1. Yes, In OpenGL you have to set up the camera before you can render your geometry. This is because the view transformation and the world (model) transformation are combined. You cannot independantly change one of them.Originally Posted by jdarling
When you call OpenGL matrix functions, you are manipulating the one of the openGl matrices (this depends on the mode you are in. change it using glMatrixMode() ). Most functions will add new transformations on top of the ones you allready built. Let's say if you do:
[pascal]
glScale( ... )
glRotate( ... )
glTranslate( ... )
[/pascal]
and you want to change the scale again, you cannot. You must either call glLoadIdentity() and rebuild everything from ground up or use a the transform stack:
[pascal]
glScale( ... )
glPushMatrix(); //We push the current Modelview matrix to the stack to save it
//So some additional transforms
glRotate( ... )
glTranslate( ... )
//Render some stuff
glPopMatrix(); //We pop the matrix that we pushed from the stack to restore its transformation
[/pascal]
2. Well, you need to view these things as separate because they actually are. It's just that opengl doesn't separate them, so if you are thinking in terms of OpenGL programming, these are indeed combined. Direct3D seperates the view from the world transform, and I think that's a better way.
3. Yeah, every time you want to modify the MODELVIEW matrix, you have to call this routine. Unless you are sure that OpenGL is allready in MODELVIEW mode. This takes some getting used to.
4. Yes, glLoadIdentity() is used to reset your transform. Be carefull with this, because if you do this, you will also reset your camera transform (because MODELVIEW was view+model combined). You probably want to use the stack to save the transforms.
5. The hardest part of this is properly understanding matrices and vectors. It took me a lot of time to squeeze them in, but it was worth it. I suggest you start looking at simple demo's and start decomposing them. If you understand how they are build, you're on the right track.
Hope this helps.
Bookmarks