//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { CDXUTComboBox* pComboBox = NULL; CDXUTComboBox* pAABBLevelComboBox = NULL; switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_SCENERASTERIZER_MODE: //CDXUTComboBox* pComboBox = NULL; pComboBox = ( CDXUTComboBox* )pControl; g_eSceneRasterizerMode = ( UINT )PtrToInt( pComboBox->GetSelectedData() ); break; case IDC_AABBSUBLEVEL: pAABBLevelComboBox = ( CDXUTComboBox* )pControl; g_CurrentAABBLevel = ( UINT )PtrToInt( pAABBLevelComboBox->GetSelectedData() ); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_DISABLEALBEDO: g_DisableAlbedo = ((CDXUTCheckBox*)pControl )->GetChecked(); break; case IDC_PAUSEANIMATION: g_PauseAnimation = ((CDXUTCheckBox*)pControl )->GetChecked(); break; case IDC_SHOWNORMALS: g_ShowNormals = ((CDXUTCheckBox*)pControl )->GetChecked(); break; case IDC_DISABLESKINING: g_DisableSkining = ((CDXUTCheckBox*)pControl )->GetChecked(); break; case IDC_TECHNIQUECOMBO: g_TechniqueIndex = ((CDXUTComboBox* )pControl)->GetSelectedIndex(); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_TOGGLESPIN: { g_bSpinning = g_SampleUI.GetCheckBox( IDC_TOGGLESPIN )->GetChecked(); break; } case IDC_EXPLODE_SCALE: { WCHAR sz[100]; g_fExplode = ( float )( g_SampleUI.GetSlider( IDC_EXPLODE_SCALE )->GetValue() * 0.01f ); swprintf_s( sz, 100, L"Explode Amount: %0.2f", g_fExplode ); g_SampleUI.GetStatic( IDC_EXPLODE_STATIC )->SetText( sz ); g_pExplodeVariable->SetFloat( g_fExplode ); break; } } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { if( g_bGuiVisible ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_SUNWIDTH_SLIDER: WCHAR temp[64]; int iVal = g_HUD.GetSlider( IDC_SUNWIDTH_SLIDER )->GetValue(); g_fSunWidth = ( float( iVal ) / 100.0f ) * 3.0f; swprintf_s( temp, L"SunWidth = %2.2f", g_fSunWidth ); g_HUD.GetStatic( IDC_SUNWIDTH_TEXT )->SetText( temp ); break; } } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_SHOWTESSELLATED: g_bShowTessellated = !g_bShowTessellated; break; case IDC_PARTITIONING_INTEGER: g_Tessellator.SetPartitioningMode( CTessellator::PARTITIONING_MODE_INTEGER ); break; case IDC_PARTITIONING_POW2: g_Tessellator.SetPartitioningMode( CTessellator::PARTITIONING_MODE_POW2 ); break; case IDC_PARTITIONING_FRACTIONAL_ODD: g_Tessellator.SetPartitioningMode( CTessellator::PARTITIONING_MODE_FRACTIONAL_ODD ); break; case IDC_PARTITIONING_FRACTIONAL_EVEN: g_Tessellator.SetPartitioningMode( CTessellator::PARTITIONING_MODE_FRACTIONAL_EVEN ); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_TOGGLE_BLUR: g_bUseMotionBlur = !g_bUseMotionBlur; break; case IDC_RENDER_OGRE: g_bRenderOgre = !g_bRenderOgre; break; case IDC_SAMPLE_COUNT: { CDXUTComboBox* pComboBox = ( CDXUTComboBox* )pControl; g_MSAASampleCount = ( UINT )PtrToInt( pComboBox->GetSelectedData() ); HRESULT hr = S_OK; ID3D10Device* pd3dDevice = DXUTGetD3D10Device(); if( pd3dDevice ) V( CreateRenderTarget( pd3dDevice, g_BackBufferWidth, g_BackBufferHeight, g_MSAASampleCount, 0 ) ); } break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_ENABLE_PRESHADER: { g_bEnablePreshader = g_SampleUI.GetCheckBox( IDC_ENABLE_PRESHADER )->GetChecked(); if( DXUTGetD3D9Device() != NULL ) { OnLostDevice( NULL ); OnDestroyDevice( NULL ); OnCreateDevice( DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL ); OnResetDevice( DXUTGetD3D9Device(), DXUTGetD3D9BackBufferSurfaceDesc(), NULL ); } break; } case IDC_ACTIVE_LIGHT: if( !g_LightControl[g_nActiveLight].IsBeingDragged() ) { g_nActiveLight++; g_nActiveLight %= g_nNumActiveLights; } break; case IDC_NUM_LIGHTS: if( !g_LightControl[g_nActiveLight].IsBeingDragged() ) { WCHAR sz[100]; swprintf_s( sz, 100, L"# Lights: %d", g_SampleUI.GetSlider( IDC_NUM_LIGHTS )->GetValue() ); g_SampleUI.GetStatic( IDC_NUM_LIGHTS_STATIC )->SetText( sz ); g_nNumActiveLights = g_SampleUI.GetSlider( IDC_NUM_LIGHTS )->GetValue(); g_nActiveLight %= g_nNumActiveLights; } break; case IDC_LIGHT_SCALE: g_fLightScale = ( float )( g_SampleUI.GetSlider( IDC_LIGHT_SCALE )->GetValue() * 0.10f ); WCHAR sz[100]; swprintf_s( sz, 100, L"Light scale: %0.2f", g_fLightScale ); g_SampleUI.GetStatic( IDC_LIGHT_SCALE_STATIC )->SetText( sz ); break; } }
void CALLBACK KeyboardProc(UINT nChar,bool bKeyDown,bool bAltDown,void *pUserContext) { if(keyPressTime<=0.0f) { if(nChar=='F') DXUTToggleFullScreen(); //else if(nChar-'0'<MAX_MESH_LODS) // g_pSceneManager->getMesh("meshName")->setLOD(false,nChar-'0'); keyPressTime=KEY_INTERNAL_TIME; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_BUTTON_1: { MessageBox( NULL, L"Button 1 pressed...", L"HUD", MB_OK); };break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_PAUSESIMULATION: FLUID->Pause( g_pHUD->GetCheckBox( IDC_PAUSESIMULATION )->GetChecked() ); break; case IDC_PAUSESIMULATIONONSTEP600: FLUID->PauseOnStep( (g_pHUD->GetCheckBox( IDC_PAUSESIMULATIONONSTEP600 )->GetChecked())? 600 : 0xFFFFFFFF ); break; case IDC_SIMULATIONSIZE: // fallthrough case IDC_RESETSIMULATION: FLUID->Fill( g_pHUD->GetSlider( IDC_SIMULATIONSIZE )->GetValue() / 10.0f ); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent(UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext) { switch (nControlID) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive()); break; case IDC_DIFF_STEPS: g_vsObj->diffSteps = g_SampleUI.GetSlider(IDC_DIFF_STEPS)->GetValue(); WCHAR sz[100]; StringCchPrintf(sz, 100, L"Diffusion steps: %d", g_vsObj->diffSteps); g_SampleUI.GetStatic(IDC_DIFF_STEPS_STATIC)->SetText(sz); break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_TOGGLERESIDENCYVIEWS: g_bDrawResidencySampleViews = !g_bDrawResidencySampleViews; break; case IDC_TOGGLETERRAINVIEW: g_bDrawTerrain = !g_bDrawTerrain; break; case IDC_PAUSESTREAMING: g_bPauseStreaming = !g_bPauseStreaming; break; } }
void CALLBACK OnGUIEvent(UINT eventID, INT controlID, CDXUTControl* control, void* userContext) { switch (controlID) { case UI_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case UI_TOGGLEWARP: DXUTToggleWARP(); break; case UI_CHANGEDEVICE: gD3DSettingsDlg.SetActive(!gD3DSettingsDlg.IsActive()); break; case UI_LIGHTINGONLY: gUIConstants.lightingOnly = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break; case UI_FACENORMALS: gUIConstants.faceNormals = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break; case UI_VISUALIZELIGHTCOUNT: gUIConstants.visualizeLightCount = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break; case UI_VISUALIZEPERSAMPLESHADING: gUIConstants.visualizePerSampleShading = dynamic_cast<CDXUTCheckBox*>(control)->GetChecked(); break; case UI_SELECTEDSCENE: DestroyScene(); break; case UI_LIGHTS: gApp->SetActiveLights(DXUTGetD3D11Device(), 1 << gLightsSlider->GetValue()); break; case UI_CULLTECHNIQUE: gUIConstants.lightCullTechnique = static_cast<unsigned int>(PtrToUlong(gCullTechniqueCombo->GetSelectedData())); break; // These controls all imply changing parameters to the App constructor // (i.e. recreating resources and such), so we'll just clean up the app here and let it be // lazily recreated next render. case UI_MSAA: DestroyApp(); break; default: break; } UpdateUIState(); }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { WCHAR wszOutput[1024]; switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break; case IDC_ENABLEIME: CDXUTIMEEditBox::SetImeEnableFlag( true ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( L"You clicked the 'Enable IME' button.\nIME text input is enabled for IME-capable edit controls." ); break; case IDC_DISABLEIME: CDXUTIMEEditBox::SetImeEnableFlag( false ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( L"You clicked the 'Disable IME' button.\nIME text input is disabled for IME-capable edit controls." ); break; case IDC_EDITBOX1: case IDC_EDITBOX2: switch( nEvent ) { case EVENT_EDITBOX_STRING: { swprintf_s( wszOutput, 1024, L"You have pressed Enter in edit control (ID %u).\nThe content of the edit control is:\n\"%s\"", nControlID, ( ( CDXUTEditBox* )pControl )->GetText() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); // Clear the text if needed if( g_SampleUI.GetCheckBox( IDC_CLEAREDIT )->GetChecked() ) ( ( CDXUTEditBox* )pControl )->SetText( L"" ); break; } case EVENT_EDITBOX_CHANGE: { swprintf_s( wszOutput, 1024, L"You have changed the content of an edit control (ID %u).\nIt is now:\n\"%s\"", nControlID, ( ( CDXUTEditBox* )pControl )->GetText() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; } } break; case IDC_SLIDER: swprintf_s( wszOutput, 1024, L"You adjusted the slider control.\nThe new value reported is %d", ( ( CDXUTSlider* )pControl )->GetValue() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; case IDC_CHECKBOX: swprintf_s( wszOutput, 1024, L"You %s the upper check box.", ( ( CDXUTCheckBox* )pControl )->GetChecked() ? L"checked" : L"cleared" ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; case IDC_CLEAREDIT: swprintf_s( wszOutput, 1024, L"You %s the lower check box.\nNow edit controls will %s", ( ( CDXUTCheckBox* )pControl )->GetChecked() ? L"checked" : L"cleared", ( ( CDXUTCheckBox* )pControl )->GetChecked() ? L"be cleared when you press Enter to send the text" : L"retain the text context when you press Enter to send the text" ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; case IDC_COMBOBOX: { DXUTComboBoxItem* pItem = ( ( CDXUTComboBox* )pControl )->GetSelectedItem(); if( pItem ) { swprintf_s( wszOutput, 1024, L"You selected a new item in the combobox.\nThe new item is \"%s\" and the associated data value is 0x%p", pItem->strText, pItem->pData ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); } break; } case IDC_RADIO1A: case IDC_RADIO1B: case IDC_RADIO1C: swprintf_s( wszOutput, 1024, L"You selected a new radio button in the UPPER radio group.\nThe new button is \"%s\"", ( ( CDXUTRadioButton* )pControl )->GetText() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; case IDC_RADIO2A: case IDC_RADIO2B: case IDC_RADIO2C: swprintf_s( wszOutput, 1024, L"You selected a new radio button in the LOWER radio group.\nThe new button is \"%s\"", ( ( CDXUTRadioButton* )pControl )->GetText() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; case IDC_LISTBOX: switch( nEvent ) { case EVENT_LISTBOX_ITEM_DBLCLK: { DXUTListBoxItem* pItem = ( ( CDXUTListBox* )pControl )->GetItem( ( ( CDXUTListBox* )pControl )->GetSelectedIndex( -1 ) ); swprintf_s( wszOutput, 1024, L"You double clicked an item in the left list box. The item is\n\"%s\"", pItem ? pItem->strText : L"" ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; } case EVENT_LISTBOX_SELECTION: { swprintf_s( wszOutput, 1024, L"You changed the selection in the left list box. The selected item is %d", ( ( CDXUTListBox* )pControl )->GetSelectedIndex() ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; } } break; case IDC_LISTBOXM: switch( nEvent ) { case EVENT_LISTBOX_ITEM_DBLCLK: { DXUTListBoxItem* pItem = ( ( CDXUTListBox* )pControl )->GetItem( ( ( CDXUTListBox* )pControl )->GetSelectedIndex( -1 ) ); swprintf_s( wszOutput, 1024, L"You double clicked an item in the right list box. The item is\n\"%s\"", pItem ? pItem->strText : L"" ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; } case EVENT_LISTBOX_SELECTION: { swprintf_s( wszOutput, 1024, L"You changed the selection in the right list box. The selected item(s) are\n" ); int nSelected = -1; while( ( nSelected = ( ( CDXUTListBox* )pControl )->GetSelectedIndex( nSelected ) ) != -1 ) { swprintf_s( wszOutput + lstrlenW( wszOutput ), 1024 - lstrlenW( wszOutput ), L"%d,", nSelected ); } // Remove the trailing comma if one exists. if( wszOutput[lstrlenW( wszOutput ) - 1] == L',' ) wszOutput[lstrlenW( wszOutput ) - 1] = L'\0'; g_SampleUI.GetStatic( IDC_OUTPUT )->SetText( wszOutput ); break; } } break; } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent(UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext) { switch (nControlID) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: { g_SettingsDlg.SetActive(!g_SettingsDlg.IsActive()); break; } case IDC_CHANGESCENE: { CDXUTComboBox* pComboBox = (CDXUTComboBox*) pControl; g_CurrentSceneId = pComboBox->GetSelectedIndex(); break; } case IDC_BLUR_AO: { g_BlurAO = g_HUD.GetCheckBox(nControlID)->GetChecked(); break; } case IDC_DEINTERLEAVE: { g_UseDeinterleavedTexturing = g_HUD.GetCheckBox(nControlID)->GetChecked(); break; } case IDC_RANDOMIZE: { g_RandomizeSamples = g_HUD.GetCheckBox(nControlID)->GetChecked(); break; } case IDC_RADIUS_SLIDER: { g_AOParams.Radius = (float) g_HUD.GetSlider(IDC_RADIUS_SLIDER)->GetValue() * MAX_RADIUS_MULT / 100.0f; WCHAR sz[100]; StringCchPrintf(sz, 100, UI_RADIUS_MULT L"%0.2f", g_AOParams.Radius); g_HUD.GetStatic(IDC_RADIUS_STATIC)->SetText(sz); break; } case IDC_BIAS_SLIDER: { g_AOParams.Bias = (float) g_HUD.GetSlider(IDC_BIAS_SLIDER)->GetValue() / 1000.f; WCHAR sz[100]; StringCchPrintf(sz, 100, UI_AO_BIAS L"%g", g_AOParams.Bias); g_HUD.GetStatic(IDC_BIAS_STATIC)->SetText(sz); break; } case IDC_EXPONENT_SLIDER: { g_AOParams.PowerExponent = (float)g_HUD.GetSlider(IDC_EXPONENT_SLIDER)->GetValue() / 100.0f; WCHAR sz[100]; StringCchPrintf(sz, 100, UI_POW_EXPONENT L"%0.2f", g_AOParams.PowerExponent); g_HUD.GetStatic(IDC_EXPONENT_STATIC)->SetText(sz); break; } case IDC_BLUR_SHARPNESS_SLIDER: { g_AOParams.Blur.Sharpness = (float)g_HUD.GetSlider(IDC_BLUR_SHARPNESS_SLIDER)->GetValue() / 100.0f; WCHAR sz[100]; StringCchPrintf(sz, 100, UI_BLUR_SHARPNESS L"%0.2f", g_AOParams.Blur.Sharpness); g_HUD.GetStatic(IDC_BLUR_SHARPNESS_STATIC)->SetText(sz); break; } case IDC_PER_PIXEL_AO: { g_AOParams.Output.MSAAMode = GFSDK_SSAO_PER_PIXEL_AO; break; } case IDC_PER_SAMPLE_AO: { g_AOParams.Output.MSAAMode = GFSDK_SSAO_PER_SAMPLE_AO; break; } case IDC_1xMSAA: case IDC_2xMSAA: case IDC_4xMSAA: case IDC_8xMSAA: { g_RenderTargetsDirty = true; g_MSAACurrentSettings = nControlID - IDC_1xMSAA; assert(g_MSAACurrentSettings >= MSAA_MODE_1X); assert(g_MSAACurrentSettings <= MSAA_MODE_8X); break; } } }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive( !g_D3DSettingsDlg.IsActive() ); break; case IDC_DISPLACEMENTLVL: { displacement_level = g_SampleUI.GetSlider( IDC_DISPLACEMENTLVL )->GetValue()/ 100.0f; tessplane.setdislvl(displacement_level); WCHAR sz[100]; swprintf_s( sz, L"Displacement Level: %2.1f", displacement_level ); g_SampleUI.GetStatic( IDC_DISPLACEMENTLVL_STATIC )->SetText( sz ); } break; case IDC_TESSLVL: { tess_lvl = g_SampleUI.GetSlider( IDC_TESSLVL )->GetValue(); tessplane.setTesslvl(tess_lvl); tesscube.set_tesslvl(tess_lvl); fuse.set_tesslvl(tess_lvl); WCHAR sz[100]; swprintf_s( sz, L"Tesselation Level: %2.1f", tess_lvl ); g_SampleUI.GetStatic( IDC_TESSLVL_STATIC )->SetText( sz ); } break; case IDC_TOGGLEBUILDING: show_buildings = g_SampleUI.GetCheckBox( IDC_TOGGLEBUILDING )->GetChecked(); break; case IDC_TOGGLEWIRE: tessplane.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked()); tesscube.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked()); fuse.toggleWire(g_SampleUI.GetCheckBox( IDC_TOGGLEWIRE )->GetChecked()); break; case IDC_TOGGLEDT: tessplane.toggleDT(g_SampleUI.GetCheckBox( IDC_TOGGLEDT )->GetChecked()); break; case IDC_PARTITION_INTEGER: tessplane.settessmethod(0); tesscube.settessmethod(0); fuse.settessmethod(0); break; case IDC_PARTITION_FRAC_EVEN: tessplane.settessmethod(1); tesscube.settessmethod(1); fuse.settessmethod(1); break; case IDC_PARTITION_FRAC_ODD: tesscube.settessmethod(2); tessplane.settessmethod(2); fuse.settessmethod(2); break; } }
void CALLBACK OnGUIEvent(UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext) { switch(nControlID) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEREF: DXUTToggleREF(); break; case IDC_HIDECONSOLE: NsConsole::Instance()->Toogle(); break; case IDC_RESETGAME: if(!g_Board.pRenjuGame->bGameIsFinished) { g_Board.Finish(); NsConsole::Instance()->AddMessage("The game was finished mannualy"); g_HUD.GetButton(IDC_RESETGAME)->SetText(L"Start"); g_SampleUI.GetRadioButton(IDC_GAMEMODE_HUMAN_HUMAN_RADIO)->SetVisible(true); g_SampleUI.GetRadioButton(IDC_GAMEMODE_AI_IS_BLACK_RADIO)->SetVisible(true); g_SampleUI.GetRadioButton(IDC_GAMEMODE_AI_IS_WHITE_RADIO)->SetVisible(true); } else { g_Board.Start(); g_HUD.GetButton(IDC_RESETGAME)->SetText(L"Finish"); g_SampleUI.GetRadioButton(IDC_GAMEMODE_HUMAN_HUMAN_RADIO)->SetVisible(false); g_SampleUI.GetRadioButton(IDC_GAMEMODE_AI_IS_BLACK_RADIO)->SetVisible(false); g_SampleUI.GetRadioButton(IDC_GAMEMODE_AI_IS_WHITE_RADIO)->SetVisible(false); } break; case IDC_GAMEMODE_HUMAN_HUMAN_RADIO: g_Board.pRenjuGame->SetNsGameMode(NsGameMode::Human_Human); break; case IDC_GAMEMODE_AI_IS_BLACK_RADIO: g_Board.pRenjuGame->SetNsGameMode(NsGameMode::AI_Black); break; case IDC_GAMEMODE_AI_IS_WHITE_RADIO: g_Board.pRenjuGame->SetNsGameMode(NsGameMode::AI_White); break; case IDC_LAUNCH_RENJU_MANUAL: HINSTANCE hiResult = ShellExecute( NULL, L"open", (NsD3DResourceManager::Instance()->GetAbsoluteContentFolderPath() + L"/Other/renju_manual.pdf").c_str(), NULL, NULL, SW_SHOWNORMAL); if((int)hiResult > 32) { NsConsole::Instance()->AddMessage("The manual was shown"); } else { NsConsole::Instance()->AddMessage("Warning! Fail to show manual"); } break; } }
// Handles the GUI events void CALLBACK OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext ) { switch( nControlID ) { case IDC_TOGGLEFULLSCREEN: { DXUTToggleFullScreen(); break; } case IDC_TOGGLEREF: { DXUTToggleREF(); break; } case IDC_CHANGEDEVICE: { gD3DSettingsDlg.SetActive( !gD3DSettingsDlg.IsActive() ); break; } case IDC_TEXT: case IDC_EXPOSURE: { gLog2Exposure = (gSampleUI.GetSlider(IDC_EXPOSURE)->GetValue() / 100.0f - 0.5f) * 33.33333; WCHAR wstr[MAX_PATH]; swprintf_s(wstr, MAX_PATH, L"Texture Size: %d x %d\n" L"logRGB L1: %.2f%%\n" //L"logRGB RMSE: %.4f\n" //L"Relative error: %.2f%%\n" //L"mPSNR: %.2f%%\n" L"Exposure: %.2f\n" L"Compression Time: %0.2f ms\n" L"Compression Rate: %0.2f Mp/s\n", gTexWidth, gTexHeight, gError, gLog2Exposure, gCompTime, gCompRate); gSampleUI.GetStatic(IDC_TEXT)->SetText(wstr); break; } case IDC_MT: { // Shut down all previous threading abilities. DestroyThreads(); gMultithreaded = gSampleUI.GetCheckBox(IDC_MT)->GetChecked(); if (gMultithreaded) { InitWin32Threads(); } // Recompress the texture. RecompressTexture(); gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT)); break; } case IDC_PROFILE: { gCompressionFunc = (CompressionFunc*)gSampleUI.GetComboBox(IDC_PROFILE)->GetSelectedData(); // Recompress the texture. RecompressTexture(); gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT)); break; } case IDC_LOAD_TEXTURE: { // Store the current working directory. TCHAR workingDirectory[MAX_PATH]; GetCurrentDirectory(MAX_PATH, workingDirectory); // Open a file dialog. OPENFILENAME openFileName; WCHAR file[MAX_PATH]; file[0] = 0; ZeroMemory(&openFileName, sizeof(OPENFILENAME)); openFileName.lStructSize = sizeof(OPENFILENAME); openFileName.lpstrFile = file; openFileName.nMaxFile = MAX_PATH; openFileName.lpstrFilter = L"DDS\0*.dds\0\0"; openFileName.nFilterIndex = 1; openFileName.lpstrInitialDir = NULL; openFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; if(GetOpenFileName(&openFileName)) { //CreateTextures(openFileName.lpstrFile); SAFE_RELEASE(gUncompressedSRV); LoadTexture(openFileName.lpstrFile); } // Restore the working directory. GetOpenFileName changes the current working directory which causes problems with relative paths to assets. SetCurrentDirectory(workingDirectory); RecompressTexture(); gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT)); break; } case IDC_RECOMPRESS: { // Recompress the texture. RecompressTexture(); gSampleUI.SendEvent(IDC_TEXT, true, gSampleUI.GetStatic(IDC_TEXT)); break; } case IDC_SAVE_TEXTURE: { // Store the current working directory. TCHAR workingDirectory[MAX_PATH]; GetCurrentDirectory(MAX_PATH, workingDirectory); // Open a file dialog. OPENFILENAME openFileName; WCHAR file[MAX_PATH]; file[0] = 0; ZeroMemory(&openFileName, sizeof(OPENFILENAME)); openFileName.lStructSize = sizeof(OPENFILENAME); openFileName.lpstrFile = file; openFileName.nMaxFile = MAX_PATH; openFileName.lpstrFilter = L"DDS\0*.dds\0\0"; openFileName.lpstrDefExt = L"dds"; openFileName.nFilterIndex = 1; openFileName.lpstrInitialDir = NULL; openFileName.Flags = OFN_PATHMUSTEXIST; if(GetSaveFileName(&openFileName)) { SaveTexture(gCompressedSRV,openFileName.lpstrFile); } // Restore the working directory. GetOpenFileName changes the current working directory which causes problems with relative paths to assets. SetCurrentDirectory(workingDirectory); break; } case IDC_IMAGEVIEW: { gImageView = (EImageView)(INT_PTR)gSampleUI.GetComboBox(IDC_IMAGEVIEW)->GetSelectedData(); break; } } }
void RenderWin32DX9Imp::toggleFullScreen() { DXUTToggleFullScreen(); }
//-------------------------------------------------------------------------------------- // Handles the GUI events //-------------------------------------------------------------------------------------- void CALLBACK OnGUIEvent(UINT nEvent, INT nControlID, CDXUTControl* /*pControl*/, void* /*pUserContext*/) { switch (nControlID) { case IDC_TOGGLEFULLSCREEN: DXUTToggleFullScreen(); break; case IDC_TOGGLEWARP: DXUTToggleWARP(); break; case IDC_CHANGEDEVICE: g_D3DSettingsDlg.SetActive(!g_D3DSettingsDlg.IsActive()); break; break; break; case IDC_FIT_TO_CASCADE: g_CascadedShadow.m_eSelectedCascadesFit = (FIT_PROJECTION_TO_CASCADES)PtrToUlong(g_FitToCascadesCombo->GetSelectedData()); break; case IDC_FIT_TO_NEARFAR: { g_CascadedShadow.m_eSelectedNearFarFit = (FIT_TO_NEAR_FAR)PtrToUlong(g_FitToNearFarCombo->GetSelectedData()); if (g_CascadedShadow.m_eSelectedNearFarFit == FIT_NEARFAR_PANCAKING) { g_CascadedShadow.m_eSelectedCascadeSelection = CASCADE_SELECTION_INTERVAL; g_CascadeSelectionCombo->SetSelectedByData(ULongToPtr(CASCADE_SELECTION_INTERVAL)); } } break; case IDC_CASCADE_SELECT: { static int iSaveLastCascadeValue = 100; if ((CASCADE_SELECTION)PtrToUlong(g_CascadeSelectionCombo->GetSelectedData()) == CASCADE_SELECTION_MAP) { if ((FIT_TO_NEAR_FAR)PtrToUlong(g_FitToNearFarCombo->GetSelectedData()) == FIT_NEARFAR_PANCAKING) { g_FitToNearFarCombo->SetSelectedByData(ULongToPtr(FIT_NEARFAR_SCENE_AABB)); g_CascadedShadow.m_eSelectedNearFarFit = FIT_NEARFAR_SCENE_AABB; } g_CascadedShadow.m_iCascadePartitionsZeroToOne[g_CascadeConfig.m_nCascadeLevels - 1] = iSaveLastCascadeValue; } else { iSaveLastCascadeValue = g_CascadedShadow.m_iCascadePartitionsZeroToOne[g_CascadeConfig.m_nCascadeLevels - 1]; g_CascadedShadow.m_iCascadePartitionsZeroToOne[g_CascadeConfig.m_nCascadeLevels - 1] = 100; } g_CascadedShadow.m_eSelectedCascadeSelection = (CASCADE_SELECTION)PtrToUlong(g_CascadeSelectionCombo->GetSelectedData()); g_HUD.GetSlider(IDC_CASCADELEVEL1 + g_CascadeConfig.m_nCascadeLevels - 1)->SetValue( g_CascadedShadow.m_iCascadePartitionsZeroToOne[g_CascadeConfig.m_nCascadeLevels - 1]); WCHAR label[16]; swprintf_s(label, L"L%d: %d", g_CascadeConfig.m_nCascadeLevels, g_CascadedShadow.m_iCascadePartitionsZeroToOne[g_CascadeConfig.m_nCascadeLevels - 1]); g_HUD.GetStatic(IDC_CASCADELEVEL1TEXT + g_CascadeConfig.m_nCascadeLevels - 1)->SetText(label); } break; case IDC_MOVE_LIGHT_IN_TEXEL_INC: g_bMoveLightTexelSize = !g_bMoveLightTexelSize; g_CascadedShadow.m_bMoveLightTexelSize = g_bMoveLightTexelSize; break; case IDC_TOGGLEVISUALIZECASCADES: g_bVisualizeCascades = !g_bVisualizeCascades; break; case IDC_PCF_SIZE: { INT PCFSize = g_HUD.GetSlider(IDC_PCF_SIZE)->GetValue(); PCFSize *= 2; PCFSize -= 1; WCHAR desc[256]; swprintf_s(desc, L"PCF Blur: %d ", PCFSize); g_HUD.GetStatic(IDC_PCF_SIZETEXT)->SetText(desc); g_CascadedShadow.m_iPCFBlurSize = PCFSize; } break; case IDC_PCF_OFFSET_SIZE: { INT offset = g_HUD.GetSlider(IDC_PCF_OFFSET_SIZE)->GetValue(); FLOAT useoffset = (FLOAT)offset * 0.001f; WCHAR desc[256]; swprintf_s(desc, L" Offset: %0.03f", useoffset); g_HUD.GetStatic(IDC_PCF_OFFSET_SIZETEXT)->SetText(desc); g_CascadedShadow.m_fPCFOffset = useoffset; } break; case IDC_BLEND_BETWEEN_MAPS_CHECK: if (g_HUD.GetCheckBox(IDC_BLEND_BETWEEN_MAPS_CHECK)->GetChecked()) g_CascadedShadow.m_iBlurBetweenCascades = 1; else g_CascadedShadow.m_iBlurBetweenCascades = 0; break; case IDC_BLEND_MAPS_SLIDER: { INT val = g_HUD.GetSlider(IDC_BLEND_MAPS_SLIDER)->GetValue(); g_CascadedShadow.m_fBlurBetweenCascadesAmount = (float)val * 0.005f; WCHAR dta[256]; swprintf_s(dta, L"Cascade Blur %0.03f", g_CascadedShadow.m_fBlurBetweenCascadesAmount); g_HUD.GetCheckBox(IDC_BLEND_BETWEEN_MAPS_CHECK)->SetText(dta); } break; case IDC_TOGGLE_DERIVATIVE_OFFSET: { if (g_CascadedShadow.m_iDerivativeBasedOffset == 0) g_CascadedShadow.m_iDerivativeBasedOffset = 1; else g_CascadedShadow.m_iDerivativeBasedOffset = 0; } break; case IDC_BUFFER_SIZE: { INT value = 32 * g_HUD.GetSlider(IDC_BUFFER_SIZE)->GetValue(); INT max = 8192 / g_CascadeConfig.m_nCascadeLevels; if (value > max) { value = max; g_HUD.GetSlider(IDC_BUFFER_SIZE)->SetValue(value / 32); } WCHAR desc[256]; swprintf_s(desc, L"Texture Size: %d ", value); g_HUD.GetStatic(IDC_BUFFER_SIZETEXT)->SetText(desc); //Only tell the app to recreate buffers once the user is through moving the slider. if (nEvent == EVENT_SLIDER_VALUE_CHANGED_UP) { g_CascadeConfig.m_iBufferSize = value; } } break; case IDC_SELECTED_SCENE: { SCENE_SELECTION ss = (SCENE_SELECTION)PtrToUlong(g_SceneSelectCombo->GetSelectedData()); if (ss == POWER_PLANT_SCENE) { g_pSelectedMesh = &g_MeshPowerPlant; } else if (ss == TEST_SCENE) { g_pSelectedMesh = &g_MeshTestScene; } DestroyD3DComponents(); CreateD3DComponents(DXUTGetD3D11Device()); UpdateViewerCameraNearFar(); } case IDC_SELECTED_CAMERA: { g_CascadedShadow.m_eSelectedCamera = (CAMERA_SELECTION) (g_CameraSelectCombo->GetSelectedIndex()); if (g_CascadedShadow.m_eSelectedCamera < 1) { g_pActiveCamera = &g_ViewerCamera; } else { g_pActiveCamera = &g_LightCamera; } } break; case IDC_CASCADELEVELS: { INT ind = 1 + g_CascadeLevelsCombo->GetSelectedIndex(); g_CascadeConfig.m_nCascadeLevels = ind; for (INT index = 0; index < ind; ++index) { g_HUD.GetStatic(IDC_CASCADELEVEL1TEXT + index)->SetVisible(true); g_HUD.GetSlider(IDC_CASCADELEVEL1 + index)->SetVisible(true); } for (int index = ind; index < MAX_CASCADES; ++index) { g_HUD.GetStatic(IDC_CASCADELEVEL1TEXT + index)->SetVisible(false); g_HUD.GetSlider(IDC_CASCADELEVEL1 + index)->SetVisible(false); } INT value = 32 * g_HUD.GetSlider(IDC_BUFFER_SIZE)->GetValue(); INT max = 8192 / g_CascadeConfig.m_nCascadeLevels; if (value > max) { WCHAR desc[256]; value = max; swprintf_s(desc, L"Texture Size: %d ", value); g_HUD.GetStatic(IDC_BUFFER_SIZETEXT)->SetText(desc); g_HUD.GetSlider(IDC_BUFFER_SIZE)->SetValue(value / 32); g_CascadeConfig.m_iBufferSize = value; } // update the selected camera based on these changes. INT selected = g_CameraSelectCombo->GetSelectedIndex(); WCHAR dta[60]; g_CameraSelectCombo->RemoveAllItems(); swprintf_s(dta, L"Eye Camera %ld", EYE_CAMERA + 1); g_CameraSelectCombo->AddItem(dta, ULongToPtr(EYE_CAMERA)); swprintf_s(dta, L"Light Camera %ld", LIGHT_CAMERA + 1); g_CameraSelectCombo->AddItem(dta, ULongToPtr(LIGHT_CAMERA)); for (int index = 0; index < g_CascadeConfig.m_nCascadeLevels; ++index) { swprintf_s(dta, L"Cascade Cam %d", index + 1); g_CameraSelectCombo->AddItem(dta, ULongToPtr(ORTHO_CAMERA1 + index)); } if (selected - 1 >= ind) { selected = ind + 1; } g_CameraSelectCombo->SetSelectedByIndex(selected); g_CascadedShadow.m_eSelectedCamera = (CAMERA_SELECTION) (g_CameraSelectCombo->GetSelectedIndex()); if (g_CascadedShadow.m_eSelectedCamera < 1) { g_pActiveCamera = &g_ViewerCamera; } else { g_pActiveCamera = &g_LightCamera; } } break; case IDC_DEPTHBUFFERFORMAT: { SHADOW_TEXTURE_FORMAT sbt = (SHADOW_TEXTURE_FORMAT)PtrToUlong(g_DepthBufferFormatCombo->GetSelectedData()); g_CascadeConfig.m_ShadowBufferFormat = sbt; } break; case IDC_CASCADELEVEL1: case IDC_CASCADELEVEL2: case IDC_CASCADELEVEL3: case IDC_CASCADELEVEL4: case IDC_CASCADELEVEL5: case IDC_CASCADELEVEL6: case IDC_CASCADELEVEL7: case IDC_CASCADELEVEL8: { INT ind = nControlID - IDC_CASCADELEVEL1; INT move = g_HUD.GetSlider(nControlID)->GetValue(); CDXUTSlider* selecteSlider; CDXUTStatic* selectedStatic; WCHAR label[16]; for (int index = 0; index < ind; ++index) { selecteSlider = g_HUD.GetSlider(IDC_CASCADELEVEL1 + index); INT sVal = selecteSlider->GetValue(); if (move < sVal) { selecteSlider->SetValue(move); selectedStatic = g_HUD.GetStatic(IDC_CASCADELEVEL1TEXT + index); swprintf_s(label, L"L%d: %d", index + 1, move); selectedStatic->SetText(label); g_CascadedShadow.m_iCascadePartitionsZeroToOne[index] = move; } } for (int index = ind; index < MAX_CASCADES; ++index) { selecteSlider = g_HUD.GetSlider(IDC_CASCADELEVEL1 + index); INT sVal = selecteSlider->GetValue(); if (move >= sVal) { selecteSlider->SetValue(move); selectedStatic = g_HUD.GetStatic(IDC_CASCADELEVEL1TEXT + index); swprintf_s(label, L"L%d: %d", index + 1, move); selectedStatic->SetText(label); g_CascadedShadow.m_iCascadePartitionsZeroToOne[index] = move; } } } break; } }
LRESULT GameApp::OnAltEnter() { DXUTToggleFullScreen(); return 0; }