ecere/gfx/drivers/OpenGL: Fixed mipmapping
authorJerome St-Louis <jerome@ecere.com>
Fri, 26 Jun 2015 23:34:38 +0000 (19:34 -0400)
committerJerome St-Louis <jerome@ecere.com>
Thu, 15 Oct 2015 00:23:01 +0000 (20:23 -0400)
- Was wrongly setting MIPMAP filter on MAG_FILTER instead of MIN_FILTER
- 1x1 level was not being set
- Also setting MAX_ANISOTROPY_EXT to 16.0

ecere/src/gfx/drivers/OpenGLDisplayDriver.ec

index 6a364cb..7c79ca4 100644 (file)
@@ -2759,8 +2759,9 @@ class OpenGLDisplayDriver : DisplayDriver
          glBindTexture(GL_TEXTURE_2D, glBitmap);
          glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
 
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mipMaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
+         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipMaps ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR);
+         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
          //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 
          //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -2768,14 +2769,17 @@ class OpenGLDisplayDriver : DisplayDriver
 
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16.0 );
 
          glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
          result = true;
 
-         for(level = 0; result && (w > 1 || h > 1); level++, w >>= 1, h >>= 1)
+         for(level = 0; result && (w >= 1 || h >= 1); level++, w >>= 1, h >>= 1)
          {
             Bitmap mipMap;
+            if(!w) w = 1;
+            if(!h) h = 1;
             if(bitmap.width != w || bitmap.height != h)
             {
                mipMap = Bitmap { };