PDA

View Full Version : World transform (like DX) in OpenGL?



cronodragon
01-11-2007, 02:52 PM
Does OGL has a World transform matrix like DirectX? :D

Regards!
-Marco

Dan
01-11-2007, 04:45 PM
OpenGL matrices are a bit different from DirectX ones.
DX has 3 matrices in total that affect geometry transformations - World, View, Projection.
OGL has only 2 - ModelView, Projection. ModelView is basically a combinations of World and View matrices.

So to answer your question, OpenGL has a transform similar the Direct3D, but not exactly the same.

cronodragon
01-11-2007, 05:15 PM
Hmm, how can I create a world transform + view transform matrix for OGL?

Dan
01-11-2007, 05:32 PM
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
gluLookAt(EyeX, EyeY, EyeZ, TargetX, TargetY, TargetZ, UpX, UpY, UpZ);
//this creates the view matrix transformation

then you can use
glRotatef, glScalef, glTranslatef to build the world matrix

or you can use glLoadMatrixf to load already built World*View matrix.

cronodragon
01-11-2007, 05:49 PM
So basically I just multiply World*View?

Regards!
-Marco

Dan
01-11-2007, 07:33 PM
yes and then pass it to OGL with glLoadMatrixf