X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=66ca36b1c5210a3ec0e0e29ff1b61a0336bcbe9e;hb=a1eb8711ba225bb4423868c50369ad5592465171;hp=ffdd3b6380e03180a6e3790ea730d57fcd6d8832;hpb=798703e937da6b4bbbc4a33f6670ca6fa61e47c3;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index ffdd3b63..66ca36b1 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) @@ -97,15 +109,13 @@ void Program::link() 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; i3 && !strcmp(name+len-3, "[0]")) name[len-3] = 0; @@ -132,8 +142,8 @@ void Program::link() legacy_vars = true; } - glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, &count); - for(int i=0; i