From: Mikko Rasa Date: Tue, 30 Mar 2021 13:40:52 +0000 (+0300) Subject: Add some precondition checks to Program X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=fc5a3640bd7a007c2da025308e6d6a33402eb098;ds=sidebyside Add some precondition checks to Program Adding stages from multiple modules presents some difficulties in matching the interfaces. --- diff --git a/source/core/program.cpp b/source/core/program.cpp index 789fa324..c41976ed 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -80,6 +80,9 @@ Program::~Program() void Program::add_stages(const Module &mod, const map &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(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);