PDA

View Full Version : lots of questions !



McZ
01-27-2001, 10:46 AM
I want to make a class for storing of my objects. so far I have made a little class that has a vertex array and a triangle index.

the rendering function is built in in this class so I only make a call like this:
Cube.Render();

the render function is rendering with singel triangles (GL_TRIANGLES), before the loop I rotate, move and set the material. this information is stored in my object class.

but in the OpenGL book I have (superbibel 2nd ed.) they set the material when they setup the lights, and then they use glColor to set the color of the object.

is there any difference when I set material like this ? why do they set the material when they set the lights ? isnīt the material for the object ?

and then I wanīt to know if there is any difference in speed using single triangles then triangle strips or quads ?

what do I need to have in my object class to draw the object I like ?

Relic
01-29-2001, 01:35 AM
>>but in the OpenGL book I have (superbibel 2nd ed.) they set the material when they setup the lights, and then they use glColor to set the color of the object.<<

This needs COLOR_MATERIAL to be enabled.

>>is there any difference when I set material like this ?<<

Frequent material changes (e.g. per vertex) is faster via color material instead of independent glMaterial calls.

>>why do they set the material when they set the lights ?<<

The lighting in OpenGL works on materials not on colors.

>>isnīt the material for the object ?<<

Well, not really, glMaterial is one of the few calls you can do in between glBegin-glEnd.

>>and then I wanīt to know if there is any difference in speed using single triangles then triangle strips or quads ?<<

There is a huge difference in geometry performance if the strips contain more than one triangle
Example: 102 (or n) vertices result 100 triangles (or n-2) in a single strip, but only in 34 independent triangles. That means the geometry requirements for independent triangles are three times higher for large numbers of vertices.