Committing patch #25676 Anisotropic filtering in viewport and BGE by me.

This patch adds anisotropic filtering of textures in the viewport and the BGE. The quality of the filtering is adjustable in the user preferences under System. For more information on anisotropic filtering:
http://en.wikipedia.org/wiki/Anisotropic_filtering

One current limitation of this setup (having the option a user preference) is it makes runtimes more troublesome. Runtimes don't have user preferences set, so for now the blender player defaults to 2x AF. Options will be added later to change this value (probably a command line option).
This commit is contained in:
2011-06-15 18:59:22 +00:00
parent 08c155845d
commit a3e296fc40
9 changed files with 67 additions and 3 deletions

View File

@@ -28,6 +28,7 @@
#define spit(x) std::cout << x << std::endl;
#include "MEM_guardedalloc.h"
#include "GPU_draw.h"
extern "C" {
// envmaps
@@ -175,6 +176,8 @@ void BL_Texture::InitGLTex(unsigned int *pix,int x,int y,bool mipmap)
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, pix );
}
if (GLEW_EXT_texture_filter_anisotropic)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
@@ -199,6 +202,9 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_RGBA, GL_UNSIGNED_BYTE, newPixels );
}
if (GLEW_EXT_texture_filter_anisotropic)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, GPU_get_anisotropic());
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
free(newPixels);
}