Jump to content
  • Advertisement
Sign in to follow this  
Silex

OpenGL going over some basics, double check me please

This topic is 4865 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

The opengl call glMultMatrix takes matrices in column-major format, right? So that's: 0 4 8 12 1 5 9 13 2 6 10 14 3 7 11 15 So if do a, say...typedef float matrix4[16], then set matrix4 matrix; matrix[12]=2.0f; matrix[13]=2.0f; matrix[14]=2.0f; matrix[15]=1.0f; and call glMultMatrixf(matrix), that would be equivalent to calling glTranslatef(2.0f,2.0f,2.0f), right? Now say I have a bunch of objects, and each have their pose matrix. The loop to draw them would look something like this: glMatrixMode(GL_MODELVIEW); glLoadIdentity(); for each object { glPushMatrix(); glMultMatrixf(object.pose); glPopMatrix(); } Do I have this right?

Share this post


Link to post
Share on other sites
Advertisement
In your code, after the glLoadIdenty() and before the for-loop, you should have the viewing transformation, i.e. position the camera.
Otherwise it looks fine :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Silex
So if do a, say...typedef float matrix4[16], then set

matrix4 matrix;

matrix[12]=2.0f;
matrix[13]=2.0f;
matrix[14]=2.0f;
matrix[15]=1.0f;

and call glMultMatrixf(matrix),

that would be equivalent to calling glTranslatef(2.0f,2.0f,2.0f), right?
Only if the compiler initializes the rest of the matrix to identity, which isn't very likely. It would be more like...
matrix[0] = 1.0f;  matrix[4] = 0.0f;  matrix[8] = 0.0f;  matrix[12] = 2.0f;
matrix[1] = 0.0f; matrix[5] = 1.0f; matrix[9] = 0.0f; matrix[13] = 2.0f;
matrix[2] = 0.0f; matrix[6] = 0.0f; matrix[10]= 1.0f; matrix[14] = 2.0f;
matrix[3] = 0.0f; matrix[7] = 0.0f; matrix[11]= 0.0f; matrix[15] = 1.0f;

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!