]> git.tdb.fi Git - libs/gl.git/commitdiff
Add some precondition checks to Program
authorMikko Rasa <tdb@tdb.fi>
Tue, 30 Mar 2021 13:40:52 +0000 (16:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 30 Mar 2021 13:40:52 +0000 (16:40 +0300)
Adding stages from multiple modules presents some difficulties in matching
the interfaces.

source/core/program.cpp

index 789fa32473392d75a0bd34a13aac7208ddf14637..c41976ed8eef270a238de46b837e529ad4904dd9 100644 (file)
@@ -80,6 +80,9 @@ Program::~Program()
 
 void Program::add_stages(const Module &mod, const map<string, int> &spec_values)
 {
+       if(!stage_ids.empty())
+               throw invalid_operation("Program::add_stages");
+
        switch(mod.get_format())
        {
        case Module::GLSL: return add_glsl_stages(static_cast<const GlslModule &>(mod), spec_values);
@@ -220,6 +223,9 @@ void Program::bind_fragment_data(unsigned index, const string &name)
 
 void Program::link()
 {
+       if(stage_ids.empty())
+               throw invalid_operation("Program::link");
+
        uniforms.clear();
 
        glLinkProgram(id);