cginternals / globjects

C++ library strictly wrapping OpenGL objects.
https://globjects.org
MIT License
538 stars 59 forks source link

Some methods return 0 to indicate errors, this should be catched #317

Closed karyon closed 5 years ago

karyon commented 7 years ago

This is probably more a feature request but nonetheless:

glCreateShader (and glCreateProgram and possibly others) return 0 to indicate errors.

if would be nice if globjects would check for that and generate an exception.

or actually, would that be glbinding's job?

scheibel commented 7 years ago

I think such error handling would be the job of globjects. And you're right, if no OpenGL object can be created in either driver or graphics card, all the following operations become nonsense. As globjects itself can't recover from such an issue, throwing exceptions may be reasonable.

scheibel commented 7 years ago

We actually had this problem a couple of days ago and I think it was because the OpenGL driver couldn't allocate any more memory. Nasty issue that would have been directly visible with actual error messages or even exceptions.

karyon commented 7 years ago

fwiw, in my case i called those methods in the wrong thread where no opengl context was active. probably not the rarest of mistakes as well.

scheibel commented 7 years ago

For this case we had another feature that detects when globjects desyncy with the current OpenGL context but I disabled it as it bloated our log files without being an actual issue. I'm still not sure if the driver didn't like such big amounts of current context calls or if there were actual errors in our context handling code...