]> git.tdb.fi Git - libs/gl.git/commitdiff
Make setting a nonexistent uniform only a warning in debug builds
authorMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:19:11 +0000 (17:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:35:09 +0000 (17:35 +0300)
During development it's sometimes necessary to disable parts of a shader,
which causes variables to disappear.

source/programdata.cpp

index 68820c59cc9fd0fd829792ebf547190d23c0fe9f..f454fe5145f595ed1cd6c62488c5b433aaba9a83 100644 (file)
@@ -1,5 +1,7 @@
 #include <msp/core/maputils.h>
+#include <msp/debug/demangle.h>
 #include <msp/gl/extensions/arb_direct_state_access.h>
+#include <msp/io/print.h>
 #include "buffer.h"
 #include "color.h"
 #include "error.h"
@@ -92,10 +94,15 @@ void ProgramData::uniform(const string &name, Uniform *uni)
                else if(name[name.size()-1]==']')
                        throw invalid_argument("ProgramData::uniform");
        }
-       catch(...)
+       catch(const exception &e)
        {
                delete uni;
+#ifdef DEBUG
+               IO::print(IO::cerr, "Error while setting uniform %s: %s: %s\n", name, Debug::demangle(typeid(e).name()), e.what());
+               return;
+#else
                throw;
+#endif
        }
 
        int i = find_uniform_index(name);