X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fprogram.cpp;h=50ebed22899d57fae6d21518fdce048084b7062b;hb=47af19a447e6c13257ca2d0aef606ea45f8a0d98;hp=111cf64b1d31886e3d33cf831d89c01642a18a6e;hpb=ee377487a2853046085e91fa41c62ea42066d168;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 111cf64b..50ebed22 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -5,9 +5,11 @@ #include #include #include +#include #include #include "buffer.h" #include "error.h" +#include "misc.h" #include "program.h" #include "shader.h" @@ -87,6 +89,17 @@ void Program::bind_attribute(unsigned index, const string &name) glBindAttribLocation(id, index, name.c_str()); } +void Program::bind_attribute(VertexComponent comp, const string &name) +{ + bind_attribute(get_component_type(comp), name); +} + +void Program::bind_fragment_data(unsigned index, const string &name) +{ + static Require _req(EXT_gpu_shader4); + glBindFragDataLocation(id, index, name.c_str()); +} + void Program::link() { for(ShaderList::iterator i=shaders.begin(); i!=shaders.end(); ++i) @@ -94,17 +107,16 @@ 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()); - int count; - glGetProgramiv(id, GL_ACTIVE_UNIFORMS, &count); + unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS); vector uniforms_by_index(count); - for(int i=0; i