Write a code to continuously rotate square about pivot point, Computer Graphics

Write a code to continuously rotate a square about a pivot point. 


static GLfloat rotat=0.0;  

void init(void);

void display(void);

void reshape(int w, int h);

void rotate(void);  

int main()





        glutCreateWindow("Moving squares");







void init(void){ 



void display(void)


   glPushMatrix(); //Push the transformation matrix to stack 


   //Translate the pivot point to origin

   glRotatef(rotat,0.0,0.0,1.0); // Rotate about origin


   //Translate pivot point back to its position

   glColour3f(0.0,0.0,1.0); //Set colour of square

   glRectf(-50.0,-50.0,50.0,50.0); //Draw square 

   glPopMatrix(); //Pop the matrix from stack

   glutSwapBuffers(); // Swap buffers


void reshape(int w, int h)

{        glViewport(0,0,(GLsizei)w,(GLsizei)h);







void rotate(void)

{     rotat+=0.1; //Continuously increse the rotation angle by 0.1



        glutPostRedisplay(); //send the current window for




Posted Date: 4/26/2013 2:56:01 AM | Location : United States

Related Discussions:- Write a code to continuously rotate square about pivot point, Assignment Help, Ask Question on Write a code to continuously rotate square about pivot point, Get Answer, Expert's Help, Write a code to continuously rotate square about pivot point Discussions

Write discussion on Write a code to continuously rotate square about pivot point
Your posts are moderated
Related Questions
Objectives of Curves and surfaces - modeling and rendering After going through the section, you should be capable to: Implement the methods utilized to represent a pol

Explain about the Computer animation Computer animation is the art of creating moving images by computer software and hardware. For 3D animation, objects are designed on a

What is the major disadvantages of storing information structures in display memory? A major disadvantage of storing information structures in display memory is that when color an

Question 1) Encode the following string using HUFFMAN ENCODING:                            DO YOU LIKE TINKY WINKY OR EMPTY DUMPTY?     Empty spaces are considered.

Illustration: Find the normalization transformation N that uses the rectangle W (1, 1), X (5, 3), Y (4, 5) and Z (0, 3) as a window and also the normalized device screen like the

Three-Dimensional Viewing Three dimensional objects are created using modelling coordinate system. The modelled objects are then placed in locations specified in the scene with

explain in detail the application of computer graphics in education and training?

Determine the perspective transformation matrix upon to z = 5 plane, when the center of projection is at origin. Solution. As z = 5 is parallel to z = 0 plane, the normal is s

Sketch Line Segment That Joining By Using Bresenham Line Algorithm Example: Sketch line segment that joining (20, 10) and (25, 14) by using Bresenham line generation algorit

Define clipping and covering (exterior clipping)? Clipping is the process of cutting a graphics display to neatly fit a predefined graphics region or the view port.  This is