# OpenGL Open GL rotation question!

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

## Recommended Posts

I have an OpenGL window with drawn coordinate sistem and lines. Lines are rotating around center point (0,0,0) with: glRotatef(xRotAng, 0, 1, 0) glRotatef(yRotAng, 1, 0, 0) and coordinate sistem is translated for: glTranslatef(0.0f, 2.0f, -10.0f) and it's rotating with lines... How can i make coordinate sistem to rotate with the same rotation as lines, only it must rotate around it's axis?! tnx for help

##### Share on other sites
This is a question on order of operations. The last operation is "done" first.
So

glTranslatef(0.0f, 2.0f, -10.0f)
glRotatef(xRotAng, 0, 1, 0)
glRotatef(yRotAng, 1, 0, 0)

should work for you. It rotates around x axis, then y axis, then translate.

##### Share on other sites
I tried that and it doesn't work ... Coordinate system gets some weird rotation...

I also tried reseting the window with glLoadIdentity() and it still doesn't work...

Before and after drawing of any object i use glPushMatrix() and glPopMatrix()...

Should i use perhaps gluLookAt() function ?

##### Share on other sites
Quote:
 Original post by u_r_b_a_nShould i use perhaps gluLookAt() function?
gluLookAt won't help you much if you don't understand how transformations work - gluLookAt computes exactly the same translations and rotations internally. I would suggest that you pick up a book on geometrical transformation and matrices - Computer Graphics, Principles and Practice is a little dated, but the low-level stuff (including math) is very useful.

Along the same lines as V-man's point, it is often helpful to think about camera transformations as affecting the world, not the camera (you don't translate the camera by 5 units along the z-axis, instead you translate the world by -5 along the z-axis).

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013736
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!