diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 25 |
2 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 18a6f1ba73d..d75b8db2c4e 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -112,6 +112,11 @@ void GPU_set_mipmap(int mipmap); void GPU_set_linear_mipmap(int linear); void GPU_paint_set_mipmap(int mipmap); +/* Anisotropic filtering settings + * - these will free textures on changes */ +void GPU_set_anisotropic(float value); +float GPU_get_anisotropic(void); + /* Image updates and free * - these deal with images bound as opengl textures */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 7dfbc52819e..87d25ac850a 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -246,8 +246,9 @@ static struct GPUTextureState { int domipmap, linearmipmap; int alphamode; + float anisotropic; MTFace *lasttface; -} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, NULL}; +} GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, -1, 1.f, NULL}; /* Mipmap settings */ @@ -292,6 +293,26 @@ static GLenum gpu_get_mipmap_filter(int mag) } } +/* Anisotropic filtering settings */ +void GPU_set_anisotropic(float value) +{ + if (GTS.anisotropic != value) + { + GPU_free_images(); + + /* Clamp value to the maximum value the graphics card supports */ + if (value > GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT) + value = GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT; + + GTS.anisotropic = value; + } +} + +float GPU_get_anisotropic() +{ + return GTS.anisotropic; +} + /* Set OpenGL state for an MTFace */ static void gpu_make_repbind(Image *ima) @@ -559,6 +580,8 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int ima->tpageflag |= IMA_MIPMAP_COMPLETE; } + if (GLEW_EXT_texture_filter_anisotropic) + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic()); /* set to modulate with vertex color */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |