PDA

View Full Version : Why does the transparent textures flicker?



mobilevisuals
06-17-2011, 03:57 AM
I want to display 2 spherical transparent background objects.
The small sphere is surrounded by the big one. Each one has a transparent texture. I can display one of the objects, but it flickers when I add the second one. What can I do to get rid of the flickering? This is the relevant code for my Android app:

gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
gl.glTexEnvx(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
GL10.GL_DECAL);

I have tried with GL_MODULATE, GL_DECAL, GL_BLEND, or GL_REPLACE, but with the same result. I have also tried with gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA);

in draw method:

float transp = 0.71f;
gl.glColor4f(1f, 1f, 1f, transp);

mhagain
06-17-2011, 04:32 AM
What Z values are you using for these objects, and what values are you using for the near and far planes of your projection matrix?

mobilevisuals
06-17-2011, 07:40 AM
Near and far is 10f and 30000.0f:

GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 10f,
30000.0f);

The spheres are situated at the origo, but their vertices have values from -8000 to 8000.

I forgot to write that I have also enabled GL_Blend.