From 96379a9afbdff95499f16f171991ce87ab53e374 Mon Sep 17 00:00:00 2001 From: Anakin Date: Tue, 13 Dec 2016 19:07:36 +0100 Subject: [PATCH] fixed texture error --- MeshViewerQt/Source/OpenGlViewer.cpp | 11 ++++++++++- MeshViewerQt/main.cpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/MeshViewerQt/Source/OpenGlViewer.cpp b/MeshViewerQt/Source/OpenGlViewer.cpp index 96fb28a..2a5202c 100644 --- a/MeshViewerQt/Source/OpenGlViewer.cpp +++ b/MeshViewerQt/Source/OpenGlViewer.cpp @@ -132,7 +132,16 @@ void OpenGlViewer::paintGL() { // set the texture std::uint32_t tmp_textureIndex = segmentIterator->textureIndex >= m_vTextures->size() ? m_vTextures->size() - 1 : segmentIterator->textureIndex; - m_oglTexture->setData(*m_vTextures->at(tmp_textureIndex)); + + if (m_oglTexture->isCreated()) + { + m_oglTexture->destroy(); + m_oglTexture->create(); + m_oglTexture->setSize(m_vTextures->at(tmp_textureIndex)->width(), m_vTextures->at(tmp_textureIndex)->height()); + m_oglTexture->setData(*m_vTextures->at(tmp_textureIndex)); + } + + // give the MVP to the shader m_program->setUniformValue(m_uniformMVP, getMVPMatrix(modelIndex)); diff --git a/MeshViewerQt/main.cpp b/MeshViewerQt/main.cpp index 8e6ee6c..d412abb 100644 --- a/MeshViewerQt/main.cpp +++ b/MeshViewerQt/main.cpp @@ -1,6 +1,7 @@ #include "Header\MainWindow.h" #include + int startGUI(int argc, char* argv[]) { QApplication a(argc, argv);