当前位置: 首页>>代码示例>>C++>>正文


C++ CD3DSettingsDlg::OnD3D11CreateDevice方法代码示例

本文整理汇总了C++中CD3DSettingsDlg::OnD3D11CreateDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ CD3DSettingsDlg::OnD3D11CreateDevice方法的具体用法?C++ CD3DSettingsDlg::OnD3D11CreateDevice怎么用?C++ CD3DSettingsDlg::OnD3D11CreateDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CD3DSettingsDlg的用法示例。


在下文中一共展示了CD3DSettingsDlg::OnD3D11CreateDevice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CDXUTTextHelper

HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* d3dDevice, const DXGI_SURFACE_DESC* backBufferSurfaceDesc,
                                     void* userContext)
{    
    ID3D11DeviceContext* d3dDeviceContext = DXUTGetD3D11DeviceContext();
    gDialogResourceManager.OnD3D11CreateDevice(d3dDevice, d3dDeviceContext);
    gD3DSettingsDlg.OnD3D11CreateDevice(d3dDevice);
    gTextHelper = new CDXUTTextHelper(d3dDevice, d3dDeviceContext, &gDialogResourceManager, 15);
    
    gViewerCamera.SetRotateButtons(true, false, false);
    gViewerCamera.SetDrag(true);
    gViewerCamera.SetEnableYAxisMovement(true);

    return S_OK;
}
开发者ID:NickABoen,项目名称:Awe,代码行数:14,代码来源:main.cpp

示例2: DXUTGetDXGIFactory

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr;

    hr = DXUTGetDXGIFactory()->MakeWindowAssociation(DXUTGetHWND(), DXGI_MWA_NO_ALT_ENTER);

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    // Create AMD_SDK resources here
    g_HUD.OnCreateDevice( pd3dDevice );

	g_Context.Init(pd3dDevice, pd3dImmediateContext);
	g_Background.Init(pd3dDevice, &g_Context);
	g_Character.Init(pd3dDevice, pd3dImmediateContext, &g_Context);

	TIMER_Init(pd3dDevice)

	// Generate shaders ( this is an async operation - call AMD::ShaderCache::ShadersReady() to find out if they are complete ) 
    static bool bFirstPass = true;
    if( bFirstPass )
    {
		// Add the applications shaders to the cache
		g_Context.m_ShaderCache.GenerateShaders(AMD::ShaderCache::CREATE_TYPE_COMPILE_CHANGES);    // Only compile shaders that have changed (development mode)
        bFirstPass = false;
    } 
	g_Context.m_Affinity.SetUseAffinity(true);

	// Set toggle whether to render using Affinity MGPU
	g_HUD.m_GUI.GetCheckBox(IDC_CHECKBOX_ENABLE_MGPU)->SetChecked(g_Context.m_Affinity.GetUseAffinity());
	g_HUD.m_GUI.GetCheckBox(IDC_CHECKBOX_ENABLE_MGPU)->SetEnabled(g_Context.m_Affinity.IsEnabled());


    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_AUTOMATIC)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());
    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_MANUAL)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());
    g_HUD.m_GUI.GetRadioButton(IDC_RADIO_SYNC_TYPE_NONE)->SetEnabled(g_Context.m_Affinity.GetUseAffinity());

    wchar_t text[1000];
    swprintf_s(text, _countof(text), L"%s : %s", APPLICATION_TITLE, g_Context.m_Affinity.IsEnabled() ? L"MGPU available" : L"MGPU not available");
    ::SetWindowTextW(::DXUTGetHWND(), text);

    return S_OK;
}
开发者ID:AnilVarmaBiruduraju,项目名称:LiquidVR,代码行数:49,代码来源:AffinityGPUControl.cpp

示例3: CDXUTTextHelper

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependent on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* /*pBackBufferSurfaceDesc*/,
    void* /*pUserContext*/)
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN(g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext));
    V_RETURN(g_D3DSettingsDlg.OnD3D11CreateDevice(pd3dDevice));
    g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15);

    V_RETURN(g_Scene.OnD3D11CreateDevice(pd3dDevice));

    // Setup the camera   
    XMVECTOR vecEye = XMVectorSet(0.0f, 0.5f, -3.0f, 0);
    XMVECTOR vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0);
    g_Camera.SetViewParams(vecEye, vecAt);

    g_OIT.OnD3D11CreateDevice(pd3dDevice);
    return S_OK;
}
开发者ID:marselas,项目名称:Zombie-Direct3D-Samples,代码行数:23,代码来源:main.cpp

示例4: CreateD3DComponents

//--------------------------------------------------------------------------------------
// When the user changes scene, recreate these components as they are scene 
// dependent.
//--------------------------------------------------------------------------------------
HRESULT CreateD3DComponents( ID3D11Device* pd3dDevice)
{
  HRESULT hr;
  
  auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
  V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
  V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
  g_pTxtHelper  = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
  
  static const XMVECTORF32 s_vecEye    = { 105.0f,  14.0f, -3.0f, 0.f };
  static const XMVECTORF32 s_vecLookAt = {   0.0f,  -7.5f,  0.0f, 0.f };
  XMFLOAT3                 vMin        = XMFLOAT3( -1000.0f, -1000.0f, -1000.0f );
  XMFLOAT3                 vMax        = XMFLOAT3( 1000.0f, 1000.0f, 1000.0f );
  
  g_ViewerCamera.SetViewParams( s_vecEye, s_vecLookAt );
  g_ViewerCamera.SetRotateButtons( true, false, false);
  g_ViewerCamera.SetScalers( 0.01f, 10.0f );
  g_ViewerCamera.SetDrag( true );
  g_ViewerCamera.SetEnableYAxisMovement( true );
  g_ViewerCamera.SetClipToBoundary( true, &vMin, &vMax );
  g_ViewerCamera.FrameMove( 0 );
  
  static const XMVECTORF32 s_lightEye = { -320.0f, 300.0f, -220.3f, 0.f };
  g_LightCamera.SetViewParams( s_lightEye, g_XMZero );
  g_LightCamera.SetRotateButtons( true, false, false );
  g_LightCamera.SetScalers( 0.01f, 50.0f );
  g_LightCamera.SetDrag( true );
  g_LightCamera.SetEnableYAxisMovement( true );
  g_LightCamera.SetClipToBoundary( true, &vMin, &vMax );
  g_LightCamera.SetProjParams( XM_PI / 4, 1.0f, 0.1f , 1000.0f);

  g_LightCamera.FrameMove( 0 );
         
  // Get the final sizes
  uint32_t width  = DXUTGetDXGIBackBufferSurfaceDesc()->Width; 
  uint32_t height = DXUTGetDXGIBackBufferSurfaceDesc()->Height;

  g_Scene.Init( pd3dDevice, pd3dImmediateContext, &g_MeshPowerPlant, width, height);
  
  return S_OK;
}
开发者ID:JasSra,项目名称:GPU-Pro-6,代码行数:45,代码来源:AdvancedLighting.cpp

