Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomatic buffer clear while using OpenGL on Android
    primarykey
    data
    text
    <p>I'm writing a certain OpenGL application where I'd specifically like to draw frames incrementally. For this, I'd like to disable automatic clearing of buffer which I understand, is default behavior of GLSurfaceView.Renderer.onDrawFrame(). Can someone please help me on how to do this? I need to write the application in Java, not using native SDK.</p> <p>I understand that I could possibly do this by :-</p> <pre><code>(1) setting EGL_SWAP_BEHAVIOR_PRESERVED_BIT bit for EGL_SURFACE_TYPE attribute while doing [eglChooseConfig][1](), and (2) setting EGL_SWAP_BEHAVIOR attribute to EGL_BUFFER_PRESERVED by calling [eglSurfaceAttrib][2] on the EGLSurface object </code></pre> <p>However, I gather from the Khronos doc that:-</p> <pre><code>"EGL_SWAP_BEHAVIOR_PRESERVED_BIT are supported only if the EGL version is 1.4 or greater." "EGL_SWAP_BEHAVIOR is supported only if the EGL version is 1.2 or greater." </code></pre> <p>Now, I understand that I could access EGL in two ways in my Android application:-</p> <pre><code>(1) use the Khronos API class [EGL10][3] in javax.microedition.khronos.egl package (EGL11 doesn't seem to be implemented yet) (2) use the Android API class [EGL14][4] in android.opengl package (similar to using class android.opengl.GLES20) </code></pre> <p>The problem with (1) is that the version is &lt; 1.4 so it doesn't support the functionality I need. The problem with (2) is that <strong>my application simply crashes the moment I call any method in EGL14, and I'm not sure how I'm supposed to use it (I could not find a single example program / tutorial on how EGL14 is supposed to be used in an app)</strong>. In particular, I'd like to learn how to get a valid GL context from EGL14: in the case of EGL10, I could do that by calling javax.microedition.khronos.egl.EGLContext.getGL(). However, I see no equivalent method in class android.opengl.EGLContext. In fact, all EGL-related classes in android.opengl except EGL14 seem to be mostly empty.</p> <p>My best bet was to follow the same line of reasoning as in case of GLES20: to call the methods only inside the GLSurfaceView.Renderer methods: onDrawFrame(), onSurfaceCreated(), onSurfaceChanged(), because these supply valid GL (GL10) and EGL (EGLConfig) contexts as arguments. So I put following code inside onDrawFrame():-</p> <pre><code>public void onDrawFrame(GL10 gl) { ... android.opengl.EGLDisplay d = null; if ( (d = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY)) == EGL14.EGL_NO_DISPLAY) { Log.i("Triangle", "EGL14.eglGetDisplay() failed!"); } else { Log.i("Triangle", "EGL14.eglGetDisplay() succeeded!"); } ... } </code></pre> <p>I believe I won't have to instantiate EGL14 before calling the above since all methods are static. However, the call to EGL14.eglGetDisplay() crashes the app.</p> <p>Any help would be much appreciated, thanks:)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload