patriciogonzalezvivo / vera

C++/WASM GL Framework
Other
82 stars 14 forks source link

Bug revert to previous shader not working #7

Closed themoep closed 1 year ago

themoep commented 1 year ago

This fixes issue #6

By adding m_previous{Fragment,Vertex}ShaderSource that is only set if both compile successfully, we have access to the last working shader. We only store this when error handling is set to anything but DONT_KEEP_SHADER. This allows setting m_{fragment,vertex}ShaderSource through setSource(), independently of load(), as it is used in glslViewer. If load is called directly, the passed sources are used, keeping the intended behaviour of all functions.

The previous pull request messed up the order of storing the shader sources and accidentally stored a non-working shader. (around line 123 in latest pull request file)

Tested with latest glslViewer (-e 'error_screen,off'). Introducing an error in the shader keeps the last working configuration. Drag+dropping an incorrect shader also keeps the last working shader. In both cases fixing the error and updateing the file (or dropping the fixed shader) correctly updates the shaders shown.