- try to see if this fixes an opengl bug, by retrying texture loading using older opengl API if newer fails

This commit is contained in:
Mark Vejvoda
2011-04-05 21:10:20 +00:00
parent 9cb1cd7bc8
commit c196e1ccfc

View File

@@ -737,6 +737,19 @@ void Texture1DGl::init(Filter filter, int maxAnisotropy) {
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_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 error= glGetError();
// Now try without compression if we tried compression
if(error != GL_NO_ERROR && glCompressionFormat != glInternalFormat) {
glTexImage1D(
GL_TEXTURE_1D, 0, glInternalFormat, pixmap.getW(),
0, glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error2= glGetError();
if(error2 == GL_NO_ERROR) { if(error2 == GL_NO_ERROR) {
error = GL_NO_ERROR; error = GL_NO_ERROR;
@@ -839,6 +852,18 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
glFormat, GL_UNSIGNED_BYTE, pixels); glFormat, GL_UNSIGNED_BYTE, pixels);
*/ */
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, glCompressionFormat,
pixmap.getW(), pixmap.getH(), 0,
glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error= glGetError();
// Now try without compression if we tried compression
if(error != GL_NO_ERROR && glCompressionFormat != glInternalFormat) {
glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat,
pixmap.getW(), pixmap.getH(), 0,
glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error2= glGetError(); GLint error2= glGetError();
if(error2 == GL_NO_ERROR) { if(error2 == GL_NO_ERROR) {
@@ -870,6 +895,18 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
else { else {
//build single texture //build single texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 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 error= glGetError();
// Now try without compression if we tried compression
if(error != GL_NO_ERROR && glCompressionFormat != glInternalFormat) {
glTexImage2D(GL_TEXTURE_2D, 0, glInternalFormat,pixmap.getW(),
pixmap.getH(),0, glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error2= glGetError(); GLint error2= glGetError();
if(error2 == GL_NO_ERROR) { if(error2 == GL_NO_ERROR) {
@@ -1072,6 +1109,17 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
*/ */
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(target, 0, glCompressionFormat,
currentPixmap->getW(), currentPixmap->getH(), 0,
glFormat, GL_UNSIGNED_BYTE, pixels);
int error = glGetError();
// Now try without compression if we tried compression
if(error != GL_NO_ERROR && glCompressionFormat != glInternalFormat) {
glTexImage2D(target, 0, glInternalFormat,
currentPixmap->getW(), currentPixmap->getH(), 0,
glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error2= glGetError(); GLint error2= glGetError();
@@ -1103,6 +1151,16 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
else { else {
glTexImage2D( glTexImage2D(
target, 0, glCompressionFormat, target, 0, glCompressionFormat,
currentPixmap->getW(), currentPixmap->getH(),
0, glFormat, GL_UNSIGNED_BYTE, pixels);
int error = glGetError();
// Now try without compression if we tried compression
if(error != GL_NO_ERROR && glCompressionFormat != glInternalFormat) {
glTexImage2D(
target, 0, glInternalFormat,
currentPixmap->getW(), currentPixmap->getH(),
0, glFormat, GL_UNSIGNED_BYTE, pixels); 0, glFormat, GL_UNSIGNED_BYTE, pixels);
GLint error2= glGetError(); GLint error2= glGetError();