• ### What is your GameDev Story?

#### Archived

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

# Rotation problems

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

## 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 on other sites
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

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 12
• 15
• 11
• 12
• ### Forum Statistics

• Total Topics
634153
• Total Posts
3015846
×