diff --git a/source/src/cube.h b/source/src/cube.h index c0e64e2b..3a03c429 100644 --- a/source/src/cube.h +++ b/source/src/cube.h @@ -46,7 +46,7 @@ extern int stenciling, stencilshadow; extern bool intermission; extern int arenaintermission; extern hashtable mapinfo; -extern int hwtexsize; +extern int hwtexsize, hwmaxaniso; extern int numspawn[3], maploaded, numflagspawn[2]; extern int verbose; diff --git a/source/src/protos.h b/source/src/protos.h index a2dd91fd..a73c75cd 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -2,7 +2,7 @@ #ifndef STANDALONE -extern bool hasTE, hasMT, hasMDA, hasDRE, hasstencil, hasST2, hasSTW, hasSTS; +extern bool hasTE, hasMT, hasMDA, hasDRE, hasstencil, hasST2, hasSTW, hasSTS, hasAF; // GL_ARB_multitexture extern PFNGLACTIVETEXTUREARBPROC glActiveTexture_; diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index 3de63ac4..f974b52d 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -3,7 +3,7 @@ #include "cube.h" #include "bot/bot.h" -bool hasTE = false, hasMT = false, hasMDA = false, hasDRE = false, hasstencil = false, hasST2 = false, hasSTW = false, hasSTS = false; +bool hasTE = false, hasMT = false, hasMDA = false, hasDRE = false, hasstencil = false, hasST2 = false, hasSTW = false, hasSTS = false, hasAF; // GL_ARB_multitexture PFNGLACTIVETEXTUREARBPROC glActiveTexture_ = NULL; @@ -90,6 +90,14 @@ void gl_checkextensions() if(strstr(exts, "GL_EXT_stencil_wrap")) hasSTW = true; + if(strstr(exts, "GL_EXT_texture_filter_anisotropic")) + { + GLint val; + glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &val); + hwmaxaniso = val; + hasAF = true; + } + if(!strstr(exts, "GL_ARB_fragment_program")) { // not a required extension, but ensures the card has enough power to do reflections diff --git a/source/src/texture.cpp b/source/src/texture.cpp index ff2689de..d0cd4189 100644 --- a/source/src/texture.cpp +++ b/source/src/texture.cpp @@ -65,10 +65,12 @@ Texture *notexture = NULL, *noworldtexture = NULL; hashtable textures; VAR(hwtexsize, 1, 0, 0); +VAR(hwmaxaniso, 1, 0, 0); VARFP(maxtexsize, 0, 0, 1<<12, initwarning("texture quality", INIT_LOAD)); VARFP(texreduce, -1, 0, 3, initwarning("texture quality", INIT_LOAD)); VARFP(trilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); VARFP(bilinear, 0, 1, 1, initwarning("texture filtering", INIT_LOAD)); +VARFP(aniso, 0, 0, 16, initwarning("texture filtering", INIT_LOAD)); int formatsize(GLenum format) { @@ -126,6 +128,7 @@ void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format buf = new uchar[tw*th*bpp]; scaletexture((uchar *)pixels, pw, ph, bpp, buf, tw, th); } + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); for(int level = 0;; level++) { uchar *src = buf ? buf : (uchar *)pixels; @@ -139,30 +142,13 @@ void uploadtexture(GLenum target, GLenum internal, int tw, int th, GLenum format } if(buf) delete[] buf; } -void check_anisotropy() -{ - float largest_supported_anisotropy; - glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy); - conoutf("your card reports: %3.1f as max anisotropy value", largest_supported_anisotropy); -} -COMMAND(check_anisotropy, ARG_NONE); -VARP(anisotropy, 0, 0, 16); void createtexture(int tnum, int w, int h, void *pixels, int clamp, bool mipmap, bool canreduce, GLenum format) { glBindTexture(GL_TEXTURE_2D, tnum); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, clamp&1 ? GL_CLAMP_TO_EDGE : GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, clamp&2 ? GL_CLAMP_TO_EDGE : GL_REPEAT); - switch(anisotropy) - { - case 1: - case 2: - case 4: - case 8: - case 16: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy); break; - default: break; - } + if(hasAF && min(aniso, hwmaxaniso) > 0 && mipmap) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, min(aniso, hwmaxaniso)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, bilinear ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mipmap ?