Пример #1
0
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
    glPushMatrix();
        gltApplyCameraTransform(&frameCamera);
        
        // Position light before any other transformations
        glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);
        
        // Draw the ground
        glColor3f(0.60f, .40f, .10f);
        DrawGround();
        
        // Draw shadows first
        glDisable(GL_DEPTH_TEST);
        glDisable(GL_LIGHTING);
        glPushMatrix();
            glMultMatrixf(mShadowMatrix);
            DrawInhabitants(1);
        glPopMatrix();
        glEnable(GL_LIGHTING);
        glEnable(GL_DEPTH_TEST);
        
        // Draw inhabitants normally
        DrawInhabitants(0);

    glPopMatrix();
        
    // Do the buffer Swap
    glutSwapBuffers();
    glutPostRedisplay();
    }
Пример #2
0
// Called to draw scene
void RenderScene(void)
{
	static GLfloat yRot = 0.0f;         // Rotation angle for animation
	yRot += 0.5f;
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	glPushMatrix();
		gltApplyCameraTransform(&frameCamera);
		glTranslatef(0.0f, 1.4f, -2.5f); //view initial position
		glScalef(4.0f,4.0f,4.0f);  //enlarge
		glLightfv(GL_LIGHT0,GL_POSITION,fLightPos);	
		
		DrawSky(tex.get_texture(SKY_TEXTURE));		
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tex.get_texture(GROUND_TEXTURE));
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
		glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
		glColor3f(0.9f,0.9f,0.9f);
		gmm.DrawGround();
		/*
		glDisable(GL_DEPTH_TEST);
		glDisable(GL_LIGHTING);
		glDisable(GL_TEXTURE_2D);		
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glPushMatrix();		
			glMultMatrixf(mShadowMatrix);
			gmm.DrawGym(1);
		glPopMatrix();
		glDisable(GL_BLEND);
		glEnable(GL_LIGHTING);
		glEnable(GL_DEPTH_TEST);
		*/
		gmm.DrawGym(0);		
		DrawEarth(tex.get_texture(EARTH_TEXTURE));
	//debug show
/*
		glPushMatrix();
			glTranslatef(fLightPos[0],fLightPos[1], fLightPos[2]);
			glColor3ub(240,240,0);
			glutSolidSphere(0.6f,10,10);
		glPopMatrix();	
*/
	glPopMatrix();		
	glutSwapBuffers();
	glutPostRedisplay();
}