#include "DisplayClass.h" #include "Matrix.h" #include "gl.h" #include DisplayClass::DisplayClass() { static const float pos[5] = {-3.0, -2.0, 0.0, 2.0, 3.0}; for(int i = 0; i < 5; ++i) { for(int j = 0; j < 5; ++j) { for(int k = 0; k < 5; ++k) { cubes[i][j][k].setSize(0.5, 0.5, 0.5); cubes[i][j][k].setPos(pos[k], pos[j], pos[i]); } } } } void DisplayClass::renderScene(unsigned long delta) { Cubehole cubeing(1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.5, 0.5); static float angle = 0.0; angle += delta*0.05; if(angle >= 360) angle -= 360; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Matrix p(GL_PROJECTION_MATRIX); Matrix m; std::list triangles; glLoadIdentity(); // Clean up matrix glTranslatef(0.0, 0.0, -10.0); // Then set up transformation glRotatef(angle, 0.0, 1.0, 0.0); glRotatef(angle*2, 1.0, 0.0, 0.0); glRotatef(angle*3, 0.0, 0.0, 1.0); glRotatef(-angle*5, 1.0, 1.0, 1.0); m.store(); // Save current transformation /*for(int i = 0; i < 5; ++i) { for(int j = 0; j < 5; ++j) { for(int k = 0; k < 5; ++k) { std::list ct = cubes[i][j][k].getTriangles(m); triangles.splice(triangles.end(), ct); } } }*/ std::list ct = cubeing.getTriangles(m); triangles.splice(triangles.end(), ct); glLoadIdentity(); glBegin(GL_TRIANGLES); for(std::list::reverse_iterator t = triangles.rbegin(); t != triangles.rend(); ++t) { t->render(); } glEnd(); glFlush(); }