X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fprogram.cpp;h=c8ce67a8897fc6fd5499b251e4a7713b71ff496e;hb=27fe0982fc18d1f5f9efe942e18c42f508268f34;hp=1735d5fa6e328afd2f3141f7783b3544d74bb083;hpb=5c883e77411a7eccc58d345b7d53d8709ae39452;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 1735d5fa..c8ce67a8 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -2,12 +2,13 @@ #include #include #include +#include +#include +#include #include -#include "arb_shader_objects.h" -#include "arb_uniform_buffer_object.h" -#include "arb_vertex_shader.h" #include "buffer.h" #include "error.h" +#include "misc.h" #include "program.h" #include "shader.h" @@ -94,15 +95,14 @@ void Program::link() (*i)->compile(); uniforms.clear(); + legacy_vars = false; glLinkProgram(id); - int value; - glGetProgramiv(id, GL_LINK_STATUS, &value); - if(!(linked = value)) + linked = get_program_i(id, GL_LINK_STATUS); + if(!linked) throw compile_error(get_info_log()); - glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &value); - unsigned count = value; + unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS); vector uniforms_by_index(count); for(unsigned i=0; i3 && !strcmp(name+len-3, "[0]")) + name[len-3] = 0; + UniformInfo &info = uniforms[name]; info.block = 0; info.name = name; @@ -122,20 +127,34 @@ void Program::link() info.type = type; uniforms_by_index[i] = &info; } + else + legacy_vars = true; + } + + count = get_program_i(id, GL_ACTIVE_ATTRIBUTES); + for(unsigned i=0; i blockless_uniforms; for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i) - { if(!i->second.block) { i->second.location = glGetUniformLocation(id, i->second.name.c_str()); blockless_uniforms.push_back(&i->second); } - /* Some implementations report the first element of a uniform array, - others report just the name of an array. */ - if(i->second.name.size()>3 && !i->second.name.compare(i->second.name.size()-3, 3, "[0]")) - i->second.name.erase(i->second.name.size()-3, 3); - } - uniform_layout_hash = compute_layout_hash(blockless_uniforms); } @@ -223,8 +235,7 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf string Program::get_info_log() const { - GLsizei len = 0; - glGetProgramiv(id, GL_INFO_LOG_LENGTH, &len); + GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH); char *buf = new char[len+1]; glGetProgramInfoLog(id, len+1, &len, buf); string log(buf, len);