worked on android port

opengl1 -> es
This commit is contained in:
root
2018-01-31 17:15:11 +01:00
parent a9bab839b2
commit e5e19779d5
53 changed files with 884 additions and 203 deletions

View File

@@ -0,0 +1,87 @@
#include "Window.h"
#include "Shader.h"
#include <Indoor/geo/Point3.h>
#include <Indoor/math/Math.h>
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);
glEnable(GL_BLEND);
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);
glDrawArrays(GL_TRIANGLES, 0, 12);
rs.shader->unsetVertices();
rs.shader->unsetNormals();
//glEnable(GL_CULL_FACE);
glDisable(GL_BLEND);
rs.shader->release();
}