Example #1
0
void display(void)
{
	float t = glutGet(GLUT_ELAPSED_TIME)/500.0;
    static float last_t = 0;
    float dt = t - last_t; last_t = t;

	printError("pre display");

	// clear the screen
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    lookAt(position.x,position.y,position.z,
           look_at.x,look_at.y,look_at.z,
           0,1,0,
           camMatrix);

	//myMatrix[3] += dir*0.01;

    draw_billboard();
    for(int i = 0; i < NUMBER_OF_WINDMILLS; ++i) {
        draw_windmill(&my_windmills[i], dt);
	}

   	//glBindTexture(GL_TEXTURE_2D, bunnyTextureID);
   	//glUniform1i(glGetUniformLocation(programs[WINDMILL_PROGRAM], "texUnit"), 0); // Texture unit 0

	glutSwapBuffers();
}
Example #2
0
void draw_scene()
{
	static float  ang_self = 0.0;  /*Define the angle of self-rotate */
	static float  angle = 0.0;

	glLightfv(GL_LIGHT4, GL_POSITION, lit4_position);
	glLightfv(GL_LIGHT4, GL_SPOT_DIRECTION, lit4_direction);

	glLightfv(GL_LIGHT5, GL_POSITION, lit5_position);
	glLightfv(GL_LIGHT5, GL_SPOT_DIRECTION, lit5_direction);

	glLightfv(GL_LIGHT1, GL_POSITION, lit1_position);  /*fixed position---*/
	glDisable(GL_TEXTURE_2D);
	draw_floor();

	glMatrixMode(GL_TEXTURE);
	glLoadIdentity();
	glTranslatef(0.0, 0.0, 0.0);
	glMatrixMode(GL_MODELVIEW);

	draw_slope();
	draw_axes();
	draw_object();

	/*-------Draw the billboard ----*/
	glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);

	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glBindTexture(GL_TEXTURE_2D, textName[2]);
	glEnable(GL_TEXTURE_2D);
	draw_billboard(5.0*4.0, -3.0*4.0, 5.0, 8.0);
	draw_billboard(6.0*4.0, -5.0*4.0, 5.0, 8.0);
	draw_billboard(3.0*4.0, -6.0*4.0, 5.0, 8.0);
	draw_billboard(2.0*4.0, -7.0*4.0, 5.0, 8.0);
	draw_billboard(7.0*4.0, -2.0*4.0, 5.0, 8.0);

	glDisable(GL_TEXTURE_2D);

	/*-------Draw the car body which is a cube----*/
	glTranslatef(position[0], position[1], position[2]);
	glRotatef(-up_ang, 1.0, 0.0, 0.0);
	glRotatef(self_ang, 0.0, 1.0, 0.0);

	glPushMatrix();              /* Save M1 coord. sys */
	draw_cube();
	glPopMatrix();               /* Get M1 back */
								 /*-------Draw the front wheels -----*/
	glColor3f(1.0, 0.0, 0.0);
	glPushMatrix();              /* Save M1 coord. sys */
	glTranslatef(-4.0, 0.0, 3.0); /* Go to left wheel position */
	glutSolidTorus(0.5,  /* inner radius */
		1.0,  /* outer radius */
		24,   /* divided into 18 segments */
		12);  /* 12 rings */
	glPopMatrix();

	glPushMatrix();              /* Save M1 coord. sys */
	glTranslatef(-4.0, 0.0, -3.0);/* Go to right wheel position */
	glutSolidTorus(0.5,  /* inner radius */
		1.0,  /* outer radius */
		24,   /* divided into 18 segments */
		12);  /* 12 rings */
	glPopMatrix();

	/*------Draw back wheels ----*/
	glColor3f(1.0, 0.4, 0.0);
	glPushMatrix();              /* Save M1 coord. sys */
	glTranslatef(6.0, 0.0, 0.0); /* Go to left wheel position */
	glutSolidTorus(0.5,  /* inner radius */
		1.0,  /* outer radius */
		24,   /* divided into 18 segments */
		12);  /* 12 rings */
	glPopMatrix();

	glColor3f(1.0, 0.4, 0.4);
	glPushMatrix();              /* Save M1 coord. sys */
	glTranslatef(0.0, 1.5, 7.5); /* Go to left wheel position */
	glRotatef(-90.0, 1.0, 0.0, 0.0);
	glutSolidTorus(0.5,  /* inner radius */
		3.0,  /* outer radius */
		24,   /* divided into 18 segments */
		12);  /* 12 rings */
	glPopMatrix();

	glColor3f(1.0, 0.4, 0.4);
	glPushMatrix();              /* Save M1 coord. sys */
	glTranslatef(0.0, 1.5, -7.5); /* Go to left wheel position */
	glRotatef(-90.0, 1.0, 0.0, 0.0);
	glutSolidTorus(0.5,  /* inner radius */
		3.0,  /* outer radius */
		24,   /* divided into 18 segments */
		12);  /* 12 rings */
	glPopMatrix();

	glColor3f(1.0, 1.0, 1.0);
	glPushMatrix();
	glTranslatef(0.0, 1.5, 7.5);
	glRotatef(bld_ang, 0.0, 1.0, 0.0);
	draw_blade();/* draw the first blade */
	glRotatef(120, 0.0, 1.0, 0.0);
	draw_blade();/* draw the first blade */
	glRotatef(120, 0.0, 1.0, 0.0);
	draw_blade();/* draw the first blade */
	glPopMatrix();

	glColor3f(1.0, 1.0, 1.0);
	glPushMatrix();
	glTranslatef(0.0, 1.5, -7.5);
	glRotatef(bld_ang, 0.0, 1.0, 0.0);
	draw_blade();
	glRotatef(120, 0.0, 1.0, 0.0);
	draw_blade();
	glRotatef(120, 0.0, 1.0, 0.0);
	draw_blade();
	glPopMatrix();

}