X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=baeba9f5c33d1091da815f0d14d7f6be45807b3b;hb=1bad86b461abd4fe2a1cb1c6c5685adf5db13935;hp=61610493df811411cc2a82ef980633754b97f36b;hpb=619aae12e01f25e79626a94c973927e5599e99a5;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 61610493..baeba9f5 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" @@ -27,8 +29,7 @@ Program::Program(const ProgramBuilder::StandardFeatures &features) ProgramBuilder builder(features); builder.add_shaders(*this); - if(!features.transform) - link(); + link(); } Program::Program(const string &vert, const string &frag) @@ -87,6 +88,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,15 +106,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; i