From 9a9fcd1ad47857a62bed1a45d5e73d363c6bad4d Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Wed, 2 Jul 2003 00:38:01 +0000 Subject: [PATCH] Ensure MIPMAP levels is reset when rebinding an existing texture to a texture unit. --- dlls/d3d8/texture.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index d10b4cd4f47..65e5c5a7cbd 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -119,7 +119,8 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) { checkGLcall("glBindTexture"); TRACE("Texture %p (level %d) given name %d\n", This->surfaces[i], i, This->surfaces[i]->textureName); /* No need to walk through all mip-map levels, since already all assigned */ - i = This->levels; + i = This->levels; + } else { if (i == 0) { if (This->surfaces[i]->textureName == 0) { @@ -130,19 +131,21 @@ void WINAPI IDirect3DTexture8Impl_PreLoad(LPDIRECT3DTEXTURE8 iface) { glBindTexture(GL_TEXTURE_2D, This->surfaces[i]->textureName); checkGLcall("glBindTexture"); - - TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels - 1); - checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)"); - } - IDirect3DSurface8Impl_LoadTexture((LPDIRECT3DSURFACE8) This->surfaces[i], GL_TEXTURE_2D, i); - /* Removed glTexParameterf now TextureStageStates are initialized at startup */ - This->Dirty = FALSE; } } + /* No longer dirty */ + This->Dirty = FALSE; + + /* Always need to reset the number of mipmap levels when rebinding as it is + a property of the active texture unit, and another texture may have set it + to a different value */ + TRACE("Setting GL_TEXTURE_MAX_LEVEL to %d\n", This->levels - 1); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels - 1); + checkGLcall("glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, This->levels)"); + LEAVE_GL(); return ;