X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=e16776f8f53f078a2ae53c39b482326a9e8b16cc;hb=0687d51f638169ffe55ad27e71ae99508ef3c38c;hp=61610493df811411cc2a82ef980633754b97f36b;hpb=619aae12e01f25e79626a94c973927e5599e99a5;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 61610493..e16776f8 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -1,13 +1,16 @@ #include #include +#include #include #include #include #include #include +#include #include #include "buffer.h" #include "error.h" +#include "misc.h" #include "program.h" #include "shader.h" @@ -27,8 +30,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 +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,15 +107,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; @@ -127,20 +139,35 @@ 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 used_bind_points; + count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS); for(unsigned i=0; i