/* * © Copyright 2014 – Urheberrechtshinweis * Alle Rechte vorbehalten / All Rights Reserved * * Programmcode ist urheberrechtlich geschuetzt. * Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner. * Keine Verwendung ohne explizite Genehmigung. * (vgl. § 106 ff UrhG / § 97 UrhG) */ #include "../../../fixC11.h" #include "Window.h" #include "Shader.h" #include #include static float window_vertices[] = { +1, 0, +1, -1, 0, +1, -1, 0, -1, -1, 0, -1, +1, 0, -1, +1, 0, +1, -1, 0, +1, +1, 0, +1, -1, 0, -1, +1, 0, -1, -1, 0, -1, +1, 0, +1, }; static float window_normals[] = { 0,-1,0, 0,-1,0, 0,-1,0, 0,-1,0, 0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0, 0,+1,0, 0,+1,0, 0,+1,0, 0,+1,0, }; Window::Window(const Point2 from, const Point2 to, float atHeight, float height) : from(from), to(to), atHeight(atHeight), height(height) { const Point2 cen = (from+to)/2; const float sx = from.getDistance(to) / 2.0f; const float sz = height / 2.0f; const float rad = -std::atan2(to.y - from.y, to.x - from.x); const float deg = rad * 180 / M_PI; mat.translate(cen.x, cen.y, atHeight + height/2); mat.rotate(deg, 0, 0, 1); mat.scale(sx, 1, sz); } void Window::render(const RenderSettings& rs) { rs.shader->bind(); rs.shader->setColor(0.75, 0.85, 1.0, 0.35); rs.funcs->glEnable(GL_BLEND); rs.funcs->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //glDisable(GL_CULL_FACE); rs.shader->setModelMatrix(mat); rs.shader->setVertices(window_vertices); rs.shader->setNormals(window_normals); rs.funcs->glDrawArrays(GL_TRIANGLES, 0, 12); rs.shader->unsetVertices(); rs.shader->unsetNormals(); //glEnable(GL_CULL_FACE); rs.funcs->glDisable(GL_BLEND); rs.shader->release(); }