.... GLuint index1 = glGetUniformBlockIndex(shader.getProgramID(), "test_unif1"); GLuint index2 = glGetUniformBlockIndex(shader.getProgramID(), "test_unif2"); .... glGetActiveUniformBlockiv(shader.getProgramID(), index1, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, (GLint*)&inds1[0]); glGetActiveUniformsiv(shader.getProgramID(),unifLen,inds1,GL_UNIFORM_OFFSET,offsets1); glGetActiveUniformBlockiv(shader.getProgramID(), index1,GL_UNIFORM_BLOCK_DATA_SIZE, &size1); glGetActiveUniformBlockiv(shader.getProgramID(), index2, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, (GLint*)&inds2[0]); glGetActiveUniformsiv(shader.getProgramID(),unifLen,inds2,GL_UNIFORM_OFFSET,offsets2); glGetActiveUniformBlockiv(shader.getProgramID(), index2,GL_UNIFORM_BLOCK_DATA_SIZE, &size2); glGenBuffers( 2, &ubo[0] ); glBindBuffer( GL_UNIFORM_BUFFER, ubo[0] ); glBufferData( GL_UNIFORM_BUFFER, size1, NULL, GL_STATIC_DRAW ); void* buffer = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY); .... glUnmapBuffer(GL_UNIFORM_BUFFER); glBindBuffer( GL_UNIFORM_BUFFER, ubo[1] ); glBufferData( GL_UNIFORM_BUFFER, size2, NULL, GL_STATIC_DRAW ); buffer = glMapBuffer(GL_UNIFORM_BUFFER, GL_WRITE_ONLY); .... glUnmapBuffer(GL_UNIFORM_BUFFER); glUniformBlockBinding(shader.getProgramID(), index1, 0); glUniformBlockBinding(shader.getProgramID(), index2, 1); glBindBufferBase(GL_UNIFORM_BUFFER, 0, ubo[0]); glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo[1]);