Skip to content

Instantly share code, notes, and snippets.

View Vassalware's full-sized avatar
🕹️
Creating game development libraries and tools.

Vassalware Vassalware

🕹️
Creating game development libraries and tools.
  • Boston
View GitHub Profile

Guide to using OpenGL's GL.DebugMessageCallback()

When learning OpenGL, one of the most common sources of bugs you'll encounter is from performing OpenGL API calls with invalid arguments, performing them in the wrong order, or performing calls that assume some OpenGL state that differs from the actual state.

With most well-written C# APIs, you'd get an exception thrown the moment you do something you shouldn't. By default, this doesn't happen with OpenGL, but there are still ways to tell if there are errors:

The easy (but tedious) way

The common way to check for errors is to use GL.GetError() to check for errors, often with a helper method such as the following:

Keybase proof

I hereby claim:

  • I am vassalware on github.
  • I am vassalware (https://keybase.io/vassalware) on keybase.
  • I have a public key whose fingerprint is CB55 FDD6 73E0 4643 826E 5F90 F948 8217 6495 1079

To claim this, I am signing this object: