Jump to content
  • Advertisement
Sign in to follow this  

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.

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

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 this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!