I cannot find any tutorial in Google and Youtube. I have a C++ program that uses OpenGL ES 2.0 API to render something on the screen. How can I debug my shaders? Any step-by-step guide? What is the easiest way to at least print variable values?
In general, you can't. The typical development environments only give you visibility on the C/C++ side.
So, I say "you can't" but that's obviously not exactly true. You can't step through the shader and print variables, but still we all develop and debug shaders. But it's a lot of intuiting indirectly what's going on, by repeated runs. Some of the things I do is:
- Have a simplified version of my app that only draws 1 or 2 things, so try/edit/retry goes faster
- Have a few fallback shaders that I know work, and swap them in when I'm doubting my own sanity...
- Use revision control, of course
- Always print out all the error messages from compiling with
In some game engine environments, you author shaders at a higher level, using flow diagrams and such, and the engine generates GLSL (or HLSL &c) on the fly, which is a whole different debug experience.
Hope that helps!