void set_slider_value(int idc, int mi, int ma, float v) { CDXUTSlider* slider = dynamic_cast<CDXUTSlider*>(find_control(idc)); if (mi == 0 && ma == 0) slider->GetRange(mi, ma); int iv = static_cast<int>(v * (ma - mi)); slider->SetValue(iv); }
float slider_value(int idc, int mi, int ma) { CDXUTSlider* slider = dynamic_cast<CDXUTSlider*>(find_control(idc)); float v = static_cast<float>(slider->GetValue()); if (mi == 0 && ma == 0) slider->GetRange(mi, ma); v /= static_cast<float>(ma - mi); return v; }
void CALLBACK onGUIEvent(UINT event, int controlId, CDXUTControl* control, void *userContext) { switch(controlId) { case IDC_TOGGLE_FULLSCREEN: DXUTToggleFullScreen(); break; case IDC_PRESET: if (event == EVENT_COMBOBOX_SELECTION_CHANGED) { SMAA::Preset selected; selected = SMAA::Preset(int(hud.GetComboBox(IDC_PRESET)->GetSelectedData())); onLostDevice(NULL); onResetDevice(DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL); } break; case IDC_ANTIALIASING: if (event == EVENT_CHECKBOX_CHANGED) timer->reset(); break; case IDC_PROFILE: if (event == EVENT_CHECKBOX_CHANGED) { timer->reset(); timer->setEnabled(hud.GetCheckBox(IDC_PROFILE)->GetChecked()); } break; case IDC_THRESHOLD: if (event == EVENT_SLIDER_VALUE_CHANGED) { CDXUTSlider *slider = hud.GetSlider(IDC_THRESHOLD); int min, max; slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); smaa->setThreshold(scale * 0.5f); wstringstream s; s << L"Threshold: " << scale * 0.5f; hud.GetStatic(IDC_THRESHOLD_LABEL)->SetText(s.str().c_str()); } break; case IDC_MAX_SEARCH_STEPS: if (event == EVENT_SLIDER_VALUE_CHANGED) { CDXUTSlider *slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS); int min, max; slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); smaa->setMaxSearchSteps(int(round(scale * 98.0f))); wstringstream s; s << L"Max Search Steps: " << int(round(scale * 98.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_LABEL)->SetText(s.str().c_str()); } break; case IDC_MAX_SEARCH_STEPS_DIAG: if (event == EVENT_SLIDER_VALUE_CHANGED) { CDXUTSlider *slider = hud.GetSlider(IDC_MAX_SEARCH_STEPS_DIAG); int min, max; slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); smaa->setMaxSearchStepsDiag(int(round(scale * 20.0f))); wstringstream s; s << L"Max Diag. Search Steps: " << int(round(scale * 20.0f)); hud.GetStatic(IDC_MAX_SEARCH_STEPS_DIAG_LABEL)->SetText(s.str().c_str()); } break; case IDC_CORNER_ROUNDING: if (event == EVENT_SLIDER_VALUE_CHANGED) { CDXUTSlider *slider = hud.GetSlider(IDC_CORNER_ROUNDING); int min, max; slider->GetRange(min, max); float scale = float(slider->GetValue()) / (max - min); smaa->setCornerRounding(scale * 100.0f); wstringstream s; s << L"Corner Rounding: " << scale * 100.0f; hud.GetStatic(IDC_CORNER_ROUNDING_LABEL)->SetText(s.str().c_str()); } break; } }