Rotation problems

Started by
0 comments, last by MelvinElvin 22 years, 9 months ago
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.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Advertisement
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

This topic is closed to new replies.

Advertisement