TomGrill Games
TomGrill Games

Reputation: 1593

How do I know if GL_OES_standard_derivatives is supported by the device?

I would like to use a GLSL ES shader which requires

#if GL_OES_standard_derivatives
#   extension GL_OES_standard_derivatives : enable
#endif

within my libgdx (Android/iOS) app. How can I determine whether a device supports this or not?

Upvotes: 1

Views: 1049

Answers (1)

goobliata
goobliata

Reputation: 340

OpenGL ES has glGetString(GL_EXTENSIONS) which returns a space separated list. If you can access Java on Android, you can use the static method of the GLES10 class like this:

bool is_supported()
{
    return GLES10.glGetString(GLES10.GL_EXTENSIONS).contains("GL_OES_standard_derivatives");
}

If you're using GLES 2.0 or higher, use GLES20 instead.

On iOS if you have access to C, you could do:

bool is_supported()
{
    return strstr(glGetString(GL_EXTENSIONS), "GL_OES_standard_derivatives") != NULL;
}

Upvotes: 3

Related Questions