Anisotropic Filtering
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1655 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
96c5dd71ec
commit
a42d9dac20
1 changed files with 101 additions and 33 deletions
|
@ -26,6 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "glquake.h"
|
#include "glquake.h"
|
||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
|
|
||||||
|
#include <stdlib.h> // is this needed for atoi?
|
||||||
|
#include <stdio.h> // is this needed for atoi?
|
||||||
|
|
||||||
//#define GL_USE8BITTEX
|
//#define GL_USE8BITTEX
|
||||||
|
|
||||||
int glx, gly, glwidth, glheight;
|
int glx, gly, glwidth, glheight;
|
||||||
|
@ -105,6 +108,8 @@ int gl_alpha_format = 4;
|
||||||
|
|
||||||
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
|
||||||
int gl_filter_max = GL_LINEAR;
|
int gl_filter_max = GL_LINEAR;
|
||||||
|
int gl_anisotropy_factor = 1;
|
||||||
|
int gl_anisotropy_factor_max = 0;
|
||||||
|
|
||||||
|
|
||||||
int texels;
|
int texels;
|
||||||
|
@ -574,6 +579,61 @@ glmode_t modes[] = {
|
||||||
{"GL_LINEAR_MIPMAP_LINEAR", "ll", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}
|
{"GL_LINEAR_MIPMAP_LINEAR", "ll", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Control the anisotropy filtering. ~ Moodles
|
||||||
|
|
||||||
|
void GLDraw_Anisotropy_f (void)
|
||||||
|
{
|
||||||
|
gltexture_t *glt;
|
||||||
|
char *arg;
|
||||||
|
int param;
|
||||||
|
|
||||||
|
if (!gl_config.ext_texture_filter_anisotropic)
|
||||||
|
{
|
||||||
|
Con_Printf("Ignoring anisotropy (not supported)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_anisotropy_factor_max); // im lazy
|
||||||
|
|
||||||
|
arg = Cmd_Argv(1);
|
||||||
|
|
||||||
|
param = atoi(arg); // I know this isn't gcc compatible, but im no lunix programmer so someone can fix it
|
||||||
|
|
||||||
|
if (Cmd_Argc() == 1)
|
||||||
|
{
|
||||||
|
Con_Printf("Maximum filtering factor: %d\n",gl_anisotropy_factor_max);
|
||||||
|
Con_Printf("0 = off, 1 = off, 2 and beyond = on\n");
|
||||||
|
|
||||||
|
//insert code that detects if user has forced AF through drivers
|
||||||
|
// because it has no effect if it is forced
|
||||||
|
|
||||||
|
if ((gl_anisotropy_factor == 0) || (gl_anisotropy_factor == 1))
|
||||||
|
{
|
||||||
|
Con_Printf("Anisotropic Filtering Factor: off\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_Printf("Current Anisotopic Filtering Factor: %d\n",gl_anisotropy_factor);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_anisotropy_factor = param;
|
||||||
|
|
||||||
|
Con_Printf("Attempting to set Anisotopic Filtering Factor: %d\n",gl_anisotropy_factor);
|
||||||
|
|
||||||
|
/* change all the existing max anisotropy settings */
|
||||||
|
for (glt = gltextures; glt ; glt = glt->next) //redo anisotropic filtering when map is changed
|
||||||
|
{
|
||||||
|
if (glt->mipmap)
|
||||||
|
{
|
||||||
|
//qglBindTexture (GL_TEXTURE_2D, glt->texnum);
|
||||||
|
GL_Bind (glt->texnum);
|
||||||
|
qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,gl_anisotropy_factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
Draw_TextureMode_f
|
Draw_TextureMode_f
|
||||||
|
@ -1079,6 +1139,8 @@ void GLDraw_Init (void)
|
||||||
|
|
||||||
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
memset(scrap_allocated, 0, sizeof(scrap_allocated));
|
||||||
|
|
||||||
|
Cmd_AddRemCommand ("gl_texture_anisotropic_filtering", &GLDraw_Anisotropy_f);
|
||||||
|
|
||||||
GLDraw_ReInit();
|
GLDraw_ReInit();
|
||||||
|
|
||||||
R_BackendInit();
|
R_BackendInit();
|
||||||
|
@ -1099,6 +1161,8 @@ void GLDraw_Init (void)
|
||||||
void GLDraw_DeInit (void)
|
void GLDraw_DeInit (void)
|
||||||
{
|
{
|
||||||
Cmd_RemoveCommand("gl_texturemode");
|
Cmd_RemoveCommand("gl_texturemode");
|
||||||
|
Cmd_RemoveCommand ("gl_texture_anisotropic_filtering");
|
||||||
|
|
||||||
draw_disc = NULL;
|
draw_disc = NULL;
|
||||||
|
|
||||||
if (uploadmemorybuffer)
|
if (uploadmemorybuffer)
|
||||||
|
@ -2996,6 +3060,10 @@ done:
|
||||||
if (gl_config.sgis_generate_mipmap&&mipmap)
|
if (gl_config.sgis_generate_mipmap&&mipmap)
|
||||||
qglTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
qglTexParameterf(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_FALSE);
|
||||||
|
|
||||||
|
if (gl_config.ext_texture_filter_anisotropic)
|
||||||
|
{
|
||||||
|
qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,gl_anisotropy_factor); // without this, you could loose anisotropy on mapchange
|
||||||
|
}
|
||||||
|
|
||||||
if (mipmap)
|
if (mipmap)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue