if(len && strncmp(name, "gl_", 3))
{
UniformInfo &info = uniforms[name];
+ info.block = 0;
info.name = name;
info.size = size;
info.type = type;
}
}
- vector<const UniformInfo *> blockless_uniforms;
-
if(is_supported("GL_ARB_uniform_buffer_object"))
{
glGetObjectParameterivARB(id, GL_ACTIVE_UNIFORM_BLOCKS, &value);
count = value;
- vector<bool> uniforms_in_blocks(uniforms_by_index.size());
for(unsigned i=0; i<count; ++i)
{
char name[128];
if(!uniforms_by_index[*j])
throw logic_error("Program::link");
info.uniforms.push_back(uniforms_by_index[*j]);
- uniforms_in_blocks[*j] = true;
+ uniforms_by_index[*j]->block = &info;
}
vector<unsigned> indices2(indices.begin(), indices.end());
info.bind_point = info.layout_hash%BufferRange::get_n_uniform_buffer_bindings();
glUniformBlockBinding(id, i, info.bind_point);
}
-
- for(unsigned i=0; i<uniforms_by_index.size(); ++i)
- if(uniforms_by_index[i] && !uniforms_in_blocks[i])
- {
- UniformInfo *info = uniforms_by_index[i];
- info->location = glGetUniformLocationARB(id, info->name.c_str());
- blockless_uniforms.push_back(info);
- }
}
- else
- {
- for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
+
+ vector<const UniformInfo *> blockless_uniforms;
+ for(UniformMap::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
+ if(!i->second.block)
{
i->second.location = glGetUniformLocationARB(id, i->second.name.c_str());
blockless_uniforms.push_back(&i->second);
}
- }
uniform_layout_hash = compute_layout_hash(blockless_uniforms);
}