• Advertisement

Archived

This topic is now archived and is closed to further replies.

Rotation problems

This topic is 6066 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know I''m doing something wrong, and it''s probably pretty damn obvious, but i can''t figure it out. I''m knew to openGL so it''s pretty basic: void render() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ; glLoadIdentity() ; glEnable(GL_POINT_SMOOTH) ; angle += 0.1f ; if (angle >= 360.0f) { angle = 0.0f ; } glRotatef(angle, 0.0f, 1.0f, 0.0f) ; glTranslatef(0.0f, 0.0f, -5.0f) ; glColor3f(1.0f, 0.0f, 0.0f) ; glBegin(GL_TRIANGLE_STRIP) ; glVertex3f(0.0f, 1.0f, 0.0f) ; glVertex3f(1.0f, 0.0f, 0.0f) ; glVertex3f(-1.0f, 0.0f, 0.0f) ; glVertex3f(0.0f, 0.0f, -1.0f) ; glVertex3f(0.0f, 1.0f, 0.0f) ; glVertex3f(1.0f, 0.0f, 0.0f) ; glEnd(); glFlush() ; SwapBuffers(ghDC) ; return ; } I''m trying to rotate the triangle around the y axis, but instead it seems to translate it along the negative x axis..... I know it''s something stupid, but, any ideas? Thanks a lot. MelvinElvin.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hello Melvin,

The reason why it looks like it is going just across the negative x-axis is because of two things:

1: You have your translation after your rotation, so first it rotates and then it translates. Switch your rotatef and translatef, so translatef comes first.

2: After you do step 1, your triangle will not move, but it will not look like it is rotating because the rotation angle increments are so small: 0.1, increase this to something higher if u want to see your triangle rotating around the y-axis.

Good Luck, saisoft

Share this post


Link to post
Share on other sites

  • Advertisement