Merge pull request #494 from DanielGibson/fix-gl_texturemode

Use gl_texturemode for UI and skies as well, fixes #489 and #491
This commit is contained in:
Yamagi 2020-01-02 14:37:33 +01:00 committed by GitHub
commit e23010c9f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 18 deletions

View File

@ -501,8 +501,10 @@ RDraw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
0, GL_COLOR_INDEX, GL_UNSIGNED_BYTE, image8);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Note: gl_filter_min could be GL_*_MIPMAP_* so we can't use it for min filter here (=> no mipmaps)
// but gl_filter_max (either GL_LINEAR or GL_NEAREST) should do the trick.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );

View File

@ -216,16 +216,21 @@ R_TextureMode(char *string)
ri.Cvar_SetValue("gl_anisotropic", 0.0);
}
const char* nolerplist = gl_nolerp_list->string;
/* change all the existing mipmap texture objects */
for (i = 0, glt = gltextures; i < numgltextures; i++, glt++)
{
if ((glt->type != it_pic) && (glt->type != it_sky))
if (nolerplist != NULL && strstr(nolerplist, glt->name) != NULL)
{
R_Bind(glt->texnum);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
gl_filter_min);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
gl_filter_max);
continue; /* those (by default: font and crosshairs) always only use GL_NEAREST */
}
R_Bind(glt->texnum);
if ((glt->type != it_pic) && (glt->type != it_sky)) /* mipmapped texture */
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
/* Set anisotropic filter if supported and enabled */
if (gl_config.anisotropic && gl_anisotropic->value)
@ -234,6 +239,13 @@ R_TextureMode(char *string)
gl_anisotropic->value);
}
}
else /* texture has no mipmaps */
{
// we can't use gl_filter_min which might be GL_*_MIPMAP_*
// also, there's no anisotropic filtering for textures w/o mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
}
}
}

View File

@ -378,8 +378,10 @@ GL3_Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
free(img);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Note: gl_filter_min could be GL_*_MIPMAP_* so we can't use it for min filter here (=> no mipmaps)
// but gl_filter_max (either GL_LINEAR or GL_NEAREST) should do the trick.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
drawTexturedRectangle(x, y, w, h, 0.0f, 0.0f, 1.0f, 1.0f);

View File

@ -64,7 +64,7 @@ GL3_TextureMode(char *string)
if (i == num_modes)
{
R_Printf(PRINT_ALL, "bad filter name\n");
R_Printf(PRINT_ALL, "bad filter name '%s' (probably from gl_texturemode)\n", string);
return;
}
@ -90,13 +90,20 @@ GL3_TextureMode(char *string)
gl3image_t *glt;
/* change all the existing mipmap texture objects */
const char* nolerplist = gl_nolerp_list->string;
/* change all the existing texture objects */
for (i = 0, glt = gl3textures; i < numgl3textures; i++, glt++)
{
if ((glt->type != it_pic) && (glt->type != it_sky))
if (nolerplist != NULL && strstr(nolerplist, glt->name) != NULL)
{
continue; /* those (by default: font and crosshairs) always only use GL_NEAREST */
}
GL3_SelectTMU(GL_TEXTURE0);
GL3_Bind(glt->texnum);
if ((glt->type != it_pic) && (glt->type != it_sky)) /* mipmapped texture */
{
GL3_SelectTMU(GL_TEXTURE0);
GL3_Bind(glt->texnum);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
@ -106,6 +113,13 @@ GL3_TextureMode(char *string)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, gl_anisotropic->value);
}
}
else /* texture has no mipmaps */
{
// we can't use gl_filter_min which might be GL_*_MIPMAP_*
// also, there's no anisotropic filtering for textures w/o mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
}
}
}
@ -194,7 +208,7 @@ GL3_Upload32(unsigned *data, int width, int height, qboolean mipmap)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);
}
else
else // if the texture has no mipmaps, we can't use gl_filter_min which might be GL_*_MIPMAP_*
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_max);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max);

View File

@ -43,8 +43,8 @@ GL3_SetDefaultState(void)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
// TODO: gl_texturemode, gl1_texturealphamode?
//GL3_TextureMode(gl_texturemode->string);
// TODO: gl1_texturealphamode?
GL3_TextureMode(gl_texturemode->string);
//R_TextureAlphaMode(gl1_texturealphamode->string);
//R_TextureSolidMode(gl1_texturesolidmode->string);

View File

@ -508,6 +508,7 @@ extern cvar_t *vid_gamma;
extern cvar_t *gl3_intensity;
extern cvar_t *gl3_intensity_2D;
extern cvar_t *gl_anisotropic;
extern cvar_t *gl_texturemode;
extern cvar_t *r_lightlevel;
extern cvar_t *gl3_overbrightbits;