Re: [android-developers] Re: screen flickering in GLSurfaceView

2010-03-26 Thread Andres Colubri

Hi,

I just wanted to mention that I found a method that solves the 
flickering problem in continuous drawing applications:
* right after the frame has been completely drawn, but before doing the 
buffer swap, copy the screen image into a texture using 
glCopyTexImage2D. This texture should be rgba, have a size coinciding 
with the screen resolution, and minification and magnification filtering 
set to nearest.
* before starting the drawing of the next frame, render the texture so 
it covers the whole screen.


Does this make sense?

ac

Mario Zechner wrote:

oh, i tried that once with OpenGL ES. I didn't use the backbuffer but
drew directly to a texture using an intermediate Bitmap as the drawing
surface and reuploading only those parts of the texture that changed.
You can find a video and an apk of that at
http://apistudios.com/hosted/marzec/badlogic/wordpress/?cat=10. The
problem is that if you update to much of the texture at once you get
100ms interruptions which might be visible to the user.

On 18 Mrz., 14:46, Andres Colubri andres.colu...@gmail.com wrote:
  

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.
  

Thanks for the explanation, this makes the source of the problem
perfectly clear.



There might be a way to disable double buffering in the GLSurfaceView
if you use that.
  

That would be nice, I wonder if it is possible to do at all... After a
quick look at the source code of GLSurfaceView, it seems to me that the
double buffering is hard coded into the EglHelper class.



Otherwise you will need to use EGL directly to setup
your OpenGL surface without double buffering.
  

I'd like to avoid this, since it basically means implementing my own
GLSurfaceView...



On the other hand i wonder why you don't compose your complete scene in a single
onDrawFrame call.
  

Because the goal is to have an interactive drawing application
controlled by the user input (brushes strokes, etc).



  


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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the words 
REMOVE ME as the subject.


[android-developers] Re: screen flickering in GLSurfaceView

2010-03-18 Thread Mario Zechner
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


Re: [android-developers] Re: screen flickering in GLSurfaceView

2010-03-18 Thread Andres Colubri



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.
  
Thanks for the explanation, this makes the source of the problem 
perfectly clear.



There might be a way to disable double buffering in the GLSurfaceView
if you use that. 
  
That would be nice, I wonder if it is possible to do at all... After a 
quick look at the source code of GLSurfaceView, it seems to me that the 
double buffering is hard coded into the EglHelper class.



Otherwise you will need to use EGL directly to setup
your OpenGL surface without double buffering. 
I'd like to avoid this, since it basically means implementing my own 
GLSurfaceView...



On the other hand i wonder why you don't compose your complete scene in a single
onDrawFrame call.
  
Because the goal is to have an interactive drawing application 
controlled by the user input (brushes strokes, etc).


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


[android-developers] Re: screen flickering in GLSurfaceView

2010-03-18 Thread Mario Zechner
oh, i tried that once with OpenGL ES. I didn't use the backbuffer but
drew directly to a texture using an intermediate Bitmap as the drawing
surface and reuploading only those parts of the texture that changed.
You can find a video and an apk of that at
http://apistudios.com/hosted/marzec/badlogic/wordpress/?cat=10. The
problem is that if you update to much of the texture at once you get
100ms interruptions which might be visible to the user.

On 18 Mrz., 14:46, Andres Colubri andres.colu...@gmail.com wrote:
  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.

 Thanks for the explanation, this makes the source of the problem
 perfectly clear.

  There might be a way to disable double buffering in the GLSurfaceView
  if you use that.

 That would be nice, I wonder if it is possible to do at all... After a
 quick look at the source code of GLSurfaceView, it seems to me that the
 double buffering is hard coded into the EglHelper class.

  Otherwise you will need to use EGL directly to setup
  your OpenGL surface without double buffering.

 I'd like to avoid this, since it basically means implementing my own
 GLSurfaceView...

  On the other hand i wonder why you don't compose your complete scene in a 
  single
  onDrawFrame call.

 Because the goal is to have an interactive drawing application
 controlled by the user input (brushes strokes, etc).

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


Re: [android-developers] Re: screen flickering in GLSurfaceView

2010-03-18 Thread Andres Colubri

ok, I see... thanks for the link.

So I guess that finding a way to disable the double buffering, at least 
temporarily, should be the best way to go then...


Mario Zechner wrote:

oh, i tried that once with OpenGL ES. I didn't use the backbuffer but
drew directly to a texture using an intermediate Bitmap as the drawing
surface and reuploading only those parts of the texture that changed.
You can find a video and an apk of that at
http://apistudios.com/hosted/marzec/badlogic/wordpress/?cat=10. The
problem is that if you update to much of the texture at once you get
100ms interruptions which might be visible to the user.

On 18 Mrz., 14:46, Andres Colubri andres.colu...@gmail.com wrote:
  

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.
  

Thanks for the explanation, this makes the source of the problem
perfectly clear.



There might be a way to disable double buffering in the GLSurfaceView
if you use that.
  

That would be nice, I wonder if it is possible to do at all... After a
quick look at the source code of GLSurfaceView, it seems to me that the
double buffering is hard coded into the EglHelper class.



Otherwise you will need to use EGL directly to setup
your OpenGL surface without double buffering.
  

I'd like to avoid this, since it basically means implementing my own
GLSurfaceView...



On the other hand i wonder why you don't compose your complete scene in a single
onDrawFrame call.
  

Because the goal is to have an interactive drawing application
controlled by the user input (brushes strokes, etc).



  


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


Re: [android-developers] Re: screen flickering in GLSurfaceView

2010-03-18 Thread amsale zelalem
thank you so much for ur precious advice. that is what we were looking for

--- On Thu, 3/18/10, Andres Colubri andres.colu...@gmail.com wrote:

From: Andres Colubri andres.colu...@gmail.com
Subject: Re: [android-developers] Re: screen flickering in GLSurfaceView
To: android-developers@googlegroups.com
Date: Thursday, March 18, 2010, 6:46 AM


 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.
   
Thanks for the explanation, this makes the source of the problem perfectly 
clear.

 There might be a way to disable double buffering in the GLSurfaceView
 if you use that.   
That would be nice, I wonder if it is possible to do at all... After a quick 
look at the source code of GLSurfaceView, it seems to me that the double 
buffering is hard coded into the EglHelper class.

 Otherwise you will need to use EGL directly to setup
 your OpenGL surface without double buffering. 
I'd like to avoid this, since it basically means implementing my own 
GLSurfaceView...

 On the other hand i wonder why you don't compose your complete scene in a 
 single
 onDrawFrame call.
   
Because the goal is to have an interactive drawing application controlled by 
the user input (brushes strokes, etc).

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



  

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