Search code examples
androidopengl-esgoogle-cardboard

Selecting GLES version in Google Cardboard Android SDK


How does the CardboardView class in the Google Cardboard SDK select which OpenGL ES version to use? I was hoping that it literally inherited from GlSurfaceView so that I could use setEGLContextClientVersion as described here, but it looks like that's not the case.

My goal is to select OpenGL ES 3.0 -- much of my existing rendering code is implemented on the native side and depends on that version.


Solution

  • The Cardboard SDK uses an OpenGL ES 2.0 compatible client. Though this doesn't seem to be officially supported, my experience is that GL ES 3.0/3.1 can be used with such a context, provided that the phone actually supports ES 3.x. Which can be checked with this call:

    String version = javax.microedition.khronos.opengles.GL10.glGetString(
        GL10.GL_VERSION);
    

    More detail at http://developer.android.com/guide/topics/graphics/opengl.html#version-check

    That said, it looks like we should add proper support for using ES 3.x with the SDK, thanks for flagging this.