clean up messy anisotropy patch
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6017 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ extern int stenciling, stencilshadow;
|
||||
extern bool intermission;
|
||||
extern int arenaintermission;
|
||||
extern hashtable<char *, enet_uint32> mapinfo;
|
||||
extern int hwtexsize;
|
||||
extern int hwtexsize, hwmaxaniso;
|
||||
extern int numspawn[3], maploaded, numflagspawn[2];
|
||||
extern int verbose;
|
||||
|
||||
|
||||
+1
-1
@@ -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_;
|
||||
|
||||
@@ -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
|
||||
|
||||
+4
-18
@@ -65,10 +65,12 @@ Texture *notexture = NULL, *noworldtexture = NULL;
|
||||
hashtable<char *, Texture> 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 ?
|
||||
|
||||
Reference in New Issue
Block a user