X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=66ca36b1c5210a3ec0e0e29ff1b61a0336bcbe9e;hb=a1eb8711ba225bb4423868c50369ad5592465171;hp=95102fe9b8367205ec70976f3f77b9b1811d3ea5;hpb=0778636782c7c42564bfea87d56fc76c583a888e;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index 95102fe9..66ca36b1 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -2,12 +2,14 @@ #include #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" @@ -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; i3 && !strcmp(name+len-3, "[0]")) name[len-3] = 0; @@ -127,20 +138,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