Skip to content

Commit

Permalink
Menu: Add an anisotropic filtering option
Browse files Browse the repository at this point in the history
  • Loading branch information
dscharrer committed May 9, 2016
1 parent d056b6a commit 3eadc24
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/gui/MainMenu.cpp
Expand Up @@ -634,6 +634,63 @@ class VideoOptionsMenuPage : public MenuPage {
addCenter(cb);
}

{
PanelWidget * panel = new PanelWidget;
std::string szMenuText = getLocalised("system_menus_options_video_texture_filter_anisotropic",
"Anisotropic filtering");
szMenuText += " ";
TextWidget * txt = new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText, Vec2f(20, 0));
txt->SetCheckOff();
panel->AddElement(txt);

CycleTextWidget * cb = new CycleTextWidget;
cb->valueChanged = boost::bind(&VideoOptionsMenuPage::onChangedMaxAnisotropy, this, _1, _2);
szMenuText = getLocalised("system_menus_options_video_filter_anisotropic_off", "Off");
cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
int maxAnisotropy = int(GRenderer->getMaxSupportedAnisotropy());
int selected = 0;
if(maxAnisotropy > 1) {
int i = 1;
std::ostringstream oss;
for(int anisotropy = 2; ; anisotropy *= 2, i++) {
if(anisotropy > maxAnisotropy) {
anisotropy = maxAnisotropy;
}
oss.str(std::string());
oss << 'x' << anisotropy;
cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, oss.str()));
if(config.video.maxAnisotropicFiltering == anisotropy) {
selected = i;
}
if(config.video.maxAnisotropicFiltering > anisotropy
&& config.video.maxAnisotropicFiltering < anisotropy * 2
&& config.video.maxAnisotropicFiltering <= maxAnisotropy) {
oss.str(std::string());
oss << 'x' << config.video.maxAnisotropicFiltering;
cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, oss.str()));
selected = ++i;
}
if(anisotropy == maxAnisotropy) {
i++;
break;
}
}
szMenuText = getLocalised("system_menus_options_video_filter_anisotropic_max", "Unlimited");
cb->AddText(new TextWidget(BUTTON_INVALID, hFontMenu, szMenuText));
if(config.video.maxAnisotropicFiltering > maxAnisotropy) {
selected = i;
}
}
cb->setValue(selected);
cb->Move(Vec2f(RATIO_X(m_size.x-9) - cb->m_rect.width(), 0));
if(maxAnisotropy <= 1) {
cb->setEnabled(false);
}
panel->AddElement(cb);

addCenter(panel);
}

{
std::string szMenuText = getLocalised("system_menus_video_apply");
szMenuText += " ";
Expand Down Expand Up @@ -708,6 +765,23 @@ class VideoOptionsMenuPage : public MenuPage {
config.video.vsync = state ? true : false;
}

void onChangedMaxAnisotropy(int pos, const std::string & str) {
ARX_UNUSED(str);

int anisotropy = 1;
if(pos > 0) {
if(!str.empty() && str[0] == 'x') {
std::stringstream ss(str.substr(1));
ss >> anisotropy;
} else {
anisotropy = 9001;
}
}

config.video.maxAnisotropicFiltering = anisotropy;
GRenderer->setMaxAnisotropy(anisotropy);
}

void onClickedBack() {
if(pMenuSliderResol && pMenuSliderResol->getOldValue() >= 0) {
pMenuSliderResol->setValue(pMenuSliderResol->getOldValue());
Expand Down

0 comments on commit 3eadc24

Please sign in to comment.