Esempio n. 1
0
void display()
{
   /*start boiler*/
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity(); 
   //set camera direction and position
   gluLookAt(viewer[0], viewer[1], viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   //draw light source
   glLightfv(GL_LIGHT0, GL_POSITION, light_one);
   /*end boiler*/

 
   
   s.draw();

   //yellow triangle /square
   /*glBegin(GL_QUADS);
       glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, yellow);
	   glVertex3f(-2 , 2,0);
	   glVertex3f(2 , 2,0);
	   glVertex3f(2 , -2,0);
	   glVertex3f(-2 , -2,0);
   glEnd();*/

   //red triangle
   //glBegin(GL_TRIANGLES);
   //    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, cyan);
	  // glVertex3f(-5,0,0);
	  // glVertex3f(-5,-5,0);
   //    glVertex3f(0,0,0);
   //glEnd();

   ////green triangle
   // glBegin(GL_TRIANGLES);
   //    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
	  // glVertex3f(0,0,0);
	  // glVertex3f(5,-5,0);
   //    glVertex3f(5,0,0);
   //glEnd();

   ////blue triangle
   // glBegin(GL_TRIANGLES);
   //    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
	  // glVertex3f(5,-5,0);
	  // glVertex3f(10,-5,0);
   //    glVertex3f(10,0,0);
   //glEnd();

  


   /*start boiler*/
   glFlush();
   glutSwapBuffers();
   /*end boiler*/
}
void display()
{
   /*start boiler*/
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity(); 
   //set camera direction and position
   gluLookAt(viewer[0], viewer[1], viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
   //draw light source
   glLightfv(GL_LIGHT0, GL_POSITION, light_one);
   /*end boiler*/


   //dummy triangle
   //glBegin(GL_QUADS);
   //    glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
	  // glVertex3f(-2,2,0);
	  // glVertex3f(2,2,0);
   //    glVertex3f(2,-2,0);
	  // glVertex3f(-2,-2,0);
   //glEnd();
    

	/*moveCounter++;
	if (moveCounter < 100)
	{
		s.move(0.1, 0.1);
	}*/

   GLfloat increment = 0.005;

   if (moveCounter > 1000)
   {

	   moveCounter = 0;
   }
   
   if (moveCounter > 660)
   {
	   changeColor[1] += increment;
	   changeColor[2] = 0;
	   changeColor[0] = 0;
   }
   else if (moveCounter > 330)
   {
	   changeColor[1] = 0;
	   changeColor[2] += increment;
	   changeColor[0] = 0;
   }
   else if (moveCounter > 0)
   {
	   changeColor[1] = 0;
	   changeColor[2] = 0;
	   changeColor[0] += increment;
   }
   moveCounter++;

   s.setColor(changeColor);
   
    s.draw();
	glutPostRedisplay();

   /*start boiler*/
   glFlush();
   glutSwapBuffers();
   /*end boiler*/
}