Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Right way to check for errors

  1. #1
    Intern Contributor
    Join Date
    Oct 2011

    Right way to check for errors

    How should I check for errors? In release mode I cant check them with while(...)glGetError after every single gl call. I can write macros that will only check in debug mode but some important calls like glCompileShader are still need to be checked in release mode too. it will be a mess.

    Should I check only once per frame?
    What about GL_ARB_debug_output? I couldnt find much information about it?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012

    This does work but traps to a callback so it can be hard to continue running the program so the user can exit gracefully.

    I have a series of macros for error checking so I can selectively remove error checks; this way I leave critical ones in the production version but have a lot more in debug mode. I would certainly recommend more than just 1 per frame.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    For debugging use, might use ARB_debug_output. This gives you a nice callback for every error,warning,info,etc. (you control what level) so you can break inside of an error as its happening, look at/dump the stack trace, and inspect in a debugger what your program has done wrong.

    For those few times you'd like to check for an error in release mode, just use glGetError. That said, glCompileShader is not one of those times. You get success and failure of the compile through a different route: glGetShaderiv( shader, GL_COMPILE_STATUS, &result ). You can of course query the log as well. And this is all independent of the OpenGL error handling mechanism which is for coding errors/problems (as opposed to shader compilation/linking problems).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts