Problem solved: partial screen updates on Android devices

Hi,

In the past I posted problems here regarding the use of SDL2 on Android tablets, in cases where the screen was not fully redrawn on each frame. In short: some tablets worked as expected, and some (e.g. the Nexus7) turned to black screen and all kinds of weird behaviour as soon as you touched it. I filed bug reports that were never solved satisfactory.

Now I created a new environment built on top of OpenGL and friends, that works for Linux and for Android. At the end it showed the same behaviour when used on Android tablets: some worked, others not. But there was one big difference: I knew what I was doing, because only OpenGL and OpenGL-ES was involved. I found that the following line of code must be inserted after a surface has been created (in my case with eglCreateWindowSurface):

Code:
eglSurfaceAttrib(display,surface,EGL_SWAP_BEHAVIOR,EGL_BUFFER_PRESERVED);

Result: all tablets work flawlessly, also with small local screen updates!

I would be happy to file a bug report mentioning this solution, but I’m not clever enough to know where and how this should be done in the SDL2 code.

As an aside: OpenGL and friends are great, once you understand their unconventional coding model. Actually, building modern GUI components is easier then using SDL2, and probably as portable as well. Writing a complete app for Linux and for Android required only some #ifdef’s plus a small amount of glue code, and no java at all.

Regards,
Wouter

Somebody didn’t read SDL README.android :)================================================================================
A note regarding the use of the “dirty rectangles” rendering technique

If your app uses a variation of the “dirty rectangles” rendering technique,
where you only update a portion of the screen on each frame, you may notice
a
variety of visual glitches on Android, that are not present on other
platforms.
This is caused by SDL’s use of EGL as the support system to handle OpenGL
ES/ES2
contexts, in particular the use of the eglSwapBuffers function. As stated
in the
documentation for the function “The contents of ancillary buffers are
always
undefined after calling eglSwapBuffers”.
Setting the EGL_SWAP_BEHAVIOR attribute of the surface to
EGL_BUFFER_PRESERVED
is not possible for SDL as it requires EGL 1.4, available only on the API
level
17+, so the only workaround available on this platform is to redraw the
entire
screen each frame.

Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html

On Sat, Jun 1, 2013 at 12:01 PM, wboe <w.boeke at upcmail.nl> wrote:

**
Hi,

In the past I posted problems here regarding the use of SDL2 on Android
tablets, in cases where the screen was not fully redrawn on each frame. In
short: some tablets worked as expected, and some (e.g. the Nexus7) turned
to black screen and all kinds of weird behaviour as soon as you touched it.
I filed bug reports that were never solved satisfactory.

Now I created a new environment built on top of OpenGL and friends, that
works for Linux and for Android. At the end it showed the same behaviour
when used on Android tablets: some worked, others not. But there was one
big difference: I knew what I was doing, because only OpenGL and OpenGL-ES
was involved. I found that the following line of code must be inserted
after a surface has been created (in my case with eglCreateWindowSurface):

Code:

eglSurfaceAttrib(display,surface,EGL_SWAP_BEHAVIOR,EGL_BUFFER_PRESERVED);

Result: all tablets work flawlessly, also with small local screen updates!

I would be happy to file a bug report mentioning this solution, but I’m
not clever enough to know where and how this should be done in the SDL2
code.

As an aside: OpenGL and friends are great, once you understand their
unconventional coding model. Actually, building modern GUI components is
easier then using SDL2, and probably as portable as well. Writing a
complete app for Linux and for Android required only some #ifdef’s plus a
small amount of glue code, and no java at all.

Regards,
Wouter


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Somebody didn’t read SDL README.android

You’re right, I confess. And indeed, I’m using api level 17.

If your final screen is hardware accelerated you might as well render the
whole screen all the time.On Sat, Jun 1, 2013 at 12:35 PM, wboe <w.boeke at upcmail.nl> wrote:

**

Quote:

Somebody didn’t read SDL README.android

You’re right, I confess. And indeed, I’m using api level 17.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org