void renderWorld::renderLoop(int winWidth, int winHeight) { // Clear screen glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Select and setup the projection matrix glMatrixMode( GL_PROJECTION ); glLoadIdentity(); //update viewport glViewport( 0, 0, winWidth, winHeight ); gluPerspective( 45.0f, ((GLfloat)winWidth)/((GLfloat)winHeight), 0.1f , 10000.0f ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); cam.updateCamera(); glDepthMask( GL_TRUE ); if(advanced) { glEnable(GL_FOG); // Activate the first texture ID, shaddowmap multiplied with colormap glActiveTextureARB(GL_TEXTURE0_ARB); glBindTexture(GL_TEXTURE_2D, terrain.single_texture_id); // Activate the second texture ID and bind the fog texture to it glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); // Here we turn on the COMBINE properties and increase our RGB // gamma for the detail texture. 2 seems to work just right. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); // Bind the detail texture glBindTexture(GL_TEXTURE_2D, terrain.worleyMap_tex_id); // Now we want to enter the texture matrix. This will allow us // to change the tiling of the detail texture. glMatrixMode(GL_TEXTURE); // Reset the current matrix and apply our chosen scale value glLoadIdentity(); glScalef(DetailScale, DetailScale, 1); // Leave the texture matrix and set us back in the model view matrix glMatrixMode(GL_MODELVIEW); } else glBindTexture( GL_TEXTURE_2D, terrain.single_texture_id); if(wireframe) { glDisable( GL_TEXTURE_2D ); glPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); glCallList(terrainList); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); glEnable( GL_TEXTURE_2D ); } else glCallList(terrainList); if(advanced) { glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_FOG); glCallList(skyboxList); } else glCallList(skyboxList); }