- added new ini setting to see if this helps fix non power of two texture loading for some ATI video cards, user needs to set this in the ini:

EnableATIHacks=true
This commit is contained in:
Mark Vejvoda
2011-04-28 07:48:19 +00:00
parent 95dcd042a3
commit 15489b066f
6 changed files with 117 additions and 2 deletions

View File

@@ -52,6 +52,8 @@ namespace Shared { namespace Graphics { namespace Gl {
typedef void (APIENTRY * PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT = NULL;
PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT = NULL;
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT = NULL;
PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT = NULL;
PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT = NULL;
@@ -831,6 +833,16 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
if(isGlExtensionSupported("GL_EXT_texture_filter_anisotropic")) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
}
if(mipmap) {
GLuint glFilter= filter==fTrilinear? GL_LINEAR_MIPMAP_LINEAR: GL_LINEAR_MIPMAP_NEAREST;
//build mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, glFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
/*
* Replaced this call due to: http://www.opengl.org/wiki/Common_Mistakes#gluBuild2DMipmaps
*
int error= gluBuild2DMipmaps(
GL_TEXTURE_2D, glCompressionFormat,
@@ -883,6 +895,14 @@ void Texture2DGl::init(Filter filter, int maxAnisotropy) {
if(error4 == GL_NO_ERROR) {
error = GL_NO_ERROR;
}
}
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error building texture 2D mipmaps");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";
sprintf(szBuf,"Error building texture 2D mipmaps [%s], returned: %d [%s] for [%s] w = %d, h = %d, glCompressionFormat = %d",this->path.c_str(),error,errorString,(pixmap.getPath() != "" ? pixmap.getPath().c_str() : this->path.c_str()),pixmap.getW(),pixmap.getH(),glCompressionFormat);
throw runtime_error(szBuf);
}
@@ -1072,7 +1092,7 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
glBindTexture(GL_TEXTURE_CUBE_MAP, handle);
//wrap
GLint wrap= toWrapModeGl(wrapMode);
GLint wrap= toWrapModeGl(wrapMode);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, wrap);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, wrap);
@@ -1098,6 +1118,14 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
glCompressionFormat = glInternalFormat;
}
//pixel init var
const uint8* pixels= pixmapInit? currentPixmap->getPixels(): NULL;
GLenum target= GL_TEXTURE_CUBE_MAP_POSITIVE_X + i;
if(mipmap) {
/*
* Replaced this call due to: http://www.opengl.org/wiki/Common_Mistakes#gluBuild2DMipmaps
*
int error= gluBuild2DMipmaps(
target, glCompressionFormat,
@@ -1150,6 +1178,15 @@ void TextureCubeGl::init(Filter filter, int maxAnisotropy) {
currentPixmap->getW(), currentPixmap->getH(),
glFormat, GL_UNSIGNED_BYTE, pixels);
if(error4 == GL_NO_ERROR) {
error = GL_NO_ERROR;
}
}
//
if(error != GL_NO_ERROR) {
//throw runtime_error("Error building texture cube mipmaps");
const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
char szBuf[1024]="";