void Robot::paintGL(void) { float len =3; glClear (GL_COLOR_BUFFER_BIT); glPushMatrix(); glTranslatef (-1.0, 0.0, 0.0); glRotatef ((GLfloat) shoulder, 0.0, 0.0, 1.0); glTranslatef (1.0, 0.0, 0.0); glPushMatrix(); glScalef (2.0, 0.4, 1.0); wireCube(1.0); glPopMatrix(); glTranslatef (1.0, 0.0, 0.0); glRotatef ((GLfloat) elbow, 0.0, 0.0, 1.0); glTranslatef (1.0, 0.0, 0.0); glPushMatrix(); glScalef (2.0, 0.4, 1.0); wireCube(1.0); glPopMatrix(); glPopMatrix(); //swapBuffers(); }
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 glPushMatrix(); glTranslatef(0.5,0.0,-1.0); // Move away from origin glColor3f(1.0,1.0,0.0); wireCube(0.5); glPopMatrix(); glPopMatrix(); // Return to base reference glFlush(); // Flush drawing routines glutSwapBuffers(); // Swap buffers }