示例5: CreateD3DComponents

//--------------------------------------------------------------------------------------
// When the user changes scene, recreate these components as they are scene 
// dependent.
//--------------------------------------------------------------------------------------
HRESULT CreateD3DComponents(ID3D11Device* pd3dDevice)
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN(g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext));
    V_RETURN(g_D3DSettingsDlg.OnD3D11CreateDevice(pd3dDevice));
    g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15);


    XMVECTOR vecEye = XMVectorSet(100.0f, 5.0f, 5.0f, 0);
    XMVECTOR vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0);
    XMFLOAT3 vMin = XMFLOAT3(-1000.0f, -1000.0f, -1000.0f);
    XMFLOAT3 vMax = XMFLOAT3(1000.0f, 1000.0f, 1000.0f);

    g_ViewerCamera.SetViewParams(vecEye, vecAt);
    g_ViewerCamera.SetRotateButtons(TRUE, FALSE, FALSE);
    g_ViewerCamera.SetScalers(0.01f, 10.0f);
    g_ViewerCamera.SetDrag(true);
    g_ViewerCamera.SetEnableYAxisMovement(true);
    g_ViewerCamera.SetClipToBoundary(TRUE, &vMin, &vMax);
    g_ViewerCamera.FrameMove(0);

    vecEye = XMVectorSet(-320.0f, 300.0f, -220.3f, 0);
    vecAt = XMVectorSet(0.0f, 0.0f, 0.0f, 0);

    g_LightCamera.SetViewParams(vecEye, vecAt);
    g_LightCamera.SetRotateButtons(TRUE, FALSE, FALSE);
    g_LightCamera.SetScalers(0.01f, 50.0f);
    g_LightCamera.SetDrag(true);
    g_LightCamera.SetEnableYAxisMovement(true);
    g_LightCamera.SetClipToBoundary(TRUE, &vMin, &vMax);
    g_LightCamera.SetProjParams(XM_PI / 4, 1.0f, 0.1f, 1000.0f);
    g_LightCamera.FrameMove(0);

    g_CascadedShadow.Init(pd3dDevice, pd3dImmediateContext,
        g_pSelectedMesh, &g_ViewerCamera, &g_LightCamera, &g_CascadeConfig);

    return S_OK;
}
开发者ID:marselas,项目名称:Zombie-Direct3D-Samples,代码行数:44,代码来源:CascadedShadowMaps11.cpp

示例6: CDXUTTextHelper

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr;

    auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    // Create other render resources here
    g_States = std::make_unique<CommonStates>( pd3dDevice );
    g_Batch = std::make_unique<PrimitiveBatch<VertexPositionColor>>( pd3dImmediateContext );

    g_BatchEffect = std::make_unique<BasicEffect>( pd3dDevice );
    g_BatchEffect->SetVertexColorEnabled(true);

    {
        void const* shaderByteCode;
        size_t byteCodeLength;

        g_BatchEffect->GetVertexShaderBytecode( &shaderByteCode, &byteCodeLength );

        hr = pd3dDevice->CreateInputLayout( VertexPositionColor::InputElements,
                                            VertexPositionColor::InputElementCount,
                                            shaderByteCode, byteCodeLength,
                                            &g_pBatchInputLayout );
        if( FAILED( hr ) )
            return hr;
    }

    // Setup the camera's view parameters
    auto pComboBox = g_SampleUI.GetComboBox( IDC_GROUP );
    SetViewForGroup( (pComboBox) ? (int)PtrToInt( pComboBox->GetSelectedData() ) : 0 );

    g_HUD.GetButton( IDC_TOGGLEWARP )->SetEnabled( true );

    return S_OK;
}
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:42,代码来源:Collision.cpp

示例7: vecEye

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice(ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext)
{
    HRESULT hr;

    DXUTTRACE(L"OnD3D11CreateDevice called\n");

    SetCursor(LoadCursor(0, IDC_ARROW));

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext(); // does not addref
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext) );
    V_RETURN( g_SettingsDlg.OnD3D11CreateDevice(pd3dDevice) );
    g_pTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, g_TextLineHeight);

    // Setup orbital camera
    D3DXVECTOR3 vecEye(0.0f, 2.0f, 0.0f);
    D3DXVECTOR3 vecAt (0.0f, 0.0f, 0.0f);
    g_OrbitalCamera.SetViewParams(&vecEye, &vecAt);
    g_OrbitalCamera.SetRadius(1.5f, 0.01f);

    // Setup first-person camera
    D3DXVECTOR3 sibenikVecEye(0.0960150138f, 0.0273544509f, -0.0185411610f);
    D3DXVECTOR3 sibenikVecAt (-0.623801112f, -0.649074197f, -0.174454257f);
    g_FirstPersonCamera.SetViewParams(&sibenikVecEye, &sibenikVecAt);
    g_FirstPersonCamera.SetEnablePositionMovement(1);
    g_FirstPersonCamera.SetScalers(0.001f, 0.05f);

    // Load Scene3D.fx
    g_pSceneRenderer.OnCreateDevice(pd3dDevice);

    // Load meshes and bin files
    LoadScenes(pd3dDevice);

    GFSDK_SSAO_Status status;
    status = g_AORenderer.Create(pd3dDevice);
    assert(status == GFSDK_SSAO_OK);

    return S_OK;
}
开发者ID:151706061,项目名称:D3DSamples,代码行数:41,代码来源:DeinterleavedTexturing.cpp

示例8: quadSize

// Create any D3D11 resources that aren't dependent on the back buffer
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN(gDialogResourceManager.OnD3D11CreateDevice(pd3dDevice, pd3dImmediateContext));
    V_RETURN(gD3DSettingsDlg.OnD3D11CreateDevice(pd3dDevice));
    gTxtHelper = new CDXUTTextHelper(pd3dDevice, pd3dImmediateContext, &gDialogResourceManager, 15);

    // Create a vertex shader.
    ID3DBlob* vertexShaderBuffer = NULL;
    V_RETURN(CompileShaderFromFile(L"shaders.hlsl", "PassThroughVS", "vs_4_0", &vertexShaderBuffer));
    V_RETURN(pd3dDevice->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &gVertexShader));

	// Create a pixel shader that renders the composite frame.
    ID3DBlob* pixelShaderBuffer = NULL;
    V_RETURN(CompileShaderFromFile(L"shaders.hlsl", "RenderFramePS", "ps_4_0", &pixelShaderBuffer));
    V_RETURN(pd3dDevice->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &gRenderFramePS));

	// Create a pixel shader that renders the error texture.
    V_RETURN(CompileShaderFromFile(L"shaders.hlsl", "RenderTexturePS", "ps_4_0", &pixelShaderBuffer));
    V_RETURN(pd3dDevice->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &gRenderTexturePS));

	// Create a pixel shader that shows alpha
    V_RETURN(CompileShaderFromFile(L"shaders.hlsl", "RenderAlphaPS", "ps_4_0", &pixelShaderBuffer));
    V_RETURN(pd3dDevice->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &gRenderAlphaPS));

    // Create our vertex input layout
    const D3D11_INPUT_ELEMENT_DESC layout[] =
    {
        { "POSITION",  0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "TEXCOORD",  0, DXGI_FORMAT_R32G32_FLOAT,    0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }
    };

    V_RETURN(pd3dDevice->CreateInputLayout(layout, ARRAYSIZE(layout), vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &gVertexLayout));

    SAFE_RELEASE(vertexShaderBuffer);
    SAFE_RELEASE(pixelShaderBuffer);

	// Create a vertex buffer for three textured quads.
	D3DXVECTOR2 quadSize(0.32f, 0.32f);
	D3DXVECTOR2 quadOrigin(-0.66f, -0.0f);
    Vertex tripleQuadVertices[18];
	ZeroMemory(tripleQuadVertices, sizeof(tripleQuadVertices));
	for(int i = 0; i < 18; i += 6)
	{
		tripleQuadVertices[i].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
		tripleQuadVertices[i].texCoord = D3DXVECTOR2(0.0f, 0.0f);

		tripleQuadVertices[i + 1].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
		tripleQuadVertices[i + 1].texCoord = D3DXVECTOR2(1.0f, 0.0f);

		tripleQuadVertices[i + 2].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
		tripleQuadVertices[i + 2].texCoord = D3DXVECTOR2(1.0f, 1.0f);

		tripleQuadVertices[i + 3].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
		tripleQuadVertices[i + 3].texCoord = D3DXVECTOR2(1.0f, 1.0f);

		tripleQuadVertices[i + 4].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
		tripleQuadVertices[i + 4].texCoord = D3DXVECTOR2(0.0f, 1.0f);

		tripleQuadVertices[i + 5].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
		tripleQuadVertices[i + 5].texCoord = D3DXVECTOR2(0.0f, 0.0f);

		quadOrigin.x += 0.66f;
	}

    D3D11_BUFFER_DESC bufDesc;
	ZeroMemory(&bufDesc, sizeof(bufDesc));
    bufDesc.Usage = D3D11_USAGE_DEFAULT;
    bufDesc.ByteWidth = sizeof(tripleQuadVertices);
    bufDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
	bufDesc.CPUAccessFlags = 0;
    D3D11_SUBRESOURCE_DATA data;
	ZeroMemory(&data, sizeof(data));
    data.pSysMem = tripleQuadVertices;
    V_RETURN(pd3dDevice->CreateBuffer(&bufDesc, &data, &gVertexBuffer));

	// Create a vertex buffer for a single textured quad.
	quadSize = D3DXVECTOR2(1.0f, 1.0f);
	quadOrigin = D3DXVECTOR2(0.0f, 0.0f);
	Vertex singleQuadVertices[6];
	singleQuadVertices[0].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
	singleQuadVertices[0].texCoord = D3DXVECTOR2(0.0f, 0.0f);
	singleQuadVertices[1].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
	singleQuadVertices[1].texCoord = D3DXVECTOR2(1.0f, 0.0f);
	singleQuadVertices[2].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
	singleQuadVertices[2].texCoord = D3DXVECTOR2(1.0f, 1.0f);
	singleQuadVertices[3].position = D3DXVECTOR3(quadOrigin.x + quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
	singleQuadVertices[3].texCoord = D3DXVECTOR2(1.0f, 1.0f);
	singleQuadVertices[4].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y - quadSize.y, 0.0f);
	singleQuadVertices[4].texCoord = D3DXVECTOR2(0.0f, 1.0f);
	singleQuadVertices[5].position = D3DXVECTOR3(quadOrigin.x - quadSize.x, quadOrigin.y + quadSize.y, 0.0f);
	singleQuadVertices[5].texCoord = D3DXVECTOR2(0.0f, 0.0f);

	ZeroMemory(&bufDesc, sizeof(bufDesc));
    bufDesc.Usage = D3D11_USAGE_DEFAULT;
    bufDesc.ByteWidth = sizeof(singleQuadVertices);
//.........这里部分代码省略.........
开发者ID:Nuos,项目名称:ISPCTextureCompressor,代码行数:101,代码来源:main.cpp

示例9: vCenter

//--------------------------------------------------------------------------------------
// Create any D3D resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr = S_OK;

    auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    XMFLOAT3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
    FLOAT fObjectRadius = 378.15607f;

    g_mCenterMesh = XMMatrixTranslation( -vCenter.x, -vCenter.y, -vCenter.z );
    XMMATRIX m;
    m = XMMatrixRotationY( XM_PI );
    g_mCenterMesh *= m;
    m = XMMatrixRotationX( XM_PI / 2.0f );
    g_mCenterMesh *= m;

    // Init the UI widget for directional lighting
    V_RETURN( CDXUTDirectionWidget::StaticOnD3D11CreateDevice( pd3dDevice,  pd3dImmediateContext ) );
    g_LightControl.SetRadius( fObjectRadius );

    // Compile and create the effect.
    DWORD dwShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#ifdef _DEBUG
    // Set the D3DCOMPILE_DEBUG flag to embed debug information in the shaders.
    // Setting this flag improves the shader debugging experience, but still allows 
    // the shaders to be optimized and to run exactly the way they will run in 
    // the release configuration of this program.
    dwShaderFlags |= D3DCOMPILE_DEBUG;

    // Disable optimizations to further improve shader debugging
    dwShaderFlags |= D3DCOMPILE_SKIP_OPTIMIZATION;
#endif

#if D3D_COMPILER_VERSION >= 46

    WCHAR str[MAX_PATH];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"DynamicShaderLinkageFX11.fx" ) );

    ID3DBlob* pErrorBlob = nullptr;
    hr = D3DX11CompileEffectFromFile( str, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, pd3dDevice, &g_pEffect, &pErrorBlob );
    if ( pErrorBlob )
    {
        OutputDebugStringA( reinterpret_cast<const char*>( pErrorBlob->GetBufferPointer() ) );
        pErrorBlob->Release();
    }
    if( FAILED(hr) )
    {
        return hr;
    }

#else

    ID3DBlob* pEffectBuffer = nullptr;
    V_RETURN( DXUTCompileFromFile( L"DynamicShaderLinkageFX11.fx", nullptr, "none", "fx_5_0", dwShaderFlags, D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS, &pEffectBuffer ) );
    hr = D3DX11CreateEffectFromMemory( pEffectBuffer->GetBufferPointer(), pEffectBuffer->GetBufferSize(), 0, pd3dDevice, &g_pEffect );
    SAFE_RELEASE( pEffectBuffer );
    if ( FAILED(hr) )
        return hr;
    
#endif

    // Get the light Class Interfaces for setting values
    // and as potential binding sources.
    g_pAmbientLightClass = g_pEffect->GetVariableByName( "g_ambientLight" )->AsClassInstance();
    g_pAmbientLightColor = g_pAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
    g_pAmbientLightEnable = g_pAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();

    g_pHemiAmbientLightClass = g_pEffect->GetVariableByName( "g_hemiAmbientLight" )->AsClassInstance();
    g_pHemiAmbientLightColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
    g_pHemiAmbientLightEnable = g_pHemiAmbientLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
    g_pHemiAmbientLightGroundColor = g_pHemiAmbientLightClass->GetMemberByName( "m_vGroundColor" )->AsVector();
    g_pHemiAmbientLightDirUp = g_pHemiAmbientLightClass->GetMemberByName( "m_vDirUp" )->AsVector();

    g_pDirectionalLightClass = g_pEffect->GetVariableByName( "g_directionalLight")->AsClassInstance();
    g_pDirectionalLightColor = g_pDirectionalLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
    g_pDirectionalLightEnable = g_pDirectionalLightClass->GetMemberByName( "m_bEnable" )->AsScalar();
    g_pDirectionalLightDir = g_pDirectionalLightClass->GetMemberByName( "m_vLightDir" )->AsVector();

    g_pEnvironmentLightClass = g_pEffect->GetVariableByName( "g_environmentLight")->AsClassInstance();
    g_pEnvironmentLightColor = g_pEnvironmentLightClass->GetMemberByName( "m_vLightColor" )->AsVector();
    g_pEnvironmentLightEnable = g_pEnvironmentLightClass->GetMemberByName( "m_bEnable" )->AsScalar();

    g_pEyeDir = g_pEffect->GetVariableByName( "g_vEyeDir" )->AsVector();
    
    // Acquire the material Class Instances for all possible material settings
    for( UINT i=0; i < MATERIAL_TYPE_COUNT; i++)
    {
        char pTechName[50];

        sprintf_s( pTechName, sizeof(pTechName),
                   "FeatureLevel11_%s",
                   g_pMaterialClassNames[ i ] );
        g_MaterialClasses[i].pTechnique = g_pEffect->GetTechniqueByName( pTechName );
//.........这里部分代码省略.........
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:101,代码来源:DynamicShaderLinkageFX11.cpp

示例10: ifs

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    HRESULT hr; 

    static bool bFirstOnCreateDevice = true;

    // Warn the user that in order to support CS4x, a non-hardware device has been created, continue or quit?
    if ( DXUTGetDeviceSettings().d3d11.DriverType != D3D_DRIVER_TYPE_HARDWARE && bFirstOnCreateDevice )
    {
        if ( MessageBox( 0, L"CS4x capability is missing. "\
                            L"In order to continue, a non-hardware device has been created, "\
                            L"it will be very slow, continue?", L"Warning", MB_ICONEXCLAMATION | MB_YESNO ) != IDYES )
            return E_FAIL;
    }

    bFirstOnCreateDevice = false;

    auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    V_RETURN( g_Tessellator.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    // find the file
    WCHAR str[MAX_PATH];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, L"BaseMesh.obj" ) );

    std::wifstream ifs( str );
    WCHAR line[256] = {0};
    std::vector<XMFLOAT4> initdata;

    // Parse the .obj file. Both triangle faces and quad faces are supported.
    // Only v and f tags are processed, other tags like vn, vt etc are ignored.
    {
        std::vector<XMFLOAT4> v;

        while ( ifs >> line )
        {
            if ( 0 == wcscmp( line, L"#" ) ) 
                ifs.getline( line, 255 );
            else
            if ( 0 == wcscmp( line, L"v" ) )
            {
                XMFLOAT4 pos;
                ifs >> pos.x >> pos.y >> pos.z;
                pos.w = 1;
                v.push_back( pos );
            }
        }

        ifs.clear( 0 );
        ifs.seekg( 0 );
        while ( ifs >> line )
        {
            if ( 0 == wcscmp( line, L"#" ) ) 
                ifs.getline( line, 255 );
            else
            if ( 0 == wcscmp( line, L"f" ) )
            {
                ifs.getline( line, 255 );
                std::wstringstream ss(line);
                int idx[4] = {0}, i = 0;
                while ( ss >> line )
                {
                    std::wstringstream ss2(line);
                    ss2 >> idx[i++];
                }
                
                initdata.push_back( v[idx[0]-1] ); initdata.push_back( v[idx[1]-1] ); initdata.push_back( v[idx[2]-1] );
                if ( i >= 4 ) // quad face?
                {
                    initdata.push_back( v[idx[2]-1] ); initdata.push_back( v[idx[3]-1] ); initdata.push_back( v[idx[0]-1] );
                }
            }
        }        
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:79,代码来源:AdaptiveTessellationCS40.cpp

示例11: vecEye

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );
    g_pTxtHelper1 = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 35 );

    // textures / rts
    D3D11_TEXTURE2D_DESC TDesc;
      
    TDesc.Width  = UINT(g_fShadowMapWidth);
    TDesc.Height = UINT(g_fShadowMapHeight);
    TDesc.MipLevels = 1;
    TDesc.ArraySize = 1;
    TDesc.Format = DXGI_FORMAT_R16_TYPELESS;
    TDesc.SampleDesc.Count = 1;
    TDesc.SampleDesc.Quality = 0;
    TDesc.Usage = D3D11_USAGE_DEFAULT;
    TDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
    TDesc.CPUAccessFlags = 0;
    TDesc.MiscFlags = 0;
    pd3dDevice->CreateTexture2D( &TDesc, 0, &g_pRSMDepthStencilTexture);
    DXUT_SetDebugName( g_pRSMDepthStencilTexture, "RSM" );

    D3D11_DEPTH_STENCIL_VIEW_DESC DSVDesc;
    
    DSVDesc.Format = DXGI_FORMAT_D16_UNORM;
    DSVDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
    DSVDesc.Flags = 0;
    DSVDesc.Texture2D.MipSlice = 0;
    pd3dDevice->CreateDepthStencilView( g_pRSMDepthStencilTexture, &DSVDesc, & g_pDepthStencilTextureDSV );
    DXUT_SetDebugName( g_pDepthStencilTextureDSV, "RSM DSV" );

    D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc;
    
    SRVDesc.Format =  DXGI_FORMAT_R16_UNORM;
    SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
    SRVDesc.Texture2D.MipLevels = 1;
    SRVDesc.Texture2D.MostDetailedMip = 0;
    pd3dDevice->CreateShaderResourceView( g_pRSMDepthStencilTexture, &SRVDesc, &g_pDepthTextureSRV );
    DXUT_SetDebugName( g_pDepthTextureSRV, "RSM SRV" );

    // Setup constant buffers
    D3D11_BUFFER_DESC Desc;
    
    // Utility
    Desc.Usage = D3D11_USAGE_DYNAMIC;
    Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    Desc.MiscFlags = 0;    
    Desc.ByteWidth = sizeof( CB_CONSTANTS );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbConstants ) );
    DXUT_SetDebugName( g_pcbConstants, "CB_CONSTANTS"  );

    // Load the scene mesh
    WCHAR str[256];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, 256,  L"ColumnScene\\scene.sdkmesh" ) );
    g_SceneMesh.Create( pd3dDevice, str, false );

    V_RETURN( DXUTFindDXSDKMediaFileCch( str, 256,  L"ColumnScene\\poles.sdkmesh" ) );
    g_Poles.Create( pd3dDevice, str, false );

    // Setup the camera   
    D3DXVECTOR3 vecEye( 0.95f, 5.83f, -14.48f );
    D3DXVECTOR3 vecAt ( 0.90f, 5.44f, -13.56f );
    g_Camera.SetViewParams( &vecEye, &vecAt );
    D3DXVECTOR3 vecEyeL = D3DXVECTOR3( 0,0,0 );
    D3DXVECTOR3 vecAtL ( 0, -0.5, 1 );
    g_LCamera.SetViewParams( &vecEyeL, &vecAtL );

    // Create sampler states for point and linear

    // PointCmp
    D3D11_SAMPLER_DESC SamDesc;
    SamDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT;
    SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_BORDER;
    SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_BORDER;
    SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
    SamDesc.MipLODBias = 0.0f;
    SamDesc.MaxAnisotropy = 1;
    SamDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
    SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 1.0;
    SamDesc.MinLOD = 0;
    SamDesc.MaxLOD = D3D11_FLOAT32_MAX;
    V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamplePointCmp ) );
    DXUT_SetDebugName( g_pSamplePointCmp, "PointCmp" );

    // Point
    SamDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
    SamDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamplePoint ) );
    DXUT_SetDebugName( g_pSamplePoint, "Point" );

//.........这里部分代码省略.........
开发者ID:KNeal,项目名称:Oculus,代码行数:101,代码来源:ContactHardeningShadows11.cpp

示例12: vCenter

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
	
    g_pd3dDevice = pd3dDevice;
 
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();

    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    D3DXVECTOR3 vCenter( 0.25767413f, -28.503521f, 111.00689f);
    FLOAT fObjectRadius = 378.15607f;

    D3DXMatrixTranslation( &g_mCenterMesh, -vCenter.x, -vCenter.y, -vCenter.z );
    D3DXMATRIXA16 m;
    D3DXMatrixRotationY( &m, D3DX_PI );
    g_mCenterMesh *= m;
    D3DXMatrixRotationX( &m, D3DX_PI / 2.0f );
    g_mCenterMesh *= m;

    // Compile the shaders to a model based on the feature level we acquired
    ID3DBlob* pVertexShaderBuffer = NULL;
	ID3DBlob* pGeometryShaderBuffer = NULL;
    ID3DBlob* pPixelShaderBuffer = NULL;
  
    switch( DXUTGetD3D11DeviceFeatureLevel() )
    {
        case D3D_FEATURE_LEVEL_11_0:
            V_RETURN( CompileShaderFromFile( L"cloth_renderer_VS.hlsl", "VSMain", "vs_5_0" , &pVertexShaderBuffer ) );
			V_RETURN( CompileShaderFromFile( L"cloth_renderer_PS.hlsl", "GSMain", "gs_5_0" , &pGeometryShaderBuffer ) );
            V_RETURN( CompileShaderFromFile( L"cloth_renderer_PS.hlsl", "PSMain", "ps_5_0" , &pPixelShaderBuffer ) );
            break;        
    }

    // Create the shaders
    V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &g_pVertexShader ) );


	V_RETURN( pd3dDevice->CreateGeometryShader( pGeometryShaderBuffer->GetBufferPointer(),
                                              pGeometryShaderBuffer->GetBufferSize(), NULL, &g_pGeometryShader ) );
    

    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &g_pPixelShader ) );

    

    V_RETURN( pd3dDevice->CreateInputLayout( layout, ARRAYSIZE( layout ), pVertexShaderBuffer->GetBufferPointer(),
                                             pVertexShaderBuffer->GetBufferSize(), &g_pVertexLayout11 ) );

    SAFE_RELEASE( pVertexShaderBuffer );
    SAFE_RELEASE( pPixelShaderBuffer );
	SAFE_RELEASE( pGeometryShaderBuffer );


    // Load the mesh
    V_RETURN( g_Mesh11.Create( pd3dDevice, L"tiny\\tiny.sdkmesh", true ) );


    

    // Create a sampler state
    D3D11_SAMPLER_DESC SamDesc;
    SamDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    SamDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    SamDesc.MipLODBias = 0.0f;
    SamDesc.MaxAnisotropy = 1;
    SamDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    SamDesc.BorderColor[0] = SamDesc.BorderColor[1] = SamDesc.BorderColor[2] = SamDesc.BorderColor[3] = 0;
    SamDesc.MinLOD = 0;
    SamDesc.MaxLOD = D3D11_FLOAT32_MAX;
    V_RETURN( pd3dDevice->CreateSamplerState( &SamDesc, &g_pSamLinear ) );


	

    // Setup constant buffers
    D3D11_BUFFER_DESC Desc;
    Desc.Usage = D3D11_USAGE_DYNAMIC;
    Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    Desc.MiscFlags = 0;

    Desc.ByteWidth = sizeof( CB_VS_PER_OBJECT );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbVSPerObject ) );

    Desc.ByteWidth = sizeof( CB_PS_PER_OBJECT );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, NULL, &g_pcbPSPerObject ) );

    Desc.ByteWidth = sizeof( CB_PS_PER_FRAME );
//.........这里部分代码省略.........
开发者ID:AndreAhmed,项目名称:directxgameengine,代码行数:101,代码来源:cloth_renderer.cpp

示例13: vecEye

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

   // D3DXVECTOR3 vCenter( 0.25767413f, -28.503521f, 111.00689f );
    FLOAT fObjectRadius = 378.15607f;
	lightpos = D3DXVECTOR3(300,300,-200);
	//test = new testing();
	hr = test.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tessplane.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = tesscube.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,D3DXVECTOR3(300,50,-200));//D3DXVECTOR3(300,50,-200
	hr = lightsphere.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,10,lightpos);
	hr = fuse.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = board1.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(300,-300,-1000));
	hr = deboard.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(-300,-300,-1000));
	hr = geo_alien.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = FirePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,80,0); //0 = fire
	hr = sky.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,D3DXVECTOR3(0,0,0));
	hr = buildings.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext);
	hr = MissilePart.setup(pd3dDevice,pBackBufferSurfaceDesc,pUserContext,20,1);
    g_LightControl.SetRadius( 2000 );



	
    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 50.0f, -1000.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, -0.0f );

	g_Camera.SetRotateButtons(true,false,false);
    g_Camera.SetViewParams( &vecEye, &vecAt );
	g_Camera.SetEnablePositionMovement( true );
	g_Camera.SetScalers( 0.005f, 500.0f );

	D3D11_DEPTH_STENCIL_DESC descDS;
	ZeroMemory(&descDS, sizeof(descDS));
	descDS.DepthEnable = false;
	descDS.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;	
	descDS.DepthFunc = D3D11_COMPARISON_LESS;	
	

	descDS.StencilEnable = FALSE;
	hr = pd3dDevice->CreateDepthStencilState( &descDS, &g_DepthState);

	//setup stuff for post process


	ID3DBlob* pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    ID3DBlob* pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"PP1.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPFirstPass ) );
    DXUT_SetDebugName( VSPPFirstPass, "VSPost1" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPFirstPass ) );
    DXUT_SetDebugName( PSPPFirstPass, "PSPost1" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"Gaussblur.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPBlur ) );
    DXUT_SetDebugName( VSPPBlur, "VSBlur" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPBlur ) );
    DXUT_SetDebugName( PSPPBlur, "PSBlur" );

	pVertexShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "VS", "vs_4_0", &pVertexShaderBuffer ) );

    pPixelShaderBuffer = NULL;
    V_RETURN( CompileShaderFromFile( L"bloom_combine.hlsl", "PS", "ps_4_0", &pPixelShaderBuffer ) );

	V_RETURN( pd3dDevice->CreateVertexShader( pVertexShaderBuffer->GetBufferPointer(),
                                              pVertexShaderBuffer->GetBufferSize(), NULL, &VSPPComb ) );
    DXUT_SetDebugName( VSPPComb, "VSComb" );
    V_RETURN( pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(),
                                             pPixelShaderBuffer->GetBufferSize(), NULL, &PSPPComb ) );
    DXUT_SetDebugName( PSPPComb, "PSComb" );





	
//.........这里部分代码省略.........
开发者ID:AlexKLM,项目名称:DX11-Shader-Language-Coursework,代码行数:101,代码来源:BasicHLSL11.cpp

示例14: CDXUTTextHelper

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                      void* pUserContext )
{
    HRESULT hr;

    auto pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_D3DSettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    // Compile shaders
    ID3DBlob* pBlobVS = nullptr;
    ID3DBlob* pBlobHSInt = nullptr;
    ID3DBlob* pBlobHSFracEven = nullptr;
    ID3DBlob* pBlobHSFracOdd = nullptr;
    ID3DBlob* pBlobDS = nullptr;
    ID3DBlob* pBlobPS = nullptr;
    ID3DBlob* pBlobPSSolid = nullptr;

    // This macro is used to compile the hull shader with different partition modes
    // Please see the partitioning mode attribute for the hull shader for more information
    D3D_SHADER_MACRO integerPartitioning[] = { { "BEZIER_HS_PARTITION", "\"integer\"" }, { 0 } };
    D3D_SHADER_MACRO fracEvenPartitioning[] = { { "BEZIER_HS_PARTITION", "\"fractional_even\"" }, { 0 } };
    D3D_SHADER_MACRO fracOddPartitioning[] = { { "BEZIER_HS_PARTITION", "\"fractional_odd\"" }, { 0 } };

    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", nullptr, "BezierVS", "vs_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobVS ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", integerPartitioning, "BezierHS", "hs_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobHSInt ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", fracEvenPartitioning, "BezierHS", "hs_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobHSFracEven ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", fracOddPartitioning, "BezierHS", "hs_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobHSFracOdd ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", nullptr, "BezierDS", "ds_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobDS ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", nullptr, "BezierPS", "ps_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobPS ) );
    V_RETURN( DXUTCompileFromFile( L"SimpleBezier11.hlsl", nullptr, "SolidColorPS", "ps_5_0",
                                   D3DCOMPILE_ENABLE_STRICTNESS, 0, &pBlobPSSolid ) );

    // Create shaders
    V_RETURN( pd3dDevice->CreateVertexShader( pBlobVS->GetBufferPointer(), pBlobVS->GetBufferSize(), nullptr, &g_pVertexShader ) );
    DXUT_SetDebugName( g_pVertexShader, "BezierVS" );

    V_RETURN( pd3dDevice->CreateHullShader( pBlobHSInt->GetBufferPointer(), pBlobHSInt->GetBufferSize(), nullptr, &g_pHullShaderInteger ) );
    DXUT_SetDebugName( g_pHullShaderInteger, "BezierHS int" );

    V_RETURN( pd3dDevice->CreateHullShader( pBlobHSFracEven->GetBufferPointer(), pBlobHSFracEven->GetBufferSize(), nullptr, &g_pHullShaderFracEven ) );
    DXUT_SetDebugName( g_pHullShaderFracEven, "BezierHS frac even" );

    V_RETURN( pd3dDevice->CreateHullShader( pBlobHSFracOdd->GetBufferPointer(), pBlobHSFracOdd->GetBufferSize(), nullptr, &g_pHullShaderFracOdd ) );
    DXUT_SetDebugName( g_pHullShaderFracOdd, "BezierHS frac odd" );

    V_RETURN( pd3dDevice->CreateDomainShader( pBlobDS->GetBufferPointer(), pBlobDS->GetBufferSize(), nullptr, &g_pDomainShader ) );
    DXUT_SetDebugName( g_pDomainShader, "BezierDS" );

    V_RETURN( pd3dDevice->CreatePixelShader( pBlobPS->GetBufferPointer(), pBlobPS->GetBufferSize(), nullptr, &g_pPixelShader ) );
    DXUT_SetDebugName( g_pPixelShader, "BezierPS" );

    V_RETURN( pd3dDevice->CreatePixelShader( pBlobPSSolid->GetBufferPointer(), pBlobPSSolid->GetBufferSize(), nullptr, &g_pSolidColorPS ) );
    DXUT_SetDebugName( g_pSolidColorPS, "SolidColorPS" );

    // Create our vertex input layout - this matches the BEZIER_CONTROL_POINT structure
    const D3D11_INPUT_ELEMENT_DESC patchlayout[] =
    {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0,  D3D11_INPUT_PER_VERTEX_DATA, 0 },
    };

    V_RETURN( pd3dDevice->CreateInputLayout( patchlayout, ARRAYSIZE( patchlayout ), pBlobVS->GetBufferPointer(),
                                             pBlobVS->GetBufferSize(), &g_pPatchLayout ) );
    DXUT_SetDebugName( g_pPatchLayout, "Primary" );

    SAFE_RELEASE( pBlobVS );
    SAFE_RELEASE( pBlobHSInt );
    SAFE_RELEASE( pBlobHSFracEven );
    SAFE_RELEASE( pBlobHSFracOdd );
    SAFE_RELEASE( pBlobDS );
    SAFE_RELEASE( pBlobPS );
    SAFE_RELEASE( pBlobPSSolid );

    // Create constant buffers
    D3D11_BUFFER_DESC Desc;
    Desc.Usage = D3D11_USAGE_DYNAMIC;
    Desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
    Desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
    Desc.MiscFlags = 0;

    Desc.ByteWidth = sizeof( CB_PER_FRAME_CONSTANTS );
    V_RETURN( pd3dDevice->CreateBuffer( &Desc, nullptr, &g_pcbPerFrame ) );
    DXUT_SetDebugName( g_pcbPerFrame, "CB_PER_FRAME_CONSTANTS" );

    // Create solid and wireframe rasterizer state objects
    D3D11_RASTERIZER_DESC RasterDesc;
    ZeroMemory( &RasterDesc, sizeof(D3D11_RASTERIZER_DESC) );
    RasterDesc.FillMode = D3D11_FILL_SOLID;
    RasterDesc.CullMode = D3D11_CULL_NONE;
    RasterDesc.DepthClipEnable = TRUE;
//.........这里部分代码省略.........
开发者ID:AndreAhmed,项目名称:directx-sdk-samples,代码行数:101,代码来源:SimpleBezier11.cpp

示例15: CDXUTTextHelper

//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
                                     void* pUserContext )
{
    DXUT_SetDebugName( pd3dDevice, "Main Device" );

    HRESULT hr;

    ID3D11DeviceContext* pd3dImmediateContext = DXUTGetD3D11DeviceContext();
    V_RETURN( g_DialogResourceManager.OnD3D11CreateDevice( pd3dDevice, pd3dImmediateContext ) );
    V_RETURN( g_SettingsDlg.OnD3D11CreateDevice( pd3dDevice ) );
    g_pTxtHelper = new CDXUTTextHelper( pd3dDevice, pd3dImmediateContext, &g_DialogResourceManager, 15 );

    IDXGIDevice* pDXGIDevice;
    hr = pd3dDevice->QueryInterface( __uuidof(IDXGIDevice), (VOID**)&pDXGIDevice );
    if( SUCCEEDED(hr) )
    {
        IDXGIAdapter* pAdapter;
        hr = pDXGIDevice->GetAdapter( &pAdapter );
        if( SUCCEEDED(hr) )
        {
            DXGI_ADAPTER_DESC AdapterDesc;
            pAdapter->GetDesc( &AdapterDesc );
            SetAdapterInfoForShaderCompilation( AdapterDesc.Description );
            SAFE_RELEASE( pAdapter );
        }
        SAFE_RELEASE( pDXGIDevice );
    }

    ID3D10Blob* pVSBlob = NULL;
    g_pVSTransform = CompileVertexShader( pd3dDevice, L"SceneRender.hlsl", "VSTransform", &pVSBlob );
    g_pPSSceneRender = CompilePixelShader( pd3dDevice, L"SceneRender.hlsl", "PSSceneRender" );
    g_pPSSceneRenderArray = CompilePixelShader( pd3dDevice, L"SceneRender.hlsl", "PSSceneRenderArray" );
    g_pPSSceneRenderQuilt = CompilePixelShader( pd3dDevice, L"SceneRender.hlsl", "PSSceneRenderQuilt" );

    // Create a layout for the object data
    const D3D11_INPUT_ELEMENT_DESC layout[] =
    {
        { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0,  0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
        { "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
    };

    V_RETURN( pd3dDevice->CreateInputLayout( layout, ARRAYSIZE( layout ), pVSBlob->GetBufferPointer(),
                                             pVSBlob->GetBufferSize(), &g_pDefaultInputLayout ) );

    // No longer need the shader blobs
    SAFE_RELEASE( pVSBlob );

    // Create state objects
    D3D11_SAMPLER_DESC samDesc;
    ZeroMemory( &samDesc, sizeof(samDesc) );
    samDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    samDesc.AddressU = samDesc.AddressV = samDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    samDesc.MaxAnisotropy = 1;
    samDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    samDesc.MaxLOD = D3D11_FLOAT32_MAX;
    V_RETURN( pd3dDevice->CreateSamplerState( &samDesc, &g_pSamLinear ) );
    DXUT_SetDebugName( g_pSamLinear, "Linear" );

    D3D11_BLEND_DESC BlendDesc;
    ZeroMemory( &BlendDesc, sizeof( D3D11_BLEND_DESC ) );
    BlendDesc.RenderTarget[0].BlendEnable = FALSE;
    BlendDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
    BlendDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
    BlendDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
    BlendDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
    BlendDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
    BlendDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
    BlendDesc.RenderTarget[0].RenderTargetWriteMask = D3D10_COLOR_WRITE_ENABLE_ALL;
    hr = pd3dDevice->CreateBlendState( &BlendDesc, &g_pBlendState );
    ASSERT( SUCCEEDED(hr) );

    D3D11_DEPTH_STENCIL_DESC DSDesc;
    ZeroMemory( &DSDesc, sizeof(D3D11_DEPTH_STENCIL_DESC) );
    DSDesc.DepthEnable = FALSE;
    DSDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    DSDesc.DepthFunc = D3D11_COMPARISON_LESS;
    DSDesc.StencilEnable = FALSE;
    DSDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
    DSDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;
    hr = pd3dDevice->CreateDepthStencilState( &DSDesc, &g_pDepthStencilState );
    ASSERT( SUCCEEDED(hr) );

    D3D11_RASTERIZER_DESC RSDesc;
    ZeroMemory( &RSDesc, sizeof(RSDesc) );
    RSDesc.AntialiasedLineEnable = FALSE;
    RSDesc.CullMode = D3D11_CULL_BACK;
    RSDesc.DepthBias = 0;
    RSDesc.DepthBiasClamp = 0.0f;
    RSDesc.DepthClipEnable = TRUE;
    RSDesc.FillMode = D3D11_FILL_SOLID;
    RSDesc.FrontCounterClockwise = FALSE;
    RSDesc.MultisampleEnable = TRUE;
    RSDesc.ScissorEnable = FALSE;
    RSDesc.SlopeScaledDepthBias = 0.0f;
    hr = pd3dDevice->CreateRasterizerState( &RSDesc, &g_pRasterizerState );
    ASSERT( SUCCEEDED(hr) );

//.........这里部分代码省略.........
开发者ID:kingofthebongo2008,项目名称:examples,代码行数:101,代码来源:TiledResources11.cpp


注:本文中的CD3DSettingsDlg::OnD3D11CreateDevice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。