different behavior in Opengl ES android -



different behavior in Opengl ES android -

.renderer performance reasons drawing 1 time background, utilize glscissors draw parts , simplified code :

public class mygame extends glsurfaceview implements renderer { private boolean firsttime; public mygame(context context) { super(context); // todo auto-generated constructor stub firsttime=true; this.setrenderer(this); this.setrendermode(rendermode_continuously); } @override public void onsurfacecreated(gl10 gl, eglconfig config) { // todo auto-generated method stub } @override public void onsurfacechanged(gl10 gl, int width, int height) { // todo auto-generated method stub gl.glmatrixmode(gl10.gl_projection); gl.glviewport(0, 0, width, height); gl.glorthof(0, width, 0, height, 1, -1); //select bluish color gl.glclearcolor(0, 0, 1f, 1); } @override public void ondrawframe(gl10 gl) { // todo auto-generated method stub //only paint bluish color nil if(firsttime) { gl.glclear(gl10.gl_color_buffer_bit); firsttime=false; } else { //other actions .......... } } }

this code works on tablet( android 4) or on emulator , have problems xperia neo (2.3.3) : first frame draw 1 bluish , sec frame draw black, next bluish , next black …..

do need set parameter ? can prepare behavior?

the way create work reliably on possible devices draw finish frame on each redraw. means either need phone call glclear() @ start of each frame, or create sure rendering covers pixels of window.

as suggested in comment above, may have improve success if clear first 2 or 3 frames. relies on scheme using double or triple buffering, not guaranteed @ all. also, not work incremental drawing, since in frame n still miss rendering added in frame n - 1. example, if scheme using simple double buffering, previous content frame n content of frame n - 2.

the egl documentation specifies why result undefined. eglswapbuffers() man page:

the contents of ancillary buffers undefined after calling eglswapbuffers. contents of color buffer left unchanged if value of egl_swap_behavior attribute of surface egl_buffer_preserved, , undefined if value egl_buffer_destroyed. value of egl_swap_behavior can set surfaces using eglsurfaceattrib.

the lastly part of suggests possible solution, comes substantial caveat: not supported on devices. more details aspect in reply here: fast screen flicker while not drawing on android opengl.

in reality, depending on graphics architecture, can faster phone call glclear() @ start of each frame if it's not needed. particularly when rendering fbos, previous content of render target has restored otherwise, , clearing may more efficient restoring previous content. es 3.0 , later have glinvalidateframebuffer() phone call these situations, tells implementation previous content not have restored.

if rendering total frame very expensive in utilize case, , can save lot of time rendering incrementally, portable alternative render offscreen target (fbo), , blit content default framebuffer when redraw needed.

android opengl-es

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -