draw: add TEXTURE_ANISOTROPY flag

main
Dominik Madarász 2024-02-14 15:09:47 +01:00
parent 7bb5bbad0d
commit 7d5efa6c62
6 changed files with 34 additions and 3 deletions

View File

@ -1062,6 +1062,7 @@ enum TEXTURE_FLAGS {
TEXTURE_NEAREST = 0,
TEXTURE_LINEAR = 64,
TEXTURE_MIPMAPS = 128,
TEXTURE_ANISOTROPY = 1 << 30,
TEXTURE_CLAMP = 0,
TEXTURE_BORDER = 0x100,
TEXTURE_REPEAT = 0x200,

View File

@ -17110,6 +17110,7 @@ enum TEXTURE_FLAGS {
TEXTURE_NEAREST = 0,
TEXTURE_LINEAR = 64,
TEXTURE_MIPMAPS = 128,
TEXTURE_ANISOTROPY = 1 << 30,
TEXTURE_CLAMP = 0,
TEXTURE_BORDER = 0x100,
@ -370744,6 +370745,15 @@ GLenum texture_type = t->flags & TEXTURE_ARRAY ? GL_TEXTURE_2D_ARRAY : GL_TEXTUR
glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, wrap);
glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, min_filter);
glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, mag_filter);
if (flags & TEXTURE_ANISOTROPY) {
GLfloat value, max_anisotropy = 16.0f;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &value);
value = (value > max_anisotropy) ? max_anisotropy : value;
glTexParameterf(texture_type, GL_TEXTURE_MAX_ANISOTROPY, value);
}
#if 0 // only for sampler2DShadow
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
@ -373225,7 +373235,7 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue;
// decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int invalid = texture_checker().id;
#if 1

View File

@ -730,6 +730,15 @@ GLenum texture_type = t->flags & TEXTURE_ARRAY ? GL_TEXTURE_2D_ARRAY : GL_TEXTUR
glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, wrap);
glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, min_filter);
glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, mag_filter);
if (flags & TEXTURE_ANISOTROPY) {
GLfloat value, max_anisotropy = 16.0f;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &value);
value = (value > max_anisotropy) ? max_anisotropy : value;
glTexParameterf(texture_type, GL_TEXTURE_MAX_ANISOTROPY, value);
}
#if 0 // only for sampler2DShadow
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
@ -3211,7 +3220,7 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue;
// decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int invalid = texture_checker().id;
#if 1

View File

@ -89,6 +89,7 @@ enum TEXTURE_FLAGS {
TEXTURE_NEAREST = 0,
TEXTURE_LINEAR = 64,
TEXTURE_MIPMAPS = 128,
TEXTURE_ANISOTROPY = 1 << 30,
TEXTURE_CLAMP = 0,
TEXTURE_BORDER = 0x100,

View File

@ -17886,6 +17886,15 @@ GLenum texture_type = t->flags & TEXTURE_ARRAY ? GL_TEXTURE_2D_ARRAY : GL_TEXTUR
glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, wrap);
glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, min_filter);
glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, mag_filter);
if (flags & TEXTURE_ANISOTROPY) {
GLfloat value, max_anisotropy = 16.0f;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &value);
value = (value > max_anisotropy) ? max_anisotropy : value;
glTexParameterf(texture_type, GL_TEXTURE_MAX_ANISOTROPY, value);
}
#if 0 // only for sampler2DShadow
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
if( flags & TEXTURE_DEPTH ) glTexParameteri(texture_type, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
@ -20367,7 +20376,7 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue;
// decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST
int invalid = texture_checker().id;
#if 1

View File

@ -3177,6 +3177,7 @@ enum TEXTURE_FLAGS {
TEXTURE_NEAREST = 0,
TEXTURE_LINEAR = 64,
TEXTURE_MIPMAPS = 128,
TEXTURE_ANISOTROPY = 1 << 30,
TEXTURE_CLAMP = 0,
TEXTURE_BORDER = 0x100,