Sign in to follow this  
tjames221188

Help needed with OpenGL rotation using matrices

Recommended Posts

tjames221188    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this