示例#1
0
文件: quadview.cpp 项目: KAlO2/blog
GLuint displayList(void)
{
	static GLfloat gold_ambient[4]  = { 0.24725f, 0.1995f, 0.0745f, 1.0f };
	static GLfloat gold_diffuse[4]  = { 0.75164f, 0.60648f, 0.22648f, 1.0f };
	static GLfloat gold_specular[4] = { 0.628281f, 0.555802f, 0.366065f, 1.0f };
	static GLfloat gold_shininess   = 41.2f;
	
	static GLfloat silver_ambient[4]  = { 0.05f, 0.05f, 0.05f, 1.0f };
	static GLfloat silver_diffuse[4]  = { 0.4f, 0.4f, 0.4f, 1.0f };
	static GLfloat silver_specular[4] = { 0.7f, 0.7f, 0.7f, 1.0f };
	static GLfloat silver_shininess   = 12.0f;

	GLuint list = glGenLists(1);
	glNewList(list, GL_COMPILE);
	
	glMaterialfv(GL_FRONT, GL_AMBIENT,  gold_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE,  gold_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, gold_specular);
	glMaterialf(GL_FRONT, GL_SHININESS, gold_shininess);
	
	glMaterialfv(GL_BACK, GL_AMBIENT,  silver_ambient);
	glMaterialfv(GL_BACK, GL_DIFFUSE,  silver_diffuse);
	glMaterialfv(GL_BACK, GL_SPECULAR, silver_specular);
	glMaterialf(GL_BACK, GL_SHININESS, silver_shininess);
	
	glutSolidSphere(0.5/*radius*/, 32/*slices*/, 32/*stacks*/);
	glutWireTorus(0.3/*innerRadius*/, 0.5/*outerRadius*/, 64/*nsides*/, 128/*rings*/);
	glEndList();
	
	return list;
}
示例#2
0
void display (void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear display window.
	
	glEnable (GL_LINE_SMOOTH);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	switch (color)
	{
		case 1: glColor3f (1.0, 0.0, 0.0);	 break;	// Set color to red
		case 2: glColor3f (0.0, 1.0, 0.0);	 break;	// Set color to green
		case 3: glColor3f (0.0, 0.0, 1.0);	 break;	// Set color to blue
		case 4: glColor3f (0.0, 0.0, 0.0);	 break;	// Set color to black
	}

	switch (shape)
	{
		case 1 : glutWireTorus (5, 20, 10, 10); break;	// Draw wireTorus
		case 2 : glutWireSphere (30, 50, 20);  break; // Draw wireSphere
		case 3 : glutWireTeapot (25);	 break;	// Draw wireTeapot
	}

	glutSwapBuffers();
	glFlush ( );     
}
示例#3
0
void myGlutDisplay( void )
{
  static float rotationX = 0.0, rotationY = 0.0;

  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  /*** Rotate the object ***/
  rotationX += 3.3f;
  rotationY += 4.7f;

  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -1.0 );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );

  /*** Now we render object, using the variables 'segments' and
    'wireframe'.  These are _live_ variables, which are transparently 
    updated by GLUI ***/
  
  if ( wireframe )
    glutWireTorus( .2,.5,16,segments );
  else
    glutSolidTorus( .2,.5,16,segments );

  glutSwapBuffers(); 
}
示例#4
0
static void display() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );  // Clear Color and Depth
    glPushMatrix();              		// Begin drawing image
        glRotatef( x,0.0,1.0,0.0);  	// Rotate
        glColor3f(1.0,0.0, 0.0);		// Set Drawing Color to Red
        glutWireTorus(0.4,0.7,30,20);		// Draw glutWireTorus(innerRadius, outerRadius, nsides, rings);
        glPushMatrix();			  // Draw orbiting sphere
            glTranslatef(0.5,0.0,-1.0);	  // Move away from origin
            glColor3f(1.0,1.0,0.0);             // Set color to yellow
            glutWireSphere(0.3,20,16);	  // Draw Sphere
            glPushMatrix();			     // Draw glutWireTeapot orbiting around the sphere
                glRotatef( x, 0.0, 1.0, 0.0);	     // Rotate
                glTranslatef(0.3,0.0,-0.5);	     // Move reference point
                glColor3f(0.0,0.0,1.0);		     // Color Blue
                glutWireTeapot(0.2);	     // Draw teapot
            glPopMatrix();			  // Return to former reference
        glPopMatrix();			// Return to first refernce
        glPushMatrix();			  // Draw orbiting cone
            glTranslatef(-0.5,0.0,1.0);	  // Move reference poit
            glColor3f(0.0,1.0,0.0);		  // Set color to green
            glutWireCone(0.3,0.5,20,16);	  // Draw cone
        glPopMatrix();			// Return to first reference
    glPopMatrix();		      // Return to base reference
    glFlush();			      // Flush drawing routines
    glutSwapBuffers();		      // Swap buffers
}
示例#5
0
// 3Dオブジェクトを描画(引数によって変化)
void mySelectWire(int i){
	switch(i){
		case 0:
			glutWireSphere( 30.0, 10, 10);
			break;
		case 1:
			glutWireCube( 40.0 );
			break;
		case 2:
			glScalef( 1.5, 1.5, 1.5 );
			glutWireTorus( 10.0, 20.0, 20, 6);
			break;
		case 3:
			glScalef( 40.0, 40.0, 40.0 );
			glutWireTetrahedron();
			break;
		case 4:
			glTranslatef( 0.0, 0.0, 10.0 );
			glRotatef( 90.0, 1.0, 0.0, 0.0 );
			glutWireTeapot( 40.0 );
			break;
		default:
			glutWireIcosahedron();
			printf("EROOR: Wire_count\n");
			break;
	}
}
示例#6
0
static void display(void)
{
    const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
    const double a = t*90.0;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glColor3d(0,1,0);

    glPushMatrix();
        glTranslated(-2.75,1.75,-6);
        glRotated(60,1,0,0);
        glRotated(a,0,0,1);
        glutWireSphere(1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(0,-1.2,-6);
        glRotated(60,20,0,0);
        glRotated(a,0,0,1);
        glutWireCone(1,1,slices,stacks);
    glPopMatrix();

    glPushMatrix();
        glTranslated(-0,1.75,-6);
        glRotated(80,75,180,90);
        glRotated(a,0,0,1);
        glutWireTorus(0.2,0.8,slices,stacks);
    glPopMatrix();

    glutSwapBuffers();
}
示例#7
0
void DrawWheels()
{
	//Wheel1
	glPushMatrix();
	
	glColor3f(0,1,0);
	glTranslated(485,390,320);
	glRotated(90,0,1,0);
	glScaled(30,30,10);
	glutWireTorus(1,0.5,20,20);
	
	glPopMatrix();

	//Wheel2
	glPushMatrix();
	
	glColor3f(0,1,0);
	glTranslated(485,390,80);
	glRotated(90,0,1,0);
	glScaled(30,30,10);
	glutWireTorus(1,0.5,20,20);
	
	glPopMatrix();

	//Wheel3
	glPushMatrix();
	
	glColor3f(0,1,0);
	glTranslated(795,390,320);
	glRotated(90,0,1,0);
	glScaled(30,30,10);
	glutWireTorus(1,0.5,20,20);
	
	glPopMatrix();

	//Wheel4
	glPushMatrix();
	
	glColor3f(0,1,0);
	glTranslated(795,390,80);
	glRotated(90,0,1,0);
	glScaled(30,30,10);
	glutWireTorus(1,0.5,20,20);
	
	glPopMatrix();
}
void transform_render() {

	glClear(GL_COLOR_BUFFER_BIT); // clear the screen
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();

	camera->Update();

	glPushMatrix();

		//transform entire scene
		doTransform( pTransInfo[0] );

		glutWireCube(1.0);

		glPushMatrix();	
			doTransform( pTransInfo[1] );
			glutWireSphere(0.50, 10, 8);
		glPopMatrix();
		
		glPushMatrix();	
			doTransform( pTransInfo[2] );
			glutWireCone(0.2, 0.5, 10, 8);
		glPopMatrix();
		
		glPushMatrix();
			doTransform( pTransInfo[3] );
			glutSolidTeapot(0.2);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[4] );
			glutWireTorus(0.1, 0.3, 10,10);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[5] );
			glutWireDodecahedron();
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[6] );
			glutWireCube(0.25);
		glPopMatrix();

		glPushMatrix();
			doTransform( pTransInfo[7] );
			gluCylinder(qobj, 0.2, 0.2, 0.4, 8,8);
		glPopMatrix();

	glPopMatrix();

	// refresh image
	glutSwapBuffers();

	glutPostRedisplay();
	
}
void myGlutDisplay( void )
{
  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  glFrustum( -xy_aspect*.08, xy_aspect*.08, -.08, .08, .1, 15.0 );

  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -1.2f );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );

  glScalef( scale, scale, scale );

  /*** Now we render object, using the variables 'obj_type', 'segments', and
    'wireframe'.  These are _live_ variables, which are transparently 
    updated by GLUI ***/
  
  if ( obj_type == 0 ) {
    if ( wireframe )      
      glutWireSphere( .6, segments, segments );
    else                  
      glutSolidSphere( .6, segments, segments );
  }
  else if ( obj_type == 1 ) {
    if ( wireframe )
      glutWireTorus( .2,.5,16,segments );
    else
      glutSolidTorus( .2,.5,16,segments );
  }
  else if ( obj_type == 2 ) {
    if ( wireframe )
      glutWireTeapot( .5 );
    else
      glutSolidTeapot( .5 );
  }

  /* Disable lighting and set up ortho projection to render text */
  glDisable( GL_LIGHTING );  
  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  gluOrtho2D( 0.0, 100.0, 0.0, 100.0  );
  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  glColor3ub( 0, 0, 0 );
  glRasterPos2i( 10, 10 );

  /*** Render the live character array 'text' ***/
  for (unsigned int i=0; i<text.length(); ++i)
    glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, text[i] );

  glEnable( GL_LIGHTING );

  glutSwapBuffers(); 
}
示例#10
0
void zeichneSzene(void)
{
	//Löschen des Framebuffers
	glClear(GL_COLOR_BUFFER_BIT);
	
	// Malfarbe ist Blau
	glColor3f(0.0, 0.0, 1.0);
	
	
	/*
		Sphere
	------------------------------------------------------ */
		// Festlegung, in welchen Festerabschnitt gemalt wird
		// params are (x, y, width, height). the origin is the lower left corner
		glViewport(0, 0, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Kugel
		// params are (radius, slices, stacks)
		glutWireSphere(70.0, 30, 30);
	
		// Rotation um die x- und y-Achse um jeweils 45 Grad
		// params are (angle, x, y, z). x/y/z defines a vector
		glRotatef(-5.0, 1.0, 1.0, 0.0);
	
	/*
		Cube
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(200, 200, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Würfel
		// param is (size)
		glutWireCube(60.0);
	
	/*
		Cone
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(0, 200, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Kegel
		// params are (base, height, slices, stacks)
		glutWireCone(30.0, 70.0, 30,30);
	
	/*
		Torus
	 ------------------------------------------------------ */
		// Festlegung des neuen Festerabschnitts
		glViewport(200, 0, 200, 200);
	
		// Zeichnen des Glut-Grundkörpers Ring
		// params are (innerRadius, outerRadius, sides, rings)
		glutWireTorus(30.0, 50.0, 30, 30);
	
	
	// Ausgabe auf dem Bildschirm
	glFlush();
}
示例#11
0
void Torus_rotate()
{
	glScalef(1,0.5,2);// Created an Ellipse
	glRotatef(angle1,1,0,0);
	glRotatef(angle1,0,1,0);
	glRotatef(angle1,0,0,1);
	glColor3f(1,1,0);
	glutWireTorus(5,0,1,20);
	glutPostRedisplay();
}
示例#12
0
void Sphere_rotate()
{
	glRotatef(angle,1,0,0);
	glRotatef(angle,0,1,0);
	glRotatef(angle,0,0,1);
	//gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); //Need to Clarify this function use
	glColor4f(0.7,0.2,0.5,0.4);
	glutWireTorus(3,0,100,100);
	glutPostRedisplay();
}
示例#13
0
文件: fireloop.cpp 项目: ytbeom/assn3
void Fireloop::display_3d_fireloop(float lion_x, int translateLoop) {
	for (int i=0; i < NumofLoop; i++) {
		if(0<LoopList[i]+translateLoop && LoopList[i]+translateLoop<mapsize) {
			glColor3f(1.0, 0.0, 0.0);
			glPushMatrix();
			glTranslatef(LoopList[i],70,0);
			glRotatef(90,0.0,1.0,0.0);
			glutWireTorus(3, 27, 20, 20);
			glPopMatrix();
		}
	}
}
示例#14
0
void DrawHolderBase()
{
	glPushMatrix();
	
	glColor3f(1,0,0);
	glTranslated(640,430,200);
	glRotated(cannonRotation,0,1,0);
	glRotated(90,1,0,0);
	glScaled(85,85,15);
	glutWireTorus(1,0.5,20,20);
	
	glPopMatrix();	
}
示例#15
0
文件: lua_glut.c 项目: lubyk/glut
/** WireTorus	(innerRadius, outerRadius, nsides, rings) -> None
 */
static int glut_wire_torus(lua_State *L) {
  /* test argument type */
  if (lua_isnumber(L, 1) && lua_isnumber(L, 2) &&
     lua_isnumber(L, 3) && lua_isnumber(L, 4)) {

     /* call GLUT functions */
     glutWireTorus((GLdouble)lua_tonumber(L, 1), (GLdouble)lua_tonumber(L, 2),
                   (GLint)lua_tonumber(L, 3), (GLint)lua_tonumber(L, 4));
  } else {
    luaL_error(L, "incorrect argument to function 'glut.WireTorus'");
  }

  return 0;
}
示例#16
0
static void hugsprim_glutWireTorus_15(HugsStackPtr hugs_root)
{
    HsDouble arg1;
    HsDouble arg2;
    HsInt32 arg3;
    HsInt32 arg4;
    arg1 = hugs->getDouble();
    arg2 = hugs->getDouble();
    arg3 = hugs->getInt32();
    arg4 = hugs->getInt32();
    glutWireTorus(arg1, arg2, arg3, arg4);
    
    hugs->returnIO(hugs_root,0);
}
示例#17
0
void Koleso(double r1,double r2)
{
  double alfa=0,N=15,i;
  glutWireTorus(r1,r2,30,30);
  for(i=1;i<=N;i++)
  {
         glBegin(GL_LINES);
         glVertex3d( 0, 0, 0);
         if(((double)(i/2)-(int)(i/2))==0)
           glVertex3d( r2*sin(alfa), r2*cos(alfa),0.2);
         else
               glVertex3d( r2*sin(alfa), r2*cos(alfa),-0.2);
         alfa=2*i*PI/N;
         glEnd();
  }
}
示例#18
0
文件: npglut.c 项目: openantz/antz
//------------------------------------------------------------------------------
void npGlutPrimitive (int primitive)
{
	switch (primitive)
	{
	case kNPgeoCubeWire :
		glScalef (0.6f, 0.6f, 0.6f); 
		glutWireCube(2.0f);
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoCube :
		glScalef (0.6f, 0.6f, 0.6f);
		glutSolidCube(2.0f);
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoSphereWire : glutWireSphere( 1.0f, 24, 12); break;//15, 15 ); break;
	case kNPgeoSphere : glutSolidSphere( 1.0f, 24, 12 ); break;

	case kNPgeoConeWire : glutWireCone( 1.0f, 2.0f, 24, 1 ); break;
	case kNPgeoCone : glutSolidCone( 1.0f, 2.0f, 24, 1 ); break;

	case kNPgeoTorusWire : glutWireTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break;
	case kNPgeoTorus : glutSolidTorus(kNPtorusRadius * 0.1f, kNPtorusRadius, 7, 16); break;

	case kNPgeoDodecahedronWire :
		glScalef (0.6f, 0.6f, 0.6f);
		glutWireDodecahedron();
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoDodecahedron :
		glScalef (0.6f, 0.6f, 0.6f);
		glutSolidDodecahedron();
		glScalef (1.666667f, 1.666667f, 1.666667f);
		break;
	case kNPgeoOctahedronWire : glutWireOctahedron(); break;
	case kNPgeoOctahedron : glutSolidOctahedron(); break;
	case kNPgeoTetrahedronWire : glutWireTetrahedron(); break;
	case kNPgeoTetrahedron : glutSolidTetrahedron(); break;
	case kNPgeoIcosahedronWire : glutWireIcosahedron(); break;
	case kNPgeoIcosahedron : glutSolidIcosahedron(); break;

//	case kNPglutWireTeapot : glutWireTeapot( 2.0f ); break;
//	case kNPglutSolidTeapot : glutSolidTeapot( 2.0f ); break;

	default : glutWireTetrahedron(); break;
	}
}
示例#19
0
文件: example4.cpp 项目: T-Jin/glui
void myGlutDisplay()
{
  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  glFrustum( -xy_aspect*.04, xy_aspect*.04, -.04, .04, .1, 15.0 );

  glMatrixMode( GL_MODELVIEW );
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -2.6f );

  glScalef( scale, scale, scale );

  /*** Now we render object, using the variables 'obj_type', 'segments', and
    'wireframe'.  These are _live_ variables, which are transparently
    updated by GLUI ***/

  glPushMatrix();
  glTranslatef( -.5, 0.0, 0.0 );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );
  if ( wireframe && show_sphere)
    glutWireSphere( .4, segments, segments );
  else if ( show_sphere )
    glutSolidSphere( .4, segments, segments );
  draw_axes(.52f);
  glPopMatrix();

  glPushMatrix();
  glTranslatef( .5, 0.0, 0.0 );
  glRotatef( rotationY, 0.0, 1.0, 0.0 );
  glRotatef( rotationX, 1.0, 0.0, 0.0 );
  if ( wireframe && show_torus )
    glutWireTorus( .15,.3,16,segments );
  else if ( show_torus )
    glutSolidTorus( .15,.3,16,segments );
  draw_axes(.52f);
  glPopMatrix();

  glutSwapBuffers();
}
示例#20
0
文件: kpfp.c 项目: kgadek/kpfp
void display() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glDisable(GL_LIGHTING);
	glDisable(GL_TEXTURE_2D);

	//gluLookAt(1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, sin(angle/SMALLSTEPD), cos(angle/SMALLSTEPD));

	glPushMatrix();
		glTranslatef(0.0f, 0.0f, -4.0f);
		glRotatef(angle, 5.0f, 7.0f, 11.0f);
		glutWireTeapot(1.0f);
	glPopMatrix();

	glPushMatrix();
		glTranslatef(3.0f*sin(180.0f+angle/SMALLSTEPD), 3.0f*cos(180.0f+angle/SMALLSTEPD), -4.0f);
		glRotatef(angle, -17.0f, 19.0f, -13.0f);
		glutWireTeapot(0.3f);
	glPopMatrix();

	glPushMatrix();
		glTranslatef(3.0f*sin(90.0f+angle/SMALLSTEPD), 3.0f*cos(90.0f+angle/SMALLSTEPD), -4.0f);
		glRotatef(angle, -17.0f, 19.0f, -13.0f);
		glutWireTeapot(0.3f);
	glPopMatrix();

	glPushMatrix();
		glTranslatef(3.0f*sin(angle/SMALLSTEPD), 3.0f*cos(angle/SMALLSTEPD), -4.0f);
		glRotatef(angle, -17.0f, 19.0f, -13.0f);
		glutWireTeapot(0.3f);
	glPopMatrix();

	glPushMatrix();
		glTranslatef(0.0f, 0.0f, -4.0f);
		glRotatef(3.0f*angle, 1.0f, 0.0f, 0.0f);
		glutWireTorus(1.0f, 4.0f, 36.0f, 36.0f);
	glPopMatrix();

	glFinish();
	glutSwapBuffers();
}
示例#21
0
void menu (int valor)
{
  switch (valor)
    {
    case 1:
      {
	glutWireTorus(0.5, 1.0, 20, 20);
	break;
      }
    case 2:
    {
      glutWireTeapot(1);
      break;
    }
    case 3:
      {
	glutWireIcosahedron();
	break;
      }
    case 4:
    {
      glutWireCone(1.0, 1.0, 10, 10);
      break;
    }
    case 5:
    {
      glutWireOctahedron();
      break;
    }
    case 6:
      {
	glutWireTetrahedron();
	break;
      }
    case 7:
      exit(0);
    }
}
// Funktion zum Zeichnen der Grundkörper
void zeichneSzene(void)
{
	glClear(GL_COLOR_BUFFER_BIT );
	
	// Sphere
	glViewport(0, 0, W_H_C, H_H_C);
	glutWireSphere(70.0, 30, 30);
	glRotatef(-45.0, 1.0, 1.0, 0.0);

	// Cube
	glViewport(W_H_C, H_H_C, W_H_C, H_H_C);
	glutWireCube(60.0);

	// Cone
	glViewport(0, H_H_C, W_H_C, H_H_C);
	glutWireCone(30.0, 70.0, 30, 30);

	// Torus
	glViewport(W_H_C, 0, W_H_C, H_H_C);
	glutWireTorus(30.0, 50.0, 30, 30); 

	glFlush();
}
示例#23
0
//draw a frame
void RenderFrame()
{
	//Draw to pbuffer
	pbuffer.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();										//reset modelview matrix

	gluLookAt(	0.0f, 0.0f, 4.0f,
				0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f);

	//Draw scene
	if(drawTextured)
	{
		glBindTexture(GL_TEXTURE_2D, decalTexture);
		glEnable(GL_TEXTURE_2D);
		
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);

		glutSolidTeapot(0.8f);
		
		glPopMatrix();

		glDisable(GL_TEXTURE_2D);
	}
	else
	{
		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();

		glPushMatrix();
		glRotatef(timer.GetTime()/20, 0.0f, 1.0f, 0.0f);
		glRotatef(-55.0f, 1.0f, 0.0f, 0.0f);
		glutWireTorus(0.3f, 1.0f, 12, 24);
		glPopMatrix();
	}


	
	//Draw to window
	window.MakeCurrent();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	camera.SetupViewMatrix();
	glLoadMatrixf(camera.viewMatrix);


	glBindTexture(GL_TEXTURE_2D, pbufferTexture);
	//use the pbuffer as the texture
	wglBindTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);


	//Draw simple rectangle
	glBegin(GL_TRIANGLE_STRIP);
	{
		glTexCoord2f(0.0f, 0.0f);
		glVertex3f(-1.0f, -1.0f, 0.0f);
		glTexCoord2f(0.0f, 1.0f);
		glVertex3f(-1.0f,  1.0f, 0.0f);
		glTexCoord2f(1.0f, 0.0f);
		glVertex3f( 1.0f, -1.0f, 0.0f);
		glTexCoord2f(1.0f, 1.0f);
		glVertex3f( 1.0f,  1.0f, 0.0f);
	}
	glEnd();

	//release the pbuffer for further rendering
	wglReleaseTexImageARB(pbuffer.hBuffer, WGL_FRONT_LEFT_ARB);



	fpsCounter.Update();											//update frames per second counter
	glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
	window.StartTextMode();
	window.Print(0, 28, "FPS: %.2f", fpsCounter.GetFps());			//print the fps
	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	window.Print(0, 48, "%dx Anisotropy", currentAnisotropy);
	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
	window.Print(0, 68, "%s", useMipmapFilter ?	"LINEAR_MIPMAP_LINEAR filtering" :
												"LINEAR filtering");
	window.EndTextMode();
	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

	if(window.isKeyPressed(VK_F1))
	{
		window.SaveScreenshot();
		window.SetKeyReleased(VK_F1);
	}

	window.SwapBuffers();									//swap buffers

	//check for any opengl errors
	window.CheckGLError();

	//quit if necessary
	if(window.isKeyPressed(VK_ESCAPE))
		PostQuitMessage(0);
}
示例#24
0
void display_2(void)
{
char *p;
 
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  //Clear the screen
 
glMatrixMode (GL_PROJECTION);  // Tell opengl that we are doing project matrix work
glLoadIdentity();  // Clear the matrix
glOrtho(-8.0, 8.0, -8.0, 8.0, 0.0, 30.0);  // Setup an Ortho view
glMatrixMode(GL_MODELVIEW);  // Tell opengl that we are doing model matrix work. (drawing)
glLoadIdentity(); // Clear the model matrix
 
 
glColor3f(1.0, 1.0, 1.0);
if (shape == 0) Sprint(-3, -7 ,"Wire Cube");
if (shape == 1) Sprint(-3, -7 ,"Wire Cone");
if (shape == 2) Sprint(-3, -7 ,"Wire Sphere");
if (shape == 3) Sprint(-3, -7 ,"Wire Torus");
if (shape == 4) Sprint(-3, -7 ,"Wire Dodecahedron");
if (shape == 5) Sprint(-3, -7 ,"Wire Octahedron");
if (shape == 6) Sprint(-3, -7 ,"Wire Tetrahedron");
if (shape == 7) Sprint(-3, -7 ,"Wire Icosahedron");
if (shape == 8) Sprint(-3, -7 ,"Wire Teapot");
 
// Setup view, and print view state on screen
if (view_state == 1)
	{
    glColor3f( 1.0, 1.0, 1.0);
    Sprint(-2, 4, "Perspective view");
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, 1, 1, 30);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    }else
	{
	glColor3f( 1.0, 1.0, 1.0);
    Sprint(-2, 4, "Ortho view");
    }
 
