Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static call to glGetString() returns null in Android 5.0

My application needs to check the availability of some OpenGL ES features before starting.

This is done with the following Java code:

String extensions = GLES20.glGetString( GLES20.GL_EXTENSIONS );

And it worked on Android up to version 4.4, but now returns null, and the log says

10-28 17:53:49.475: E/libEGL(8930): call to OpenGL ES API with no current context (logged once per thread)

How do I get this information on Android 5.0? Do I need to create a new OpenGL ES context? And what's the easiest way to do it?

like image 770
G B Avatar asked Sep 07 '25 01:09

G B


1 Answers

First of all, this is probably not an upgrade issue, but a device-specific issue. Maybe (yours truly does not have enough statistical data across the thousands of device models), this kind of behavior of glGetString() is less likely to happen on older models, but such knowledge is not worth to seek, it doesn't help to resolve the problem anyway.

The khronos wiki explains that a live rendering GL context is required for all OpenGL functions to work, but it is not a violation for some of these functions to return non-NULL when called without such context.

You can find examples of initialization code here and here.

Even then, we have encountered some devices that returned NULL for glGetString(GLES20.GL_RENDERER); these have different manufacturers, platform levels, etc. Our Crashlytcis data does not suggest that this behavior is consistent for the same device.

Therefore, we had to employ a fallback so that the app does not crash when this function returns null.

like image 135
Alex Cohn Avatar answered Sep 08 '25 15:09

Alex Cohn