View Full Version : newbie: general overview wanted

03-25-2000, 10:01 PM
i'm just starting out trying to learn ogl but i need to know the grand scheme of things before this stuff clicks for me. the following is my thinking. please help me clear it up:

when you open a window ready for OpenGL to draw in it, you specify a coordinate system, like, "the center of the world shown in the window is (0,0,0)".

you then draw a shape, series of connected lines, etc.. by specifying vertices between glBegin() and glEnd() commands. the coordinates of these vertices are with respect to the world c.s. specified above.

you then tell ogl: where you're looking at the scene from (x,y,z) and whether it's a wide angle view or a close-up. this gets done after (?) the glBegin()/glEnd() business...

now suppose i want to move the specified object about the screen (err,... about the "world"). does ogl keep special 4x4 matrices around for this purpose? how often are the values of these matrices changed? suppose a scene with many different moving objects is being rendered; do each of these objects have their own transformation/translation matrices or is the same one matrix constantly changed and used one-by-one on each of the different objects?

and... i really have no idea how glPushMatrix() and glPopMatrix fit it to this whole thing.

thanks in advance for your comments. please begin sermon now. :-)

03-26-2000, 12:52 AM

OpenGL only have one matrix to transform vertices, and it's called the model view matrix (there is two more for projection and texturemapping). If you want to translate or rotate the object, the modelview matrix changed. In other words, the matrix will be changed for each transformation. There will only be one matrix for all objects, wich means you have to "create a new one" each time you want to place the object somewhere else and/or draw it in another direction.

How about push and pop then... Since there is only one matrix for modelview/projection/texturemapping, you might wanna change the matrix, and then restore it later. Look at this.

// setup projection matrix
// draw something
// setup new projection matrix
// draw something else

This piece of pseudocode will first setup the projection matrix, draw something, then we want to setup at new matrix, but we want to be able to get back to the old one later. First we push it, then pop it when we want to get it back. Push and pop is stack functions, which means the matrix you push first, will be popped last.

Hope it helps some, Bob

03-27-2000, 06:16 PM
thanks bob!