- char name[128];
- int len;
- glGetActiveUniformBlockName(id, i, sizeof(name), &len, name);
- UniformBlockInfo &info = uniform_blocks[name];
- info.name = name;
-
- int value;
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_DATA_SIZE, &value);
- info.data_size = value;
-
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &value);
- vector<int> indices(value);
- glGetActiveUniformBlockiv(id, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, &indices[0]);
- for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
- {
- if(!uniforms_by_index[*j])
- throw logic_error("Program::link");
- info.uniforms.push_back(uniforms_by_index[*j]);
- uniforms_by_index[*j]->block = &info;
- }
-
- vector<unsigned> indices2(indices.begin(), indices.end());
- vector<int> values(indices.size());
- glGetActiveUniformsiv(id, indices.size(), &indices2[0], GL_UNIFORM_OFFSET, &values[0]);
- for(unsigned j=0; j<indices.size(); ++j)
- uniforms_by_index[indices[j]]->location = values[j];
-
- indices2.clear();
- for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)
- if(uniforms_by_index[*j]->size>1)
- indices2.push_back(*j);
- if(!indices2.empty())
- {
- glGetActiveUniformsiv(id, indices2.size(), &indices2[0], GL_UNIFORM_ARRAY_STRIDE, &values[0]);
- for(unsigned j=0; j<indices2.size(); ++j)
- uniforms_by_index[indices2[j]]->array_stride = values[j];
- }
-
- indices2.clear();
- for(vector<int>::iterator j=indices.begin(); j!=indices.end(); ++j)