The problem is that there's actually to targets you render to, the
back and the frontbuffer of the OpenGL surface. In each call to
Renderer.onDrawFrame()  you actually render to the back buffer while
the front buffer is presented on screen. Once you leave the
onDrawFrame method the back buffer becomes the new front buffer and is
presented on screen, while the former front buffer becomes the new
back buffer. This is called double buffering and is actually used to
reduce another form of flickering which is related to screen refresh
rates.

What happens in your case is the following (as far as i can tell). In
the first onDrawFrame() call you render some elements to the initially
black back buffer. The front buffer is also black. Now you leave
onDrawFrame() and the back buffer gets presented while the front
buffer becomes your new back buffer. But the new back buffer does not
contain the elements you just rendered! So you render your new
elements to a completely black back buffer this time so the final
image is not a composition of the first onDrawFrame and the second
one. As the buffers are constantly swaped they never have the same
content as half of the elements is in one buffer and the others are in
the other buffer.

There might be a way to disable double buffering in the GLSurfaceView
if you use that. Otherwise you will need to use EGL directly to setup
your OpenGL surface without double buffering. On the other hand i
wonder why you don't compose your complete scene in a single
onDrawFrame call.

On 18 Mrz., 13:44, ac <andres.colu...@gmail.com> wrote:
> Hello,
>
> I'm using GLSurfaceView to create a simple OpenGL drawing application.
> Since the elements drawn in each frame must remain on screen in order
> to be composed into the whole drawing, I don't use
> gl.glClear(GL10.GL_COLOR_BUFFER_BIT) at the beginning of each frame.
> But not clearing the color buffer leads to substantial flickering.
>
> Is there any way to eliminate flickering while still not clearing the
> screen at the beginning of each frame?
>
> Thanks a lot,
> ac

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to