floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.55k stars 469 forks source link

GL Shader compilation error not shown if OpenGL doesn't provide an error log #927

Open TLAliceDev opened 8 months ago

TLAliceDev commented 8 months ago

I'm trying out sokol for the first time. While trying to create my pipeline, I was getting a shader missing or invalid error, despite having the shader field in the desc filled properly with a shader created through sokol-shdc. Since that error was only reporting about pipeline creation it took me quite a while to figure out where the problem was. After some debugging I eventually found that it was during shader compilation, and that the reason I was not receiving any errors about it was because the opengl shader information log was empty, meaning that _SG_ERROR(GL_SHADER_COMPILATION_FAILED) never got called. After finding that out, I pretty quickly realised that i had simply forgotten to give my SDL window the opengl flag. A pretty simple error that took me close to 2 days to work out due to the lack of error messages. The fact that _SG_ERROR(GL_SHADER_COMPILATION_FAILED) is only called in the if (log_len > 0) block feels like an oversight and I believe it would be helpful to other people who might come across similar situations if the error was brought up to just above that block.