+ // Draw sceneObjs array\r
+ for ( int i = 0; i < nObjects; i++ ) {\r
+ glPushMatrix();\r
+ SceneObject so = sceneObjs[i];\r
+\r
+ // Apply translation vector\r
+ glTranslatef(so.x, so.y, so.z);\r
+\r
+ // Apply independant rotation vectors\r
+ glRotatef(so.rotation.x, 1.0, 0.0, 0.0);\r
+ glRotatef(so.rotation.y, 0.0, 1.0, 0.0);\r
+ glRotatef(so.rotation.z, 0.0, 0.0, 1.0);\r
+\r
+ // Apply scaling vector\r
+ glScalef(so.scale[0], so.scale[1], so.scale[2]);\r
+\r
+ // Apply texture\r
+ if ( so.texture.id > 0 ) {\r
+ getTexture(so.texture.id);\r
+ glBindTexture(GL_TEXTURE_2D, so.texture.id);\r
+ glMatrixMode(GL_TEXTURE);\r
+ glScalef(so.texture.scale, so.texture.scale, so.texture.scale);\r
+ glMatrixMode(GL_MODELVIEW);\r
+ } else {\r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
+ }\r
+\r
+ // Draw actual object\r
+ if ( so.mesh > 0 ) {\r
+ // drawMesh();\r
+ } else if ( so.mesh == -1 ) { // a mesh of -1 draws the teapot\r
+ // The teapot does not obey the right-hand rule\r
+ glFrontFace(GL_CW);\r
+ glutSolidTeapot(1);\r
+ glFrontFace(GL_CCW);\r
+ }\r
+\r
+ glBindTexture(GL_TEXTURE_2D, 0);\r
+ glPopMatrix();\r
+ }\r
+\r
+ // Draw a white ball over the light sources\r
+ glDisable(GL_LIGHTING);\r
+ glColor3f(1.0, 1.0, 1.0);\r
+\r