ROTATION IN OpenGL:
first of all we will create a window for drawing here is the code for creation of window here and naw draw a rectangle or triangle by using GL_QUADS function you can see that how to draw rectangle here
for rotation we use the builtian function glRotatef()
syntax:
glRotatef(angle , float x , float y , float z)
f indicate the it will take the value in floating point. it will take 4 perameter
example:
void Draw_triangle() {
glPushMatrix(); //Save the transformations performed thus far
glRotatef(-40.0, 0.0, 0.9, 0.0);
glBegin(GL_QUADS);
glColor3f(0.0f,1.0f,0.0f);
glVertex2f( 0.2, 0.49);
glVertex2f(0.4, 0.49);
glVertex2f(0.4, 0.76);
glVertex2f( 0.2, 0.76);
glEnd();
glPopMatrix();
glFlush();
}
screen short:
Rotation |
0 comments:
Post a Comment