Skip to main content
GameDev.net gamedev.net
🔒 Locked

Help needed with OpenGL rotation using matrices

Started by tjames221188 Feb 9, 2010 at 2:13 PM 1 replies 950+ views
Original Post
tjames221188
tjames221188
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
Brother Bob
Brother Bob
The standard library functions use radians, not degrees. So convert the degrees to radians by multiplying them by pi/180.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.