How to Check OpenGL Errors

I didn’t checked all possible use cases of GLSL Hacker (a huge and actually impossible task) and some sequences of drawing instructions (render calls) can generate OpenGL errors. So if you suspect something dodgy because the rendering is not what you expect, you can check the OpenGL errors after some particular instructions.

Here is a code snippet in Lua to log OpenGL errors:

function LogGLError(where)
  local errcode = gh_renderer.get_opengl_error()
  local errcodestr = gh_renderer.opengl_error_code_to_str(errcode)
  print(where .. " - " .. errcodestr)
end  

get_opengl_error() returns the real OpenGL error code (ex: 1282) and opengl_error_code_to_str() translates this code into a string: “GL_INVALID_OPERATION”.

GLSL Hacker offers another way to log errors, this time with a minimal amount of code. Just enable the gl_debug_profile attribute in the XML window node
and all OpenGL events will reported in GLSL Hacker log file. This feature is based on GL_ARB_debug_output introduced with OpenGL 4.3.


And if you find some code sequences that generate OpenGL errors, post them in the forum, I’ll try to fix them.





Leave a Comment

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