From b4b2538ea6d35938e7c5fbd0a353c8b5ad2abe0f Mon Sep 17 00:00:00 2001 From: Anakin Date: Tue, 8 Nov 2016 17:06:50 +0100 Subject: [PATCH] fixed problem --- MshViewer/Header/OpenGLController.h | 2 +- MshViewer/Source/OpenGlController.cpp | 10 ++++------ MshViewer/main.cpp | 3 ++- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/MshViewer/Header/OpenGLController.h b/MshViewer/Header/OpenGLController.h index da09ec3..d5c9c3d 100644 --- a/MshViewer/Header/OpenGLController.h +++ b/MshViewer/Header/OpenGLController.h @@ -28,7 +28,7 @@ struct textureData { bool alpha; std::uint32_t width; std::uint32_t height; - const GLvoid* data; + std::vector* data; }; class OpenGLController diff --git a/MshViewer/Source/OpenGlController.cpp b/MshViewer/Source/OpenGlController.cpp index 04e2218..afe0b2f 100644 --- a/MshViewer/Source/OpenGlController.cpp +++ b/MshViewer/Source/OpenGlController.cpp @@ -46,6 +46,7 @@ OpenGLController::~OpenGLController() { textureData* cursor = vTextures.back(); vTextures.pop_back(); + delete cursor->data; delete cursor; } } @@ -347,8 +348,7 @@ void OpenGLController::loadMsh(const char * path) tempData->alpha = tempTex.hasAlpha(); tempData->width = tempTex.getWidth(); tempData->height = tempTex.getHeight(); - tempData->data = tempTex.getData().data(); - + tempData->data = new std::vector(tempTex.getData()); } catch (std::invalid_argument e) { @@ -356,7 +356,7 @@ void OpenGLController::loadMsh(const char * path) tempData->alpha = true; tempData->width = 1; tempData->height = 1; - tempData->data = (const GLvoid*)solidColor; + tempData->data = new std::vector({ 0, 0, 255, 255 }); } vTextures.push_back(tempData); @@ -370,7 +370,7 @@ void OpenGLController::loadMsh(const char * path) 0, vTextures.front()->alpha ? GL_BGRA : GL_BGR, GL_UNSIGNED_BYTE, - vTextures.front()->data + vTextures.front()->data->data() ); // set some texture parameters @@ -380,6 +380,4 @@ void OpenGLController::loadMsh(const char * path) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glGenerateMipmap(GL_TEXTURE_2D); - - } diff --git a/MshViewer/main.cpp b/MshViewer/main.cpp index 6062a71..2f52e99 100644 --- a/MshViewer/main.cpp +++ b/MshViewer/main.cpp @@ -20,7 +20,8 @@ int main(int argc, char** argv) else scene = OpenGLController::getInstance(); - scene->loadMsh("..\\Release\\Msh\\multiModTex.msh"); + //scene->loadMsh("..\\Release\\Msh\\multiModTex.msh"); + scene->loadMsh("..\\Release\\Msh\\cubeTex.msh"); do { scene->updateScene();