glColor3f( 0.0, 0.0, 1.0);  // Cube color
 
// Lighting on/off
if (light_state == 1)
	{
	glDisable(GL_LIGHTING);  // Turn off lighting
    glDisable(GL_COLOR_MATERIAL); // Turn off material, which needs lighting to work
    }else
	{
    glEnable(GL_LIGHTING); // Turn on lighting
    glEnable(GL_COLOR_MATERIAL); // Turn on material settings
    glColorMaterial(GL_FRONT, GL_AMBIENT);
    glColor4f(0.65, 0.65, 0.65, 0.4);
    glColorMaterial(GL_FRONT, GL_EMISSION);
    glColor4f(0.10, 0.10, 0.10, 0.0);
    glColorMaterial(GL_FRONT, GL_SPECULAR);
    glColor4f(0.5, 0.5, 0.5, 0.4);
    glColorMaterial(GL_FRONT, GL_DIFFUSE);
    glColor4f(0.85, 0.85, 0.85, 0.4);
    }
 
gluLookAt( 0, 0, 20, 0, 0, 0, 0, 1, 0);
 
//glRotatef( 45, 1.0, 1.0, 0.0); // rotate cube
glRotatef( spin++, 1.0, 1.0, 1.0); // spin cube
 
if (shape == 0) glutWireCube(10); // Draw a cube
if (shape == 1) glutWireCone(5,10, 16,16);  // Draw a Cone
if (shape == 2) glutWireSphere(5, 16,16 );  // Draw a Sphere
if (shape == 3) glutWireTorus( 2.5, 5, 16, 16);
if (shape == 4)
   {
	glScalef( 3.5, 3.5, 3.5);
	glutSolidDodecahedron();
   }
 
if (shape == 5)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireOctahedron();
   }
if (shape == 6)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireTetrahedron();
   }
 
if (shape == 7)
   {
	glScalef( 5.0, 5.0, 5.0);
	glutWireIcosahedron();
   }
if (shape == 8) glutWireTeapot( 5 );
 
glutSwapBuffers();
}
示例#25
0
void drawBike(float x, float y, float z,
        float len, float high, float wid,
        float x_deg, float y_deg, float z_deg,
        float tyre,float tyre_turn)
{
    y+=0.65;
    glPushMatrix();
    glTranslatef(x,y,z);
    glRotatef(y_deg,0.0,1.0,0.0);
    glRotatef(z_deg,0.0,0.0,1.0);
    glRotatef(x_deg,1.0,0.0,0.0);

    //back
    glColor3f(1.0,1.0,0.0);
    glBegin(GL_QUADS);
    glVertex3f(-1*len/2,high/2,wid/2);
    glVertex3f(-1*len/2,high/2,-1*wid/2);
    glVertex3f(0,-1*high/2,-1*wid/2);
    glVertex3f(0,-1*high/2,wid/2);
    glEnd();

    //front
    glColor3f(0.0,1.0,1.0);
    glBegin(GL_QUADS);
    glVertex3f(1*len/2,high/2,wid/2);
    glVertex3f(1*len/2,high/2,-1*wid/2);
    glVertex3f(0,-1*high/2,-1*wid/2);
    glVertex3f(0,-1*high/2,wid/2);
    glEnd();

    //headlight
    glPushMatrix();
    glColor3f(1.0,1.0,1.0);
    glTranslatef(len/1.5,high/2,0.0);
    glRotatef(tyre_turn, 0.0f, 1.0f, 0.0f);
    glRotatef(-90,0,1.0,0);
    glutSolidCone(0.2,0.2,20,30);
    glPopMatrix();

    //seat
    glColor3f(1.0,0.0,1.0);
    glBegin(GL_QUADS);
    glVertex3f(-1*len/2,high/2,wid/2);
    glVertex3f(-1*len/2,high/2,-1*wid/2);
    glVertex3f(1*len/2,high/2,-1*wid/2);
    glVertex3f(1*len/2,high/2,wid/2);
    glEnd();

    //side left
    glColor3f(0.0,0.5,1.0);
    glBegin(GL_TRIANGLES);
    glVertex3f(-1*len/2,high/2,wid/2);
    glVertex3f(0,-1*high/2,wid/2);
    glVertex3f(1*len/2,high/2,wid/2);
    glEnd();

    //side right
    glColor3f(0.5,0.5,1.0);
    glBegin(GL_TRIANGLES);
    glVertex3f(-1*len/2,high/2,-1*wid/2);
    glVertex3f(0,-1*high/2,-1*wid/2);
    glVertex3f(1*len/2,high/2,-1*wid/2);
    glEnd();

    //handle
    glPushMatrix();
    glColor3f(0.0,0.0,0.0);
    GLUquadricObj *quadratic1;
    quadratic1 = gluNewQuadric();
    glTranslatef(BIKE_LEN/2,BIKE_HIGH/2,-0.0);
    glRotatef(tyre_turn, 0.0f, 1.0f, 0.0f);
    gluCylinder(quadratic1,0.035f,0.035f,0.5f,32,32);
    glPopMatrix();
    glPushMatrix();
    glColor3f(0.0,0.0,0.0);
    GLUquadricObj *quadratic2;
    quadratic2 = gluNewQuadric();
    glTranslatef(BIKE_LEN/2,BIKE_HIGH/2,-0.0);
    glRotatef(tyre_turn+180, 0.0f, 1.0f, 0.0f);
    gluCylinder(quadratic2,0.035f,0.035f,0.5f,32,32);
    glPopMatrix();

    glColor3f(1.0,1.0,1.0);
    //Front Tyre
    glPushMatrix();
    glTranslatef( len/2 , -high/2 , 0.0 );
    glRotatef(tyre_turn,0.0,1.0,0.0);
    glRotatef(tyre,0.0,0.0,1.0);
    glutWireTorus(0.1,0.3,10,20);
    glPopMatrix();

    //Rear Tyre
    glPushMatrix();
    glTranslatef( -len/2 ,-high/2 ,0.0 );
    glRotatef(tyre,0.0,0.0,1.0);
    glutWireTorus(RIM_RADIUS,TYRE_RADIUS,10,20);
    glPopMatrix();


    glPopMatrix();

}
示例#26
0
void
displayFunc(void)
{
  static int shape = 1;

  fprintf(stderr, " %d", shape);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  switch (shape) {
  case 1:
    glutWireSphere(1.0, 20, 20);
    break;
  case 2:
    glutSolidSphere(1.0, 20, 20);
    break;
  case 3:
    glutWireCone(1.0, 1.0, 20, 20);
    break;
  case 4:
    glutSolidCone(1.0, 1.0, 20, 20);
    break;
  case 5:
    glutWireCube(1.0);
    break;
  case 6:
    glutSolidCube(1.0);
    break;
  case 7:
    glutWireTorus(0.5, 1.0, 15, 15);
    break;
  case 8:
    glutSolidTorus(0.5, 1.0, 15, 15);
    break;
  case 9:
    glutWireDodecahedron();
    break;
  case 10:
    glutSolidDodecahedron();
    break;
  case 11:
    glutWireTeapot(1.0);
    break;
  case 12:
    glutSolidTeapot(1.0);
    break;
  case 13:
    glutWireOctahedron();
    break;
  case 14:
    glutSolidOctahedron();
    break;
  case 15:
    glutWireTetrahedron();
    break;
  case 16:
    glutSolidTetrahedron();
    break;
  case 17:
    glutWireIcosahedron();
    break;
  case 18:
    glutSolidIcosahedron();
    break;
  default:
    printf("\nPASS: test16\n");
    exit(0);
  }
  glutSwapBuffers();
  shape += 1;
  sleep(1);
  glutPostRedisplay();
}
示例#27
0
static void drawWireTorus(void)                { glutWireTorus (irad,orad,slices,stacks);        }
示例#28
0
void Car::draw()
{
	if (!active) return;
	// Reinicia transformações
	glPushMatrix();
	glTranslatef(_position.getX(), _position.getY(), _position.getZ() + 0.2);
	glRotatef(_turnAngle, 0, 0, 1);

	//corpo do carro
	glPushMatrix();
	GLfloat bodyAmb[] = { 0.35f,0.0f,0.0f,1.0f };
	GLfloat bodyDiff[] = { 0.69f,0.0f,0.0f,1.0f };
	GLfloat bodySpec[] = { 0.29f,0.28f,0.29f,1.0f };
	GLfloat bodyShine = 46;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, bodyAmb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, bodyDiff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, bodySpec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, bodyShine);
	glColor3f(1.0f, 0.0f, 0.0f);
	glScalef(1.0f, 0.8f, 0.3f);
	drawCube();
	glPopMatrix();

	//cockpit do carro
	glPushMatrix();
	glTranslatef(-0.2f, 0.0f, 0.20f);
	glScalef(0.4f, 0.6f, 0.1f);
	GLfloat cockpitAmb[] = { 0.07f,0.07f,0.07f,1.0f };
	GLfloat cockpitDiff[] = { 0.13f,0.17f,0.17f,1.0f };
	GLfloat cockpitSpec[] = { 0.42f,0.41f,0.41f,1.0f };
	GLfloat cockpitShine = 4;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, cockpitAmb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, cockpitDiff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, cockpitSpec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, cockpitShine);
	glColor3f(1.0, 1.0, 1.0);
	drawCube();
	glColor3f(1.0, 0.0, 0.0);
	glutWireCube(1.0);
	glPopMatrix();


	// roda traseira direita
	glPushMatrix();
	GLfloat wheel1Amb[] = { 0.0f,0.0f,0.0f,1.0f };
	GLfloat wheel1Diff[] = { 0.13f,0.13f,0.14f,1.0f };
	GLfloat wheel1Spec[] = { 0.17f,0.18f,0.19f,1.0f };
	GLfloat wheel1Shine = 12;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, wheel1Amb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, wheel1Diff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, wheel1Spec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, wheel1Shine);
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(-0.3f, -0.45f, 0.0f);
	glRotated(90, 1, 0, 0);
	glScalef(0.4f, 0.4f, 1.5f);
	drawWheel();
	glColor3f(0, 0, 0);
	glutWireTorus(0.05, 0.2, 32, 32);
	glPopMatrix();


	//perna dianteira direita
	glPushMatrix();
	GLfloat wheel2Amb[] = { 0.0f,0.0f,0.0f,1.0f };
	GLfloat wheel2Diff[] = { 0.13f,0.13f,0.14f,1.0f };
	GLfloat wheel2Spec[] = { 0.17f,0.18f,0.19f,1.0f };
	GLfloat wheel2Shine = 12;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, wheel2Amb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, wheel2Diff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, wheel2Spec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, wheel2Shine);
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(0.3f, -0.45f, 0.0);
	glRotated(90, 1, 0, 0);
	glScalef(0.4f, 0.4f, 1.5f);
	drawWheel();
	glColor3f(0.0, 0.0, 0.0);
	glutWireTorus(0.05, 0.2, 32, 32);
	glPopMatrix();


	// roda traseira direita
	glPushMatrix();
	GLfloat wheel3Amb[] = { 0.0f,0.0f,0.0f,1.0f };
	GLfloat wheel3Diff[] = { 0.13f,0.13f,0.14f,1.0f };
	GLfloat wheel3Spec[] = { 0.17f,0.18f,0.19f,1.0f };
	GLfloat wheel3Shine = 12;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, wheel3Amb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, wheel3Diff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, wheel3Spec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, wheel3Shine);
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(-0.3f, 0.45f, 0.0f);
	glRotated(90, 1, 0, 0);
	glScalef(0.4f, 0.4f, 1.5f);
	drawWheel();
	glColor3f(0, 0, 0);
	glutWireTorus(0.05, 0.2, 32, 32);
	glPopMatrix();


	//perna dianteira direita
	glPushMatrix();
	GLfloat wheel4Amb[] = { 0.0f,0.0f,0.0f,1.0f };
	GLfloat wheel4Diff[] = { 0.13f,0.13f,0.14f,1.0f };
	GLfloat wheel4Spec[] = { 0.17f,0.18f,0.19f,1.0f };
	GLfloat wheel4Shine = 12;
	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, wheel4Amb);
	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, wheel4Diff);
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, wheel4Spec);
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, wheel4Shine);
	glColor3f(1.0, 1.0, 1.0);
	glTranslatef(0.3f, 0.45f, 0.0);
	glRotated(90, 1, 0, 0);
	glScalef(0.4f, 0.4f, 1.5f);
	drawWheel();
	glColor3f(0.0, 0.0, 0.0);
	glutWireTorus(0.05, 0.2, 32, 32);
	glPopMatrix();

	glPopMatrix();
}
示例#29
0
文件: example5.cpp 项目: libglui/glui
void myGlutDisplay( void )
{
  glClearColor( .9f, .9f, .9f, 1.0f );
  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

  glMatrixMode( GL_PROJECTION );
  glLoadIdentity();
  glFrustum( -xy_aspect*.04, xy_aspect*.04, -.04, .04, .1, 15.0 );

  glMatrixMode( GL_MODELVIEW );

  glLoadIdentity();
  glMultMatrixf( lights_rotation );
  glLightfv(GL_LIGHT0, GL_POSITION, light0_position);
  
  glLoadIdentity();
  glTranslatef( 0.0, 0.0, -2.6f );
  glTranslatef( obj_pos[0], obj_pos[1], -obj_pos[2] ); 
  glMultMatrixf( view_rotate );

  glScalef( scale, scale, scale );

  /*** Now we render object, using the variables 'obj_type', 'segments', and
    'wireframe'.  These are _live_ variables, which are transparently 
    updated by GLUI ***/

  glPushMatrix();
  glTranslatef( -.5, 0.0, 0.0 );
  glMultMatrixf( sphere_rotate );
  if ( wireframe && show_sphere)
    glutWireSphere( .4, segments, segments );
  else if ( show_sphere )
    glutSolidSphere( .4, segments, segments );
  if ( show_axes )
    draw_axes(.52f);
  glPopMatrix();

  glPushMatrix();
  glTranslatef( .5, 0.0, 0.0 );
  glMultMatrixf( torus_rotate );
  if ( wireframe && show_torus )
    glutWireTorus( .15,.3,16,segments );
  else if ( show_torus )
    glutSolidTorus( .15,.3,16,segments );
  if ( show_axes )
    draw_axes(.52f);
  glPopMatrix();

  if ( show_text ) 
  {
    glDisable( GL_LIGHTING );  /* Disable lighting while we render text */
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    gluOrtho2D( 0.0, 100.0, 0.0, 100.0  );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glColor3ub( 0, 0, 0 );
    glRasterPos2i( 10, 10 );

    /*  printf( "text: %s\n", text );              */

    /*** Render the live character array 'text' ***/
    int i;
    for( i=0; i<(int)strlen( string_list[curr_string] ); i++ )
      glutBitmapCharacter( GLUT_BITMAP_HELVETICA_18, string_list[curr_string][i] );
  }

  glEnable( GL_LIGHTING );


  glutSwapBuffers(); 
}
示例#30
0
void display()
{
 glClear(GL_COLOR_BUFFER_BIT);
 
 glMatrixMode(GL_MODELVIEW);
 
 glLoadIdentity();
 
 gluLookAt( 0,5,1,
                  0, 0, -4,
                  0,1,0);

 
 //***************************************************
 // to generate bus body
 //***************************************************
 glPushMatrix();
 
 glColor3f(1,1,0);

 glTranslatef(0, 0, -4);

 glRotatef(angle, 0, 1, 0);
 
 glTranslatef(0, 0.5, -2);
 
 glScalef(2,1,1);
 
 glutWireCube(1);
 
 glPopMatrix();
 
 
 //***************************************************
 // to generate back right wheel
 //***************************************************
 glPushMatrix();
 
 glColor3f(0, 0, 0);

 glTranslatef(0, 0, -4);

 glRotatef(angle, 0, 1, 0);
 
 glTranslatef(-0.55, 0, -1.5);
 
 glutWireTorus(0.1, 0.2, 10, 10);
 
 glPopMatrix();
 
 glFlush();

  //***************************************************
 // to generate back left wheel
 //***************************************************
 glPushMatrix();
 
 glColor3f(0, 0, 0);

 glTranslatef(0, 0, -4);

 glRotatef(angle, 0, 1, 0);
 
 glTranslatef(-0.55, 0, -2.5);
 
 glutWireTorus(0.1, 0.2, 10, 10);
 
 glPopMatrix();
 
 glFlush();

  //***************************************************
 // to generate front right wheel
 //***************************************************
 glPushMatrix();
 
 glColor3f(0, 0, 0);

 glTranslatef(0, 0, -4);

 glRotatef(angle, 0, 1, 0);
 
 glTranslatef(0.55, 0, -1.5);
 
 glutWireTorus(0.1, 0.2, 10, 10);
 
 glPopMatrix();
 
 glFlush();

  //***************************************************
 // to generate front left wheel
 //***************************************************
 glPushMatrix();
 
 glColor3f(0, 0, 0);

 glTranslatef(0, 0, -4);

 glRotatef(angle, 0, 1, 0);
 
 glTranslatef(0.55, 0, -2.5);
 
 glutWireTorus(0.1, 0.2, 10, 10);
 
 glPopMatrix();
 
 glFlush();

 glutSwapBuffers();
 
}