PDA

View Full Version : How to think openGL or structure of



nexusone
06-21-2000, 01:34 PM
I have looked at a lot of openGL site and seen examples. But I am not sure on the structure of openGL....
Here is what I think I know.

1. Opengl should be though of as the render and that object and their movement are delt with at the C code level. So to change a scene you change the object's location then have the opengl render the change.

2. Matrix or stack.... The Matrix work's sorta like the stack in a program. The active stack is the only stack change by rotate and translate commands. But when the opengl renders it renders all matrix to the screen?

Rob The Bloke
06-21-2000, 02:25 PM
1.OpenGL is a graphics API that allows you to draw 3D graphics within a C program. It provides a set of basic tools that you can use to manipulate objects and draw them. The inclusion of the 'glut.h' header file and library, allows you to control input devices such as mice, keyboards, joypads etc.

Because openGL is a set of very low level functions and tools. With their use and mainly C code you can construct higher level tools. ie, object loaders, texture loaders etc. OpenGL doesn't have support for these things by default, mainly because input devices can change, file formats can change and be updated. It is up to the programmer to create their own set of tools therefore.

2.At the simplest level, OpenGL uses matrices to rotate, scale and translate objects. If you remember back to your maths lessons at school, matrices can be multiplied together to give a combined effect. (eg, scaling and rotating with one matrix) The order in which these matrices are multiplied is non-commutitive, ie, translate*scale != scale*translate.

The stack stores these combined matrices and the vertex data, normals etc. The vertices are then multiplied by the matrices. A stack is a first in last out data structure. This is why when using openGL, the commands are written back to front.

so,

glTranslated(x,y,z);
glScalef(sx,sy,sz);
glutWireCube(0.1);

would actually be read so that, the cube would be drawn first, then it would be scaled and then it would be translated.

drakaza
06-21-2000, 03:38 PM
Originally posted by Rob The Bloke:

glTranslated(x,y,z);
glScalef(sx,sy,sz);
glutWireCube(0.1);

would actually be read so that, the cube would be drawn first, then it would be scaled and then it would be translated.

~~~~~
I thought that only transformations were done in reverse order, not the actual drawing of it.....cause if you draw it then transform it, then how does the transformation get applied??

I'm still trying to get the whole concept of this reverse-order thing...so please excuse me if i just missed something...or missed your point http://www.opengl.org/discussion_boards/ubb/smile.gif

-Drak

john
06-22-2000, 04:41 AM
hi,

some points to clarify...

1) OpenGL doesn't worry about input not because it changes so much (because so does graphcis hardware), but becasue it's beyond it's scope. If change was the only reason, then there would be no graphics API either

2) OpenGL isn't just for C, and was never designed/specified to be language specific

3) the order of transformations is *NOT* because of the stack, but because the matricies are post-multiplied. it's entirely feasiable to have a stack with "reverse" ordered transformations.

I could explain the story behind the ordering, but i have before and... it's not very exciting http://www.opengl.org/discussion_boards/ubb/wink.gif

cheers
John