diff --git a/MeshViewerQt/Source/OpenGlViewer.cpp b/MeshViewerQt/Source/OpenGlViewer.cpp index 96fb28a8c224c836624adbda86e96730f0b88394..2a5202c51bf6598dfbaeec770f16a3226dcc2632 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 8e6ee6cb6d5cd500065f4454ad0b2fbfa5098378..d412abb3153f63944c64b5e727695a98aa1b3841 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);