added TEXF_FORCENEAREST and TEXF_FORCELINEAR flags
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 7 Mar 2003 09:31:10 +0000 (09:31 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 7 Mar 2003 09:31:10 +0000 (09:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2810 d7cf8633-e32d-0410-b094-e92efae38249

gl_textures.c
r_textures.h

index f0b74a3..a05ab29 100644 (file)
@@ -567,11 +567,35 @@ static void GL_SetupTextureParameters(int flags, int texturetype)
        if (gltexturetypedimensions[texturetype] >= 3)
                qglTexParameteri(textureenum, GL_TEXTURE_WRAP_R, wrapmode);
 
-       if (flags & TEXF_MIPMAP)
-               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+       if (flags & TEXF_FORCENEAREST)
+       {
+               if (flags & TEXF_MIPMAP)
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
+               else
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+       }
+       else if (flags & TEXF_FORCELINEAR)
+       {
+               if (flags & TEXF_MIPMAP)
+               {
+                       if (gl_filter_min == GL_NEAREST_MIPMAP_LINEAR || gl_filter_min == GL_LINEAR_MIPMAP_LINEAR)
+                               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+                       else
+                               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
+               }
+               else
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+       }
        else
-               qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
-       qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+       {
+               if (flags & TEXF_MIPMAP)
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_min);
+               else
+                       qglTexParameteri(textureenum, GL_TEXTURE_MIN_FILTER, gl_filter_mag);
+               qglTexParameteri(textureenum, GL_TEXTURE_MAG_FILTER, gl_filter_mag);
+       }
 
        CHECKGLERROR
 }
index 5cf3753..a6e323a 100644 (file)
 #define TEXF_FRAGMENT 0x00000010
 // indicates texture coordinates should be clamped rather than wrapping
 #define TEXF_CLAMP 0x00000020
+// indicates texture should be uploaded using GL_NEAREST or GL_NEAREST_MIPMAP_NEAREST mode
+#define TEXF_FORCENEAREST 0x00000040
+// indicates texture should be uploaded using GL_LINEAR or GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR mode
+#define TEXF_FORCELINEAR 0x00000080
 // used for checking if textures mismatch
-#define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_FRAGMENT | TEXF_CLAMP)
+#define TEXF_IMPORTANTBITS (TEXF_ALPHA | TEXF_MIPMAP | TEXF_FRAGMENT | TEXF_CLAMP | TEXF_FORCENEAREST | TEXF_FORCELINEAR)
 
 // 8bit paletted
 #define TEXTYPE_PALETTE 1