packages/Windows API Code Pack 1.1/source/Samples/DirectX/CS/Direct3D10/Tutorials/D3D10Tutorial01_WinFormsControl/TutorialWindow.cs
/// <summary>
/// Create Direct3D device and swap chain
/// </summary>
Create Direct3D device and swap chain
Create Direct3D device and swap chain
protected void InitDevice()
        {
            device = D3DDevice.CreateDeviceAndSwapChain(directControl.Handle);
            swapChain = device.SwapChain;
            using (Texture2D pBuffer = swapChain.GetBuffer<Texture2D>(0))
            {
                renderTargetView = device.CreateRenderTargetView(pBuffer);
            }
            device.OM.RenderTargets = new OutputMergerRenderTargets(new RenderTargetView[] { renderTargetView });
            Viewport vp = new Viewport()
            {
                Width = (uint)directControl.ClientSize.Width,
                Height = (uint)directControl.ClientSize.Height,
                MinDepth = 0.0f,
                MaxDepth = 1.0f,
                TopLeftX = 0,
                TopLeftY = 0
            };
            device.RS.Viewports = new Viewport[] { vp };
        }
protected void InitDevice ( ) { device = D3DDevice . CreateDeviceAndSwapChain ( directControl . Handle ) ; swapChain = device . SwapChain ; using ( Texture2D pBuffer = swapChain . GetBuffer < Texture2D > ( 0 ) ) { renderTargetView = device . CreateRenderTargetView ( pBuffer ) ; } device . OM . RenderTargets = new OutputMergerRenderTargets ( new RenderTargetView [ ] { renderTargetView } ) ; Viewport vp = new Viewport ( ) { Width = ( uint ) directControl . ClientSize . Width , Height = ( uint ) directControl . ClientSize . Height , MinDepth = 0.0f , MaxDepth = 1.0f , TopLeftX = 0 , TopLeftY = 0 } ; device . RS . Viewports = new Viewport [ ] { vp } ; }
Create Direct3D device and swap chain
Create Direct3D device and swap chain
// Create a render target view // Setup the viewport