How to Check the Availability of an OpenGL Extension

It may be useful to know if the current OpenGL implementation supports a particular OpenGL extension. For example you have coded a cool OpenGL 4.0 demo based on tessellation shaders. It would be nice to display a different scene (actually an error scene) if the demo runs on a system that is limited to OpenGL 3.0.

To check the presence of an extension, just use the check_opengl_extension of the gh_renderer lib (Lua / Python). This function returns 1 if the extension is exposed and 0 otherwise.

local ret = gh_renderer.check_opengl_extension("GL_ARB_tessellation_shader")
if (ret == 1) then
  -- the extension is supported
  -- the extension is NOT supported

Leave a Comment

Your email address will not be published. Required fields are marked *