PDA

View Full Version : how to avoid this kind of flickering



hapcafe
06-13-2002, 06:13 PM
Sorry for my crossposting. I posted the following content on the beginners section, but nobody replied to it. So I hope people here can help me.


The code is like following:
/**********************************/
GLUquadricObj *Bubble;
Bubble=gluNewQuadric();
gluQuadricDrawStyle(Bubble, GLU_FILL);
gluQuadricTexture(Bubble, true);
gluQuadricCallback(Bubble, GLU_ERROR, ErrorCallback);
float radius[4]={2.0, 2.0, 2.0, 2.0};

StartList=glGenLists(4);

glNewList(StartList, GL_COMPILE);
gluSphere(Bubble, radius[0], 10, 10);
glEndList();

glNewList(StartList+1, GL_COMPILE);
gluSphere(Bubble, radius[1], 10, 10);
glEndList();

glNewList(StartList+2, GL_COMPILE);
gluSphere(Bubble, radius[2], 10, 10);
glEndList();

glNewList(StartList+3, GL_COMPILE);
gluSphere(Bubble, radius[3], 10, 10);
glEndList();
/**********************************/

To my surprise, I found that bubbles flickered greatly when the four components of the "radius" are different. But when they are the same, say 2.1, they nearly don't flicker. Why and how to solve it?
Thanks in advance.

dorbie
06-13-2002, 06:25 PM
Sounds like the problem is the zbuffering.

When the radius is slightly different you get differences in depth rasterization and therefore z fighting.

Use glDepthMask to disable depth writes on all but the last bubble.

hapcafe
06-14-2002, 08:04 AM
Originally posted by dorbie:
Sounds like the problem is the zbuffering.

When the radius is slightly different you get differences in depth rasterization and therefore z fighting.

Use glDepthMask to disable depth writes on all but the last bubble.

Thanks. But I am not clearly about what you mean. The bubbles are so widely separated that there should be no z_buffer fighting.

dorbie
06-14-2002, 08:08 AM
Then I am lost for an explanation.

Perhaps you get their size confused or use a different dlist in each position each frame causing it to be some random size each frame and therefore flicker.

zed
06-14-2002, 01:12 PM
search for this line in your code (or equivilant)
gluPerspective( .., .. , .., .. )
make the 3rd value 10x larger

hapcafe
06-14-2002, 08:01 PM
Originally posted by dorbie:
Then I am lost for an explanation.

Perhaps you get their size confused or use a different dlist in each position each frame causing it to be some random size each frame and therefore flicker.

Thanks a lot. What you say is just what I did. For some reasons, I do display bubbles with different sizes, but I ignored the possibility to render the same bubble with different sizes at the same place. What a stupid one! http://www.opengl.org/discussion_boards/ubb/smile.gif
I posted another big problem in my application named "Physics-based modelling and reality " which confused me a lot. Would you please give some information?
Thanks to all of you!