diff --git a/GL/private.h b/GL/private.h index 64f8161..87d7674 100644 --- a/GL/private.h +++ b/GL/private.h @@ -43,6 +43,8 @@ typedef struct { GLenum minFilter; GLenum magFilter; + + GLboolean isCompressed; } TextureObject; typedef struct { diff --git a/GL/state.c b/GL/state.c index fb48212..43b89ed 100644 --- a/GL/state.c +++ b/GL/state.c @@ -146,6 +146,12 @@ void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit) { break; } + /* FIXME: If you disable mipmaps on a compressed mipmapped texture + * you get corruption and I don't know why, so we force mipmapping for now */ + if(tx1->isCompressed && _glIsMipmapComplete(tx1)) { + enableMipmaps = GL_TRUE; + } + if(enableMipmaps) { if(tx1->minFilter == GL_LINEAR_MIPMAP_NEAREST) { filter = PVR_FILTER_TRILINEAR1; diff --git a/GL/texture.c b/GL/texture.c index b254bcc..7bf4748 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -330,14 +330,15 @@ void APIENTRY glCompressedTexImage2DARB(GLenum target, TextureObject* active = TEXTURE_UNITS[ACTIVE_TEXTURE]; /* Set the required mipmap count */ - active->mipmapCount = _glGetMipmapLevelCount(active); - active->mipmap = (mipmapped) ? ~0 : (1 << level); /* Set only a single bit if this wasn't mipmapped otherwise set all */ active->width = width; active->height = height; active->color = _determinePVRFormat( internalFormat, internalFormat /* Doesn't matter (see determinePVRFormat) */ ); + active->mipmapCount = _glGetMipmapLevelCount(active); + active->mipmap = (mipmapped) ? ~0 : (1 << level); /* Set only a single bit if this wasn't mipmapped otherwise set all */ + active->isCompressed = GL_TRUE; /* Odds are slim new data is same size as old, so free always */ if(active->data) @@ -644,6 +645,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLuint size = _glGetMipmapDataSize(active); active->data = pvr_mem_malloc(size); + active->isCompressed = GL_FALSE; } /* Mark this level as set in the mipmap bitmask */