示例#1
0
//--------------------------------------------------------------------------------------
// 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 )
{
	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_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;
    }
}
示例#4
0
//--------------------------------------------------------------------------------------
// 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_TOGGLEREF:
        DXUTToggleREF(); break;
    case IDC_CHANGEDEVICE:
        g_SettingsDlg.SetActive( !g_SettingsDlg.IsActive() ); break;    
    }
}
示例#5
0
文件: main.cpp 项目: NickABoen/Awe
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*/)
{
    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;
    }

}