diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 3d02c0dfd..449fee202 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -30,6 +30,7 @@ void SCR_Viewsize_Callback (struct cvar_s *var, char *oldvalue); void SCR_Fov_Callback (struct cvar_s *var, char *oldvalue); #if defined(RGLQUAKE) void GL_Texturemode_Callback (struct cvar_s *var, char *oldvalue); +void GL_Texture_Anisotropic_Filtering_Callback (struct cvar_s *var, char *oldvalue); #endif // @@ -103,6 +104,7 @@ static cvar_t vid_desktopsettings = SCVARF("vid_desktopsettings", "0", CVAR_ARCH #if defined(RGLQUAKE) cvar_t gl_texturemode = SCVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texturemode_Callback); +cvar_t gl_texture_anisotropic_filtering = SCVARFC("gl_texture_anisotropic_filtering", "0", CVAR_ARCHIVE|CVAR_RENDERERCALLBACK, GL_Texture_Anisotropic_Filtering_Callback); cvar_t gl_conback = SCVARF("gl_conback", "", CVAR_RENDERERCALLBACK); cvar_t gl_font = SCVARF("gl_font", "", CVAR_RENDERERCALLBACK); //gl blends. Set this to 1 to stop the outside of your conchars from being visible @@ -345,6 +347,7 @@ void GLRenderer_Init(void) Cvar_Register (&r_drawdisk, GLRENDEREROPTIONS); Cvar_Register (&gl_texturemode, GLRENDEREROPTIONS); + Cvar_Register (&gl_texture_anisotropic_filtering, GLRENDEREROPTIONS); Cvar_Register (&gl_savecompressedtex, GLRENDEREROPTIONS); Cvar_Register (&gl_compress, GLRENDEREROPTIONS); Cvar_Register (&gl_driver, GLRENDEREROPTIONS); @@ -1046,7 +1049,6 @@ typedef struct { menucombo_t *conscalecombo; menucombo_t *bppcombo; menucombo_t *texturefiltercombo; - menucombo_t *anisotropycombo; menuedit_t *customwidth; menuedit_t *customheight; } videomenuinfo_t; @@ -1130,47 +1132,13 @@ qboolean M_VideoApply (union menuoption_s *op,struct menu_s *menu,int key) switch(info->texturefiltercombo->selectedoption) { case 0: + Cbuf_AddText("gl_texturemode gl_nearest_mipmap_nearest\n", RESTRICT_LOCAL); + break; + case 1: Cbuf_AddText("gl_texturemode gl_linear_mipmap_nearest\n", RESTRICT_LOCAL); - Cbuf_AddText("gl_texture_anisotropic_filtering 1\n", RESTRICT_LOCAL); break; - case 1: + case 2: Cbuf_AddText("gl_texturemode gl_linear_mipmap_linear\n", RESTRICT_LOCAL); - Cbuf_AddText("gl_texture_anisotropic_filtering \n", RESTRICT_LOCAL); - break; - case 2: - Cbuf_AddText("gl_texturemode gl_linear_mipmap_linear\n",RESTRICT_LOCAL); - Cbuf_AddText("gl_texture_anisotropic_filtering 2\n", RESTRICT_LOCAL); - break; - } - - switch(info->anisotropycombo->selectedoption) - { - case 0: - Cbuf_AddText("gl_texture_anisotropic_filtering 1\n", RESTRICT_LOCAL); - break; - case 1: - Cbuf_AddText("gl_texture_anisotropic_filtering 2\n", RESTRICT_LOCAL); - break; - case 2: - Cbuf_AddText("gl_texture_anisotropic_filtering 4\n", RESTRICT_LOCAL); - break; - case 3: - Cbuf_AddText("gl_texture_anisotropic_filtering 6\n", RESTRICT_LOCAL); - break; - case 4: - Cbuf_AddText("gl_texture_anisotropic_filtering 8\n", RESTRICT_LOCAL); - break; - case 5: - Cbuf_AddText("gl_texture_anisotropic_filtering 10\n", RESTRICT_LOCAL); - break; - case 6: - Cbuf_AddText("gl_texture_anisotropic_filtering 12\n", RESTRICT_LOCAL); - break; - case 7: - Cbuf_AddText("gl_texture_anisotropic_filtering 14\n", RESTRICT_LOCAL); - break; - case 8: - Cbuf_AddText("gl_texture_anisotropic_filtering 16\n", RESTRICT_LOCAL); break; } @@ -1232,22 +1200,9 @@ void M_Menu_Video_f (void) }; static const char *texturefilternames[] = { + "Nearest", "Bilinear", "Trilinear", - "Anisotropy", - NULL - }; - static const char *possibleanisotropylevels[] = - { - "0", - "2", - "4", - "6", - "8", - "10", - "12", - "14", - "16", NULL }; @@ -1258,12 +1213,9 @@ void M_Menu_Video_f (void) int currentbpp; #ifdef RGLQUAKE int currenttexturefilter; - int currentanisotropy; #endif int i, y; - char bilinear[] = "gl_linear_mipmap_nearest"; - char trilinear[] = "gl_linear_mipmap_linear"; prefabmode = -1; prefab2dmode = -1; for (i = 0; i < sizeof(vid_modes)/sizeof(vidmode_t); i++) @@ -1309,24 +1261,16 @@ void M_Menu_Video_f (void) currentbpp = 0; #ifdef RGLQUAKE - if (gl_anisotropy_factor >= 2) - currenttexturefilter = 2; - - if (strcmp(gl_texturemode.string,trilinear)) + if (!Q_strcasecmp(gl_texturemode.string, "gl_nearest_mipmap_nearest")) currenttexturefilter = 0; - else if (strcmp(gl_texturemode.string,bilinear)) + else if (!Q_strcasecmp(gl_texturemode.string, "gl_linear_mipmap_linear")) + currenttexturefilter = 2; + else if (!Q_strcasecmp(gl_texturemode.string, "gl_linear_mipmap_nearest")) currenttexturefilter = 1; else currenttexturefilter = 1; #endif -#ifdef RGLQUAKE - if (gl_anisotropy_factor == 1) - currentanisotropy = 0; - else - currentanisotropy = gl_anisotropy_factor/2; -#endif - MC_AddCenterPicture(menu, 4, "vidmodes"); @@ -1357,7 +1301,7 @@ void M_Menu_Video_f (void) MC_AddSlider(menu, 16, y, " Contrast", &v_contrast, 1, 3); y+=8; #ifdef RGLQUAKE info->texturefiltercombo = MC_AddCombo(menu, 16, y, " Texture Filter ", texturefilternames, currenttexturefilter); y+=8; - info->anisotropycombo = MC_AddCombo(menu, 16, y, "Anisotropy Level", possibleanisotropylevels, currentanisotropy); y+=8; + MC_AddSlider(menu, 16, y, "Anisotropy Level", &gl_texture_anisotropic_filtering, 1, 16); y+=8; #endif menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 152, 32, NULL, false); diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 5f56ffbf6..2e7a1ea0f 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -31,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //#define GL_USE8BITTEX -int gl_anisotropy_factor = 1; int glx, gly, glwidth, glheight; mesh_t draw_mesh; @@ -62,7 +61,7 @@ extern cvar_t gl_picmip2d; extern cvar_t r_drawdisk; extern cvar_t gl_compress; extern cvar_t gl_smoothfont, gl_smoothcrosshair, gl_fontedgeclamp; -extern cvar_t gl_texturemode; +extern cvar_t gl_texturemode, gl_texture_anisotropic_filtering; extern cvar_t cl_noblink; extern cvar_t gl_savecompressedtex; @@ -91,6 +90,7 @@ float char_instep; static unsigned cs_data[16*16]; static int externalhair; +int gl_anisotropy_factor; typedef struct { @@ -112,8 +112,6 @@ int gl_alpha_format = 4; int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; int gl_filter_max = GL_LINEAR; -int gl_anisotropy_factor_max = 0; - int texels; @@ -576,55 +574,17 @@ glmode_t modes[] = { {"GL_LINEAR_MIPMAP_LINEAR", "ll", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} }; -void GLDraw_Anisotropy_f (void) +void GL_Texture_Anisotropic_Filtering_Callback (struct cvar_s *var, char *oldvalue) { gltexture_t *glt; - char *arg; - int param; + int anfactor; - if (!gl_config.ext_texture_filter_anisotropic) - { - Con_Printf("Anisotropic Filtering: NOT SUPPORTED\n"); + gl_anisotropy_factor = 0; + + if (gl_config.ext_texture_filter_anisotropic < 2) return; - } - qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_anisotropy_factor_max); - - arg = Cmd_Argv(1); - - param = atoi(arg); - - if (Cmd_Argc() == 1) - { - //insert code that detects if user has forced AF through drivers - //because it has no effect if it is forced - - if (gl_anisotropy_factor == 1) - { - Con_Printf("Anisotropic Filtering: 1 (OFF) (Maximum: %dx)\n",gl_anisotropy_factor_max); - } - else - { - Con_Printf("Anisotropic Filtering: %dx (Maximum: %dx)\n",gl_anisotropy_factor,gl_anisotropy_factor_max); - } - return; - } - - if (param == 0) // Nvidia says GL Error when this is 0, ATI doesn't. 1 = off anyway. - param = 1; - - if ((fmod(param,2.0f) != 0.0f) && (param != 1)) // anisotropic filtering works in factors of 2 - param = param+1; - - if (param > gl_anisotropy_factor_max) - param = gl_anisotropy_factor_max; - - gl_anisotropy_factor = param; - - if (param == 1) - Con_Printf("Anisotropic Filtering: %d (OFF) (Maximum: %dx)\n",gl_anisotropy_factor,gl_anisotropy_factor_max); - else - Con_Printf("Anisotropic Filtering: %dx (Maximum: %dx)\n",gl_anisotropy_factor,gl_anisotropy_factor_max); + anfactor = bound(1, var->value, gl_config.ext_texture_filter_anisotropic); /* change all the existing max anisotropy settings */ for (glt = gltextures; glt ; glt = glt->next) //redo anisotropic filtering when map is changed @@ -633,9 +593,14 @@ void GLDraw_Anisotropy_f (void) { //qglBindTexture (GL_TEXTURE_2D, glt->texnum); GL_Bind (glt->texnum); - qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT,gl_anisotropy_factor); + qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)anfactor); } } + + if (anfactor >= 2) + gl_anisotropy_factor = anfactor; + else + gl_anisotropy_factor = 0; } /* @@ -1137,8 +1102,6 @@ void GLDraw_Init (void) memset(scrap_allocated, 0, sizeof(scrap_allocated)); - Cmd_AddRemCommand ("gl_texture_anisotropic_filtering", &GLDraw_Anisotropy_f); - GLDraw_ReInit(); R_BackendInit(); @@ -3153,10 +3116,8 @@ done: if (gl_config.sgis_generate_mipmap&&mipmap) 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 (gl_anisotropy_factor) + qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_anisotropy_factor); // without this, you could loose anisotropy on mapchange if (mipmap) { diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index e4192215a..c9b03f44d 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -135,7 +135,6 @@ lpMTexFUNC qglMTexCoord2fSGIS; lpSelTexFUNC qglSelectTextureSGIS; int mtexid0; int mtexid1; -int gl_anisotropy_factor_max; //ati_truform PFNGLPNTRIANGLESIATIPROC qglPNTrianglesiATI; @@ -233,15 +232,13 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name)) gl_config.arb_shader_objects = false; - gl_config.ext_texture_filter_anisotropic = false; + gl_config.ext_texture_filter_anisotropic = 0; if (strstr(gl_extensions, "GL_EXT_texture_filter_anisotropic")) { - gl_config.ext_texture_filter_anisotropic = true; + qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_config.ext_texture_filter_anisotropic); - qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_anisotropy_factor_max); - - Con_SafePrintf("Anisotropic filter extension found (%dx max).\n",gl_anisotropy_factor_max); + Con_SafePrintf("Anisotropic filter extension found (%dx max).\n",gl_config.ext_texture_filter_anisotropic); } if (strstr(gl_extensions, "GL_ARB_texture_non_power_of_two")) diff --git a/engine/gl/glquake.h b/engine/gl/glquake.h index cf7b740dc..bda31b1cf 100644 --- a/engine/gl/glquake.h +++ b/engine/gl/glquake.h @@ -97,12 +97,11 @@ typedef struct { qboolean arb_texture_env_dot3; qboolean arb_texture_cube_map; - qboolean ext_texture_filter_anisotropic; - qboolean arb_texture_compression; // qboolean arb_fragment_program; qboolean arb_shader_objects; qboolean ext_stencil_wrap; + int ext_texture_filter_anisotropic; int maxtmus; //max texture units } gl_config_t;