fixed the problem,

next solve texture name is taken only from the first element,
move some code around
This commit is contained in:
Anakin 2016-11-08 21:28:24 +01:00
parent b4b2538ea6
commit 2f83d37e12
2 changed files with 23 additions and 21 deletions

View File

@ -119,6 +119,12 @@ void OpenGLController::processInit()
// generate texture
glGenTextures(1, &gluiTextureID);
glBindTexture(GL_TEXTURE_2D, gluiTextureID);
// set some texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
}
void OpenGLController::startGLFW()
@ -266,6 +272,21 @@ void OpenGLController::updateScene()
for (int modelIndex = 0; modelIndex < vModels.size(); modelIndex++)
{
// give texture to the shader
glTexImage2D(GL_TEXTURE_2D,
0,
vTextures[modelIndex]->alpha ? GL_RGBA : GL_RGB,
vTextures[modelIndex]->width,
vTextures[modelIndex]->height,
0,
vTextures[modelIndex]->alpha ? GL_BGRA : GL_BGR,
GL_UNSIGNED_BYTE,
vTextures[modelIndex]->data->data()
);
glGenerateMipmap(GL_TEXTURE_2D);
// give the MVP to the shader
glUniformMatrix4fv(gluiMatrixID, 1, GL_FALSE, &getMVPMatrix(modelIndex)[0][0]);
glDrawArrays(GL_TRIANGLES, instanceOffset, vModels[modelIndex]->meshSize);
@ -361,23 +382,4 @@ void OpenGLController::loadMsh(const char * path)
vTextures.push_back(tempData);
}
glTexImage2D(GL_TEXTURE_2D,
0,
vTextures.front()->alpha ? GL_RGBA : GL_RGB,
vTextures.front()->width,
vTextures.front()->height,
0,
vTextures.front()->alpha ? GL_BGRA : GL_BGR,
GL_UNSIGNED_BYTE,
vTextures.front()->data->data()
);
// set some texture parameters
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D);
}

View File

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