PDA

View Full Version : grouping storing or something like that



selcux
09-29-2005, 11:25 AM
Hello,
I am new in graphic programming and I do not know whether there is the right place to ask this question or not.
My problem is that when I draw some lines arc etc. ı want to treat them as single object and if possible to store it. So when I call it do not need to redraw it.
Is this possible? what kind of tool do I have to use?

dorbie
09-29-2005, 02:12 PM
Graphics application rendering tends to be data driven, so you can simply store the data to describe the arc somewhere in memory and call your rendering with that data. This is particularly effective with something like glDrawArrays.

Alternatively you can use display lists, but be warned that this is good for large ammounts of data but drawing small uncomplex objects this way is not a good idea. To use Display Lists you need to use calls like:

glNewList(my_objects_unique_integer, GL_COMPILE);
// make draw calls here
glEndList();

Then to draw that object in the future just make the single call:

glCallList(my_objects_unique_integer);

You can still move that object around with matrix calls and change the texture and color it uses if you define it without that state and bind textures or specify colors externally to the list. Alternatively you can make the positional information, the texture and the color etc. part of the object simply by making those calls inside the display list creation code. You have complete flexibility.