how to avoid this kind of flickering

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.

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.

Originally posted by dorbie:
[b]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.[/b]

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

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.

search for this line in your code (or equivilant)
gluPerspective( …, … , …, … )
make the 3rd value 10x larger

Originally posted by dorbie:
[b]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.[/b]

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!
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!