Запись идентификатора в uniform-буфер
This commit is contained in:
@@ -205,7 +205,9 @@ Model::Model(Node *parent) : Node(parent), verteces_count(0), first_index_byteOf
|
||||
vertex_vbo(VERTEX), index_vbo(ELEMENT), normals_vbo(VERTEX), texCoords_vbo(VERTEX),
|
||||
tangent_vbo(VERTEX), bitangent_vbo(VERTEX)
|
||||
{
|
||||
|
||||
// Приведение указателя к целому 8байт
|
||||
id.value = (GLuint64) this;
|
||||
id.etc = 0;
|
||||
}
|
||||
|
||||
// Конструктор копирования
|
||||
@@ -218,7 +220,9 @@ texture_diffuse(copy.texture_diffuse), texture_ambient(copy.texture_ambient), te
|
||||
texture_heights(copy.texture_heights), texture_normals(copy.texture_normals),
|
||||
material(copy.material)
|
||||
{
|
||||
|
||||
// Приведение указателя к целому 8байт
|
||||
id.value = (GLuint64) this;
|
||||
id.etc = copy.id.etc;
|
||||
}
|
||||
|
||||
// Оператор присваивания
|
||||
@@ -274,6 +278,9 @@ void Model::render()
|
||||
// Вызов отрисовки
|
||||
void Model::render(ShaderProgram &shaderProgram, UBO &material_buffer)
|
||||
{
|
||||
// Загрузка идентификатора объекта
|
||||
glUniform3uiv(shaderProgram.getUniformLoc("ID"), 1, (GLuint*) &id);
|
||||
|
||||
// Расчитаем матрицу трансформации
|
||||
glUniformMatrix4fv(shaderProgram.getUniformLoc("model"), 1, GL_FALSE, &this->getTransformMatrix()[0][0]);
|
||||
|
||||
|
||||
@@ -236,3 +236,14 @@ Scene loadOBJtoScene(const char* filename, const char* mtl_directory, const char
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Изменение флага записи идентификатора для всех моделей
|
||||
void Scene::set_group_id(GLuint64 id, GLuint etc)
|
||||
{
|
||||
for (auto& model : models)
|
||||
{
|
||||
model.id.value = id;
|
||||
if (etc)
|
||||
model.id.etc = etc;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user