Also look up GL_ARB_debug_output - https://www.opengl.org/registry/specs/ARB/debug_output.txt. I don't remember this ever telling me anything terribly useful for debugging, but I did get a couple of perf hints from it... anyway, it's vendor-specific, so on OS X, maybe it will help.
(BTW - if you ever end up using Direct3D on Windows, be sure to activate the debug runtime. Compare and contrast.)
Apparently Apple is unaware of this technique...
There are exceptions to this general rule, and sometimes you do need to use glGetError in the normal run of things, and take action based on the result. But they are very much exceptions.
#define GLSL(str) (char*)"#version 330\n" #str
It basically enables you to embed quick snippets of GLSL inside your C code, instead of using concatenated strings. Example: char* fragShader = GLSL(
in vec3 uv;
out vec4 color;
uniform sampler2DArray tex;
void main()
{
// Comments work too
color = texture(tex, uv);
}
);
In Sublime Text you even get code completion and color highlighting, since GLSL and C look so alike.I believe it might work for OpenCL Kernels too.
The only downside is that it doesn't add line breaks by itself (hence the "#version 330\n", which requires a line break), so GLSL Compilation errors aren't as useful.
(Source: https://open.gl/geometry )