X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogramdata.cpp;h=912bc3c88a54c25a8c52199e8552a0d0a2b5eecc;hb=56133280d92c08c1c649a725260a6c4d5afb5e75;hp=3561719725501a4ca7663ad4ae6c3e825e6bd10b;hpb=ed7ca8892daceebb963950945fed5e75bd96a8a1;p=libs%2Fgl.git diff --git a/source/programdata.cpp b/source/programdata.cpp index 35617197..912bc3c8 100644 --- a/source/programdata.cpp +++ b/source/programdata.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #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); @@ -421,6 +428,12 @@ const Uniform &ProgramData::get_uniform(const string &name) const return *uniforms[i].value; } +const Uniform *ProgramData::find_uniform(const string &name) const +{ + int i = find_uniform_index(name); + return (i>=0 ? uniforms[i].value : 0); +} + bool ProgramData::uniform_name_compare(const NamedUniform &nu, const string &name) { return nu.name::const_iterator j=info.uniforms.begin(); (!any_found && j!=info.uniforms.end()); ++j) - any_found = (find_uniform_index((*j)->name)>=0); + bool all_found = true; + for(vector::const_iterator j=info.uniforms.begin(); j!=info.uniforms.end(); ++j) + { + if(find_uniform_index((*j)->name)>=0) + any_found = true; + else + all_found = false; + } - // TODO throw if all uniforms for a buffer-backed block are not found if(!any_found) return 0; + else if(!all_found && info.bind_point>=0) + { +#ifdef DEBUG + IO::print(IO::cerr, "Warning: not all uniforms for block %s are present\n", info.name); +#else + throw incomplete_uniform_block(info.name); +#endif + } UniformBlock *block; if(info.bind_point>=0)