#include "Cuboid.h" #include "DisplayClass.h" #include "Matrix.h" #include "gl.h" #include void DisplayClass::renderScene(unsigned long delta) { Cuboid cube1(2, 2, 1, -1, 1, 0.5); Cuboid cube2(1, 1, 2, -0.5, 0.5, -1.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, 0.0, 0.0, 1.0); m.store(); // Save current transformation std::list t1 = cube1.getTriangles(m); triangles.splice(triangles.end(), t1); glRotatef(angle*10, 0.0, 0.0, 1.0); m.store(); std::list t2 = cube2.getTriangles(m); triangles.splice(triangles.end(), t2); //std::sort(triangles.begin(), triangles.end(), Sorter(p)); glLoadIdentity(); glBegin(GL_TRIANGLES); for(std::list::reverse_iterator t = triangles.rbegin(); t != triangles.rend(); ++t) { t->render(); } glEnd(); glFlush(); }