I have draw a 2D object. The object(head) consist of hair, eye, nose, etc. In my program, only eye is animating. I notice there is one problem, that is each time the animation executed, all the other parts are repainted.
My question here is, is there any way for me to keep the parts other than the eye to be static (not to be repainted each time the animation is executed), only eye is repainted each time animation is executed.
I’m a freshman at this subject, but I’ll try to respond.
Once you want to actualize your screen you the OpenGL redraws the entire scene in the buffer, an after the buffer is changed and the scene is displayed.
So if you want your application to be faster, you should make the less calculation as possible. So you just change what is necessary and after, I think, you have to say to OpenGL redraw the hole scene.
Please, if I’m wrong correct me!
one thing you can do is use a displaylist for all parts which are not animated.
Did you mean glNewList() … glEndList()?
What if my functions are in a following sequence:
Beside, there are glPushAttrib() and glPushMatrix. How do I tie together all these? I have one computer graphics reference book, but it does not mentioned how the OpenGL API is to be used in detail.
Try using a hierarchy for your models in compiled lists:
- In the global namespace, for example:
#define eye 1
#define mouth 2
#define nose 3
//various variable declarations and definitions
…declare and define starting values for above
//Prototype function declarations
- In the Body of the App, for example:
// Call each of the functions that make
//the following facial parts
make the mouth, for example…
make the nose, for example...
make the eyes, for example...
glRotatef(eyes,1,0,0); // make more eye positions to animate eyes only (just an idea)
Just an idea. Hope it helps
Wow, it was kind of you to help me! I will try your suggestion now.