X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fprogram.cpp;h=e65a703f77a8d1f5f4b2d769e7c85ca0d439b2bd;hb=a40fc85277dba5c34402a0e703d038efd30cc57b;hp=c3625f4159589916f0e83e7c9f88135266e91b49;hpb=edc2ea855300df08d9f68f2e67316385b003dba6;p=libs%2Fgl.git diff --git a/source/program.cpp b/source/program.cpp index c3625f41..e65a703f 100644 --- a/source/program.cpp +++ b/source/program.cpp @@ -129,7 +129,6 @@ void Program::link() (*i)->compile(); uniforms.clear(); - legacy_vars = false; glLinkProgram(id); linked = get_program_i(id, GL_LINK_STATUS); @@ -173,8 +172,6 @@ void Program::query_uniforms() info.type = type; uniforms_by_index[i] = &info; } - else - legacy_vars = true; } if(ARB_uniform_buffer_object) @@ -283,8 +280,17 @@ void Program::query_attributes() int size; GLenum type; glGetActiveAttrib(id, i, sizeof(name), &len, &size, &type, name); - if(len && !strncmp(name, "gl_", 3)) - legacy_vars = true; + if(len && strncmp(name, "gl_", 3)) + { + if(len>3 && !strcmp(name+len-3, "[0]")) + name[len-3] = 0; + + AttributeInfo &info = attributes[name]; + info.name = name; + info.location = glGetAttribLocation(id, name); + info.size = size; + info.type = type; + } } } @@ -333,6 +339,20 @@ int Program::get_uniform_location(const string &n) const return i->second.block->bind_point<0 ? i->second.location : -1; } +const Program::AttributeInfo &Program::get_attribute_info(const string &name) const +{ + return get_item(attributes, name); +} + +int Program::get_attribute_location(const string &n) const +{ + if(n[n.size()-1]==']') + throw invalid_argument("Program::get_attribute_location"); + + AttributeMap::const_iterator i = attributes.find(n); + return i!=attributes.end() ? i->second.location : -1; +} + void Program::bind() const { if(!linked)