Search code examples
copenglmatrixdirectx-9

OpenGL Projection, View and World matrices


I have question about OpenGL projection, view and model matrices. In DirectX 9 i can easily manipulate matrix content and then apply it by using SetTransform function.

I saw in MSDN OpenGL glLoadMatrixf function, but it only changes current matrix which I can change by glMatrixMode function.

This function gets one argument with 3 options: GL_MODELVIEW, GL_PROJECTION and GL_TEXTURE. But that's the problem. How can I modify world matrix?

In DirectX 9 I can use SetTransform and one of state types: D3DTS_WORLD (macro), D3DTS_VIEW and D3DTS_PROJECTION and set matrices for them.


Solution

  • The GL_MODELVIEW matrix is exactly what its name is; a combination of the model and view matrices. Usually, you apply your view transformations first, then for each model, you push a matrix, apply model transforms, draw the model, then pop the matrix.

    If you use shaders, though, (and you have to in OpenGL 3.1+ without the compatibility profile), then you can use uniforms to pass matrices to the shader however you want, including splitting the model and view matrices if you so desire.