diff --git a/src/files/ResourceLoader.cpp b/src/files/ResourceLoader.cpp index 9e320841..1650b416 100644 --- a/src/files/ResourceLoader.cpp +++ b/src/files/ResourceLoader.cpp @@ -186,15 +186,15 @@ GLMaterial* ResourceLoader::AddMaterial(const vector& textureFiles, cons wxString fileExt = fileName.GetExt().Lower(); string fileExtStr = string(fileExt.c_str()); - // Cubemap - if (!textureID && i == 4) - textureID = SOIL_load_OGL_single_cubemap(textureFiles[i].c_str(), SOIL_DDS_CUBEMAP_FACE_ORDER, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS); - - // Normal texture (GLI) + // All textures (GLI) if (!textureID && fileExtStr == "dds" || fileExtStr == "ktx") textureID = GLI_load_texture(textureFiles[i]); - // Normal texture and image (SOIL fallback) + // Cubemap fallback (SOIL) + if (!textureID && i == 4) + textureID = SOIL_load_OGL_single_cubemap(textureFiles[i].c_str(), SOIL_DDS_CUBEMAP_FACE_ORDER, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS | SOIL_FLAG_GL_MIPMAPS); + + // Texture and image fallback (SOIL) if (!textureID) textureID = SOIL_load_OGL_texture(textureFiles[i].c_str(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS | SOIL_FLAG_GL_MIPMAPS); @@ -225,15 +225,15 @@ GLMaterial* ResourceLoader::AddMaterial(const vector& textureFiles, cons if (!data.IsEmpty()) { byte* texBuffer = static_cast(data.GetData()); - // Cubemap - if (!textureID && i == 4) - textureID = SOIL_load_OGL_single_cubemap_from_memory(texBuffer, data.GetDataLen(), SOIL_DDS_CUBEMAP_FACE_ORDER, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS); - - // Normal texture (GLI) + // All textures (GLI) if (!textureID && fileExtStr == "dds" || fileExtStr == "ktx") textureID = GLI_load_texture_from_memory((char*)texBuffer, data.GetDataLen()); - // Normal texture and image (SOIL fallback) + // Cubemap fallback (SOIL) + if (!textureID && i == 4) + textureID = SOIL_load_OGL_single_cubemap_from_memory(texBuffer, data.GetDataLen(), SOIL_DDS_CUBEMAP_FACE_ORDER, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS | SOIL_FLAG_GL_MIPMAPS); + + // Texture and image fallback (SOIL) if (!textureID) textureID = SOIL_load_OGL_texture_from_memory(texBuffer, data.GetDataLen(), SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_TEXTURE_REPEATS | SOIL_FLAG_MIPMAPS | SOIL_FLAG_GL_MIPMAPS); } diff --git a/src/render/GLShader.cpp b/src/render/GLShader.cpp index 0cf81f83..bed7bd8c 100644 --- a/src/render/GLShader.cpp +++ b/src/render/GLShader.cpp @@ -315,8 +315,6 @@ void GLShader::BindTexture(const GLint& index, const GLuint& texture, const stri glUniform1i(texLoc, index); glActiveTexture(GL_TEXTURE0 + index); - glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glBindTexture(GL_TEXTURE_2D, texture); } } @@ -327,10 +325,8 @@ void GLShader::BindCubemap(const GLint& index, const GLuint& texture, const stri glUniform1i(texLoc, index); glActiveTexture(GL_TEXTURE0 + index); - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBindTexture(GL_TEXTURE_CUBE_MAP, texture); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } } diff --git a/src/render/GLSurface.cpp b/src/render/GLSurface.cpp index 0bd21e7f..000b64e0 100644 --- a/src/render/GLSurface.cpp +++ b/src/render/GLSurface.cpp @@ -124,6 +124,7 @@ int GLSurface::InitGLSettings() { glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); // Get supported line width range GLfloat lineRange[2]; @@ -789,11 +790,8 @@ void GLSurface::RenderMesh(mesh* m) { glDrawElements(GL_TRIANGLES, m->nTris * 3, GL_UNSIGNED_SHORT, (GLvoid*)0); } - if (bTextured && m->textured && m->texcoord) { - glBindTexture(GL_TEXTURE_2D, 0); - glBindTexture(GL_TEXTURE_CUBE_MAP, 0); + if (bTextured && m->textured && m->texcoord) glDisableVertexAttribArray(3); - } // Render points if (m->bShowPoints && m->vcolors) {