Only check for OpenGL errors in debug builds.

Might speed up rendering a bit.
Merge branch 'bugfixes' into 3.1