I need to debug a GLSL program but I don't know how to output intermediate result.
Is it possible to make some debug traces (like with printf) with GLSL ?
How to debug a GLSL shader
debuggingglslopengl
Related Topic
- Php – How to Debug Variables in Smarty like in PHP var_dump()
- Java – a stack trace, and how can I use it to debug the application errors
- Random / noise functions for GLSL
- Android – Run/install/debug Android applications over Wi-Fi
- C# – Writing to output window of Visual Studio
- Php – Reference – What does this error mean in PHP
Best Answer
You can't easily communicate back to the CPU from within GLSL. Using glslDevil or other tools is your best bet.
A printf would require trying to get back to the CPU from the GPU running the GLSL code. Instead, you can try pushing ahead to the display. Instead of trying to output text, output something visually distinctive to the screen. For example you can paint something a specific color only if you reach the point of your code where you want add a printf. If you need to printf a value you can set the color according to that value.