Public Group

# Help needed with OpenGL rotation using matrices

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

## Recommended Posts

Hi there, I am new to opengl and I am having a bit of trouble. here is my code: int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-1.0f, 0.0f, -10.0f); glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); drawCylinder(5.0f); glLoadIdentity(); const GLfloat t[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, -10.0f, 1.0f}; //rotate 90 in x axis GLfloat r[16] = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, cos(90.0f), -sin(90.0f), 0.0f, 0.0f, sin(90.0f), cos(90.0f), 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}; glTranslatef(0.0f, 0.0f, 10.0f); glLoadMatrixf(t); glMultMatrixf(r); drawCylinder(5.0f); return TRUE; } My problem is when i rotate using a matrix, the rotation always seems to be less than it should. here is an image comparing the two: http://img714.imageshack.us/img714/6508/lalalay.jpg in this image the cylinder on the left has been rotated by 90 degrees in the x axis using glRotatef(). The cylinder on the right has been rotated by using the above matrix. If anyone has any suggestions they would be greatly appreciated as it's starting to drive me slightly insane! many thanks in advance, Toby

##### Share on other sites
The standard library functions use radians, not degrees. So convert the degrees to radians by multiplying them by pi/180.

##### Share on other sites
Thankyou so much!

• 12
• 12
• 23
• 10
• 19