Esempio n. 1
0
void Model::prepareData(const glm::mat4& world_transform) {
    updateUniformData(_rootNode, world_transform);

    _nodeUniformData->updateData(_alignedUniformData.getData(),
                                 0,
                                 _alignedUniformData.getSize(),
                                 UpdateFlags::DiscardOldData);
}
Esempio n. 2
0
void Model::updateUniformData(const ModelNode& node, const glm::mat4& model) {
    auto final_transform = model * node.transform;

    auto data = _alignedUniformData.getElement(node.index);
    data->model_matrix = final_transform;
    data->normal_model_matrix = glm::transpose(glm::inverse(final_transform));

    for (auto& child : node.child_nodes) {
        updateUniformData(*child, final_transform);
    }
}
Esempio n. 3
0
void FlatDrawable::draw(){
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);

    glUseProgram(shader.getGLId());
    mesh->bindVAO();

    transformation = glm::mat3( width , 0     , position.x,
                                0     , height, position.y,
                                0     , 0     , 1           );

    glUniformMatrix3fv(glGetUniformLocation(shader.getGLId(), "transformation"), 1, GL_FALSE, glm::value_ptr(transformation));

    updateUniformData();

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texture.getGLId());

    mesh->draw();
}