Browse Source

Fixed the check to reset Texture's requested levels when loading uncompressed. Fixes uncompressed images always having mipmaps.

Lasse Öörni 12 years ago
parent
commit
af9905a891

+ 3 - 1
Source/Engine/Graphics/Direct3D9/D3D9Texture2D.cpp

@@ -339,7 +339,9 @@ bool Texture2D::Load(SharedPtr<Image> image, bool useAlpha)
             break;
         }
         
-        SetNumLevels(0); // Determine number of levels after creation
+        // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+        if (IsCompressed() && requestedLevels_ > 1)
+            requestedLevels_ = 0;
         SetSize(levelWidth, levelHeight, format);
         
         for (unsigned i = 0; i < levels_; ++i)

+ 3 - 1
Source/Engine/Graphics/Direct3D9/D3D9Texture3D.cpp

@@ -391,7 +391,9 @@ bool Texture3D::Load(SharedPtr<Image> image, bool useAlpha)
             break;
         }
         
-        SetNumLevels(0); // Determine number of levels after creation
+        // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+        if (IsCompressed() && requestedLevels_ > 1)
+            requestedLevels_ = 0;
         SetSize(levelWidth, levelHeight, levelDepth, format);
         
         for (unsigned i = 0; i < levels_; ++i)

+ 3 - 1
Source/Engine/Graphics/Direct3D9/D3D9TextureCube.cpp

@@ -409,7 +409,9 @@ bool TextureCube::Load(CubeMapFace face, SharedPtr<Image> image, bool useAlpha)
         // Create the texture when face 0 is being loaded, check that rest of the faces are same size & format
         if (!face)
         {
-            SetNumLevels(0); // Determine number of levels after creation
+            // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+            if (IsCompressed() && requestedLevels_ > 1)
+                requestedLevels_ = 0;
             SetSize(levelWidth, format);
         }
         else

+ 3 - 1
Source/Engine/Graphics/OpenGL/OGLTexture2D.cpp

@@ -289,7 +289,9 @@ bool Texture2D::Load(SharedPtr<Image> image, bool useAlpha)
             break;
         }
         
-        SetNumLevels(0); // Determine number of levels after creation
+        // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+        if (IsCompressed() && requestedLevels_ > 1)
+            requestedLevels_ = 0;
         SetSize(levelWidth, levelHeight, format);
         if (!object_)
             return false;

+ 3 - 1
Source/Engine/Graphics/OpenGL/OGLTexture3D.cpp

@@ -335,7 +335,9 @@ bool Texture3D::Load(SharedPtr<Image> image, bool useAlpha)
             break;
         }
         
-        SetNumLevels(0); // Determine number of levels after creation
+        // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+        if (IsCompressed() && requestedLevels_ > 1)
+            requestedLevels_ = 0;
         SetSize(levelWidth, levelHeight, levelDepth, format);
         if (!object_)
             return false;

+ 3 - 1
Source/Engine/Graphics/OpenGL/OGLTextureCube.cpp

@@ -369,7 +369,9 @@ bool TextureCube::Load(CubeMapFace face, SharedPtr<Image> image, bool useAlpha)
         // Create the texture when face 0 is being loaded, check that rest of the faces are same size & format
         if (!face)
         {
-            SetNumLevels(0); // Determine number of levels after creation
+            // If image was previously compressed, reset number of requested levels to avoid error if level count is too high for new size
+            if (IsCompressed() && requestedLevels_ > 1)
+                requestedLevels_ = 0;
             SetSize(levelWidth, format);
         }
         else