bool DemoApp::Init() { if (!DemoBase::Init()) return false; m_pShadowMap = new ShadowMap(md3dDevice, mShadowMapSize, mShadowMapSize); m_pSkybox = new SkyBox( md3dDevice, 1000, 50, 50, "test"); CreateLights(); CreateShaders(); CreateGeometry(); CreateContantBuffers(); CreateSamplerStates(); CreateRenderStates(); SetUpSceneConsts(); return true; }
HRESULT D3D11Object::Initialize( HWND &hWnd, ID3D11UnorderedAccessView** ppResultUAV ) { printf("Initializing DXObject...\n"); HRESULT hr = S_OK; RECT rc; GetClientRect( hWnd, &rc ); UINT width = rc.right - rc.left; UINT height = rc.bottom - rc.top; InitDeviceContext(static_cast<int>(HEIGHT), static_cast<int>(WIDTH), hWnd ); m_pSwapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), reinterpret_cast<void**>(&m_pBackBufferTexture) ); CreateBufferTexUAV( m_pBackBufferTexture, ppResultUAV ); m_pDevice->CreateRenderTargetView( m_pBackBufferTexture, NULL, &m_pRenderTargetView ); CreateViewport(width, height); CreateSamplerStates(); return hr; }
// ╔════════════════════════════════════════════════════════════════════════════════════╗ // ║ Constructor and Destructor. ║ // ╚════════════════════════════════════════════════════════════════════════════════════╝ Shader::Shader(ID3D11Device* p_device, HWND p_windowHandle) { // Set variables to initial values. m_matrixBuffer = 0; m_lightSourceBuffer = 0; m_lightBuffer = 0; m_vertexShader = 0; m_pixelShader = 0; m_layout = 0; m_samplerState = 0; m_shadowMapSamplerState = 0; m_rasterizerState = 0; // Compile and create the shaders. CreateVertexShader(p_device); CreatePixelShader(p_device); // Create the states. CreateRasterizerState(p_device); CreateSamplerStates(p_device); // Setup buffers. SetupBuffers(p_device); }