X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=3c3a78b7c298a15bb6e55f8b9e75268fd788c4c7;hb=f14435e58bfa0fa697a06ba9a454bb30cd37d9d8;hp=eb9481f2426ae7908f2a875aa9efa07ab7caed3e;hpb=8ac93980ef87834fd431c97104baa441561a7ce0;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index eb9481f2..3c3a78b7 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include "arb_shader_objects.h" #include "arb_vertex_shader.h" @@ -212,24 +205,37 @@ void Program::bind_attribute(unsigned index, const string &name) void Program::link() { for(list::iterator i=shaders.begin(); i!=shaders.end(); ++i) - if(!(*i)->get_compiled()) + if(!(*i)->is_compiled()) (*i)->compile(); + uniforms.clear(); + glLinkProgramARB(id); - if(!(linked = get_param(GL_LINK_STATUS))) + int value; + glGetObjectParameterivARB(id, GL_OBJECT_LINK_STATUS_ARB, &value); + if(!(linked = value)) throw CompileError(get_info_log()); -} -int Program::get_param(GLenum param) const -{ - int value; - glGetObjectParameterivARB(id, param, &value); - return value; + glGetObjectParameterivARB(id, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &value); + for(int i=0; i::const_iterator i = uniforms.find(n); + if(i==uniforms.end()) + return -1; + + return i->second.location; } void Program::unbind()