# 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.

## 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 on other sites
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 on other sites
Quote:
 Original post by SilexSo if do a, say...typedef float matrix4[16], then setmatrix4 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;

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633298
• Total Posts
3011260
• ### Who's Online (See full list)

There are no registered users currently online

×