Beispiel #1
0
//----------------------------------------------------------------------
// Draw the entire scene
//
// We first update the camera location based on its distance from the
// origin and its direction.
//----------------------------------------------------------------------
void renderScene(void) 
{
	int i, j;

	// Clear color and depth buffers
	//glClearColor(0.0, 0.7, 1.0, 1.0); // sky color is light blue
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Reset transformations
	glLoadIdentity();

	// Set the camera centered at (x,y,1) and looking along directional
	// vector (lx, ly, 0), with the z-axis pointing up
	gluLookAt(
			x,      y,      1.0,
			x + lx, y + ly, 1.0,
			0.0,    0.0,    1.0);

	glPushMatrix();
	glTranslatef(z*7.5, 7.5, 0);
	drawSnowman();
	glPopMatrix();

	glutSwapBuffers(); // Make it all visible
} 
Beispiel #2
0
//----------------------------------------------------------------------
// Draw the entire scene
//
// We first update the camera location based on its distance from the
// origin and its direction.
//----------------------------------------------------------------------
void renderScene(void) 
{
	int i, j;

	// Clear color and depth buffers
	glClearColor(0.0, 0.7, 1.0, 1.0); // sky color is light blue
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	// Reset transformations
	glLoadIdentity();

	// Set the camera centered at (x,y,1) and looking along directional
	// vector (lx, ly, 0), with the z-axis pointing up
	gluLookAt(
			x,      y,      1.0,
			x + lx, y + ly, 1.0,
			0.0,    0.0,    1.0);

	// Draw ground - 200x200 square colored green
	glColor3f(0.0, 0.7, 0.0);
	glBegin(GL_QUADS);
		glVertex3f(-100.0, -100.0, 0.0);
		glVertex3f(-100.0,  100.0, 0.0);
		glVertex3f( 100.0,  100.0, 0.0);
		glVertex3f( 100.0, -100.0, 0.0);
	glEnd();

	// Draw 36 snow men
	for(i = -3; i < 3; i++)
		for(j = -3; j < 3; j++) {
			glPushMatrix();
				glTranslatef(i*7.5, j*7.5, 0);
				drawSnowman();
			glPopMatrix();
		}

	glutSwapBuffers(); // Make it all visible
} 
Beispiel #3
0
void display(void)
{
	glClearColor(0.2,0.5,1.0,1.0);
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glLoadIdentity();
	gluLookAt(x,1.0f,z,x+lx,1.0f,z+lz,0.0f,1.0f,0.0f);

	// Draw ground
	glColor3f(0.75f,0.75f,0.75f);
	glBegin(GL_QUADS);
		glVertex3f(-100.0f,0.0f,-100.0f);
		glVertex3f(-100.0f,0.0f,100.0f);
		glVertex3f(100.0f,0.0f,100.0f);
		glVertex3f(100.0f,0.0f,-100.0f);
	glEnd();

	// Draw 36 SnowMen
	for(int i=-3; i<3; i++) {
		for(int j=-3; j<3; j++) {
			glPushMatrix();
			glTranslatef(i*10.0,0,j*10.0);
			drawSnowman();
			glPopMatrix();
		}
	}

	updateMovement();
	updateScene();

//	if(colorMode)
//		glColorMask(red,green,blue,1.0f);
//	else
//		glColorMask(1.0f,1.0f,1.0f,1.0f);

	glutSwapBuffers();
}