CategoryGLES20

How To Get Android OpenGL 1.0 and 2.0 Information and Constrains – Revisited

Some time ago I’ve made a short post (here) about the basics of how to get opengl infos on an android device. For an app I’m currently working on it was required to get all interesting information once more in my android device information application. The basic idea is to add a respective opengl 1.1 or opengl 2.0 and possibly even opengl 3.0+ context to the active view, load all information in the onSurfaceCreate method of the renderer and remove the view afterwards again.

You’d use it appropriatelly like that in your activity:

Here is what I came up with:

Enjoy. (:

Android: OpenGL 1.0 and 2.0 infos

So here I was again, trying to figure out a way to get opengl infos like max texture size, max uniform vectors, max vertex attributes, etc. for several android devices. Technically you could just use a small getter:

The problem was that on many devices the the returned number would always be 0. That’s because there hasn’t been created an opengl context yet. As suggested on Stackoverflow you could create a GLSurfaceView, add a renderer which could read the required infos by adding the glsurfaceview to the actual main active view and simply remove itself when done. In order to get opengles 1.0 and opengles 2.0 infos you would need to create two surfacesviews with different opengl versions. The following example looks a bit complicated, because I use fragments which i need to update on the main thread after I got all the infos I wanted. A full example is on github.