Skip to content

Commit

Permalink
Add a config key for anisotropic filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed Apr 26, 2015
1 parent 7e27271 commit d092d92
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/core/Config.cpp
Expand Up @@ -58,6 +58,7 @@ const std::string
const int
levelOfDetail = 2,
fogDistance = 10,
maxAnisotropicFiltering = 9001,
volume = 10,
sfxVolume = 10,
speechVolume = 10,
Expand Down Expand Up @@ -151,6 +152,7 @@ const std::string
showCrosshair = "show_crosshair",
antialiasing = "antialiasing",
vsync = "vsync",
maxAnisotropicFiltering = "max_anisotropic_filtering",
colorkeyAlphaToCoverage = "colorkey_alpha_to_coverage";

// Window options
Expand Down Expand Up @@ -372,6 +374,7 @@ bool Config::save() {
writer.writeKey(Key::showCrosshair, video.showCrosshair);
writer.writeKey(Key::antialiasing, video.antialiasing);
writer.writeKey(Key::vsync, video.vsync);
writer.writeKey(Key::maxAnisotropicFiltering, video.maxAnisotropicFiltering);
writer.writeKey(Key::colorkeyAlphaToCoverage, video.colorkeyAlphaToCoverage);

// window
Expand Down Expand Up @@ -460,6 +463,8 @@ bool Config::init(const fs::path & file) {
video.showCrosshair = reader.getKey(Section::Video, Key::showCrosshair, Default::showCrosshair);
video.antialiasing = reader.getKey(Section::Video, Key::antialiasing, Default::antialiasing);
video.vsync = reader.getKey(Section::Video, Key::vsync, Default::vsync);
video.maxAnisotropicFiltering = reader.getKey(Section::Video, Key::maxAnisotropicFiltering, Default::maxAnisotropicFiltering);
video.maxAnisotropicFiltering = std::max(1, video.maxAnisotropicFiltering);
video.colorkeyAlphaToCoverage = reader.getKey(Section::Video, Key::colorkeyAlphaToCoverage, Default::colorkeyAlphaToCoverage);

// Get window settings
Expand Down
1 change: 1 addition & 0 deletions src/core/Config.h
Expand Up @@ -116,6 +116,7 @@ class Config {
bool showCrosshair;
bool antialiasing;
bool vsync;
int maxAnisotropicFiltering;
bool colorkeyAlphaToCoverage;

} video;
Expand Down
4 changes: 3 additions & 1 deletion src/graphics/opengl/OpenGLRenderer.cpp
Expand Up @@ -253,7 +253,9 @@ void OpenGLRenderer::reinit() {
}

if(GLEW_EXT_texture_filter_anisotropic) {
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnisotropy);
GLfloat limit;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &limit);
maximumAnisotropy = std::min(float(config.video.maxAnisotropicFiltering), limit);
}

onRendererInit();
Expand Down

0 comments on commit d092d92

Please sign in to comment.