Contraz / demosys-py

A light high performance modern OpenGL 3.3+ Python Framework https://demosys-py.readthedocs.io/
ISC License
64 stars 5 forks source link

Better feedback when shaders do not compile #62

Closed einarf closed 4 years ago

einarf commented 6 years ago

Right now we simply show the default error message from moderngl. We should consider improving this feedback possibly adding some of the actual source in stdout and make the file name clearly visible.

yoyonel commented 6 years ago

Can be very useful in dev mode

yoyonel commented 6 years ago
E       mgl.Error: GLSL Compiler failed
E       
E       vertex_shader
E       =============
E       [error] compiling vertex shader...
E       
E         0001  
E         0002                          #version 330
E         0003  
E         0004                          uniform vec2 pos;
E         0005                          uniform float scale;
E         0006  
E         0007                          in vec2 vert;
E         0008                          out vec2 v_vert;
E         0009                          
E         0010                          toto;
E       
E       error C0000: syntax error, unexpected ';', expecting "::" at token ";"
E       
E         0011  
E         0012                          void main() {
E         0013                              gl_Position = vec4(pos + vert * scale, 0.0, 1.0);
E         0014                              v_vert = vert + ;
E       
E       error C0000: syntax error, unexpected ';', expecting "::" at token ";"
E       
E         0015                          }
E         0016

Begins to look good ;-)

I have to perform more (unit) tests and refactoring/cleaning the source code. I will PR in ModernGL repo and link with this issue.

einarf commented 6 years ago

Awesome! 💯

It totally makes sense doing this in moderngl. From this project we can use the #line directive to make sure the output is sane. Some tweaks are often needed when adding preprocessors and when implementing the #include directive.

https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Preprocessor_directives

einarf commented 4 years ago

moving this to moderngl-window