fixed problem

This commit is contained in:
Anakin 2016-11-08 17:06:50 +01:00
parent e5490b9451
commit b4b2538ea6
3 changed files with 7 additions and 8 deletions

View File

@ -28,7 +28,7 @@ struct textureData {
bool alpha; bool alpha;
std::uint32_t width; std::uint32_t width;
std::uint32_t height; std::uint32_t height;
const GLvoid* data; std::vector<std::uint8_t>* data;
}; };
class OpenGLController class OpenGLController

View File

@ -46,6 +46,7 @@ OpenGLController::~OpenGLController()
{ {
textureData* cursor = vTextures.back(); textureData* cursor = vTextures.back();
vTextures.pop_back(); vTextures.pop_back();
delete cursor->data;
delete cursor; delete cursor;
} }
} }
@ -347,8 +348,7 @@ void OpenGLController::loadMsh(const char * path)
tempData->alpha = tempTex.hasAlpha(); tempData->alpha = tempTex.hasAlpha();
tempData->width = tempTex.getWidth(); tempData->width = tempTex.getWidth();
tempData->height = tempTex.getHeight(); tempData->height = tempTex.getHeight();
tempData->data = tempTex.getData().data(); tempData->data = new std::vector<std::uint8_t>(tempTex.getData());
} }
catch (std::invalid_argument e) catch (std::invalid_argument e)
{ {
@ -356,7 +356,7 @@ void OpenGLController::loadMsh(const char * path)
tempData->alpha = true; tempData->alpha = true;
tempData->width = 1; tempData->width = 1;
tempData->height = 1; tempData->height = 1;
tempData->data = (const GLvoid*)solidColor; tempData->data = new std::vector<std::uint8_t>({ 0, 0, 255, 255 });
} }
vTextures.push_back(tempData); vTextures.push_back(tempData);
@ -370,7 +370,7 @@ void OpenGLController::loadMsh(const char * path)
0, 0,
vTextures.front()->alpha ? GL_BGRA : GL_BGR, vTextures.front()->alpha ? GL_BGRA : GL_BGR,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
vTextures.front()->data vTextures.front()->data->data()
); );
// set some texture parameters // 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); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
} }

View File

@ -20,7 +20,8 @@ int main(int argc, char** argv)
else else
scene = OpenGLController::getInstance(); scene = OpenGLController::getInstance();
scene->loadMsh("..\\Release\\Msh\\multiModTex.msh"); //scene->loadMsh("..\\Release\\Msh\\multiModTex.msh");
scene->loadMsh("..\\Release\\Msh\\cubeTex.msh");
do { do {
scene->updateScene(); scene->updateScene();