From c196e1ccfce56dd2d87b57898cf6da5d8aacae50 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 5 Apr 2011 21:10:20 +0000 Subject: [PATCH] - try to see if this fixes an opengl bug, by retrying texture loading using older opengl API if newer fails --- .../sources/graphics/gl/texture_gl.cpp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/source/shared_lib/sources/graphics/gl/texture_gl.cpp b/source/shared_lib/sources/graphics/gl/texture_gl.cpp index 710ce7f7..05a5b319 100644 --- a/source/shared_lib/sources/graphics/gl/texture_gl.cpp +++ b/source/shared_lib/sources/graphics/gl/texture_gl.cpp @@ -737,6 +737,19 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy) { if(error2 == GL_NO_ERROR) { error = GL_NO_ERROR; } + else { + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexImage1D( + GL_TEXTURE_1D, 0, glCompressionFormat, pixmap.getW(), + 0, glFormat, GL_UNSIGNED_BYTE, pixels); + + GLint error3= glGetError(); + if(error3 == GL_NO_ERROR) { + error = GL_NO_ERROR; + } + } } // @@ -839,6 +852,18 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) { if(error2 == GL_NO_ERROR) { error = GL_NO_ERROR; } + else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glFilter); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + int error3= gluBuild2DMipmaps( + GL_TEXTURE_2D, glCompressionFormat, + pixmap.getW(), pixmap.getH(), + glFormat, GL_UNSIGNED_BYTE, pixels); + if(error3 == GL_NO_ERROR) { + error = GL_NO_ERROR; + } + } } // @@ -870,6 +895,18 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) { if(error2 == GL_NO_ERROR) { error = GL_NO_ERROR; } + else { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexImage2D(GL_TEXTURE_2D, 0, glCompressionFormat,pixmap.getW(), + pixmap.getH(),0, glFormat, GL_UNSIGNED_BYTE, pixels); + + GLint error3= glGetError(); + if(error3 == GL_NO_ERROR) { + error = GL_NO_ERROR; + } + } } // @@ -1072,6 +1109,17 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) { if(error2 == GL_NO_ERROR) { error = GL_NO_ERROR; } + else { + int error3= gluBuild2DMipmaps( + target, glCompressionFormat, + currentPixmap->getW(), currentPixmap->getH(), + glFormat, GL_UNSIGNED_BYTE, pixels); + + + if(error3 == GL_NO_ERROR) { + error = GL_NO_ERROR; + } + } } // @@ -1103,6 +1151,16 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) { if(error2 == GL_NO_ERROR) { error = GL_NO_ERROR; } + else { + glTexImage2D(target, 0, glCompressionFormat, + currentPixmap->getW(), currentPixmap->getH(), + 0, glFormat, GL_UNSIGNED_BYTE, pixels); + + int error3 = glGetError(); + if(error3 == GL_NO_ERROR) { + error = GL_NO_ERROR; + } + } } //