protected override void SetOutputTargets()
 {
     RenderTargets = new D3D.RenderTargetView[1 + NumAdditionalTargets];
     RenderTextures = new D3D.Texture2D[1 + NumAdditionalTargets];
     Targets = new Texturing.RenderTarget[1 + NumAdditionalTargets];
     RenderTargets[0] = RenderTarget.RenderView;
     RenderTextures[0] = RenderTarget.Texture;
     Targets[0] = RenderTarget;
     for (int i = 0; i < NumAdditionalTargets; i++)
     {
         RenderTextures[i + 1] = new D3D.Texture2D(Device, RenderTarget.Texture.Description);
         RenderTargets[i + 1] = new D3D.RenderTargetView(Device, RenderTextures[i + 1]);
         //Targets[i + 1] = new Texturing.RenderTarget(Device, RenderTargetView.Texture.Description.Width, RenderTargetView.Texture.Description.Height);
         Targets[i + 1] = new Texturing.RenderTarget(Device, RenderTarget.Texture.Description);
     }
     Device.OutputMerger.SetTargets(DepthBufferView, GetRenderTargets());
     //Device.OutputMerger.SetTargets(DepthBufferView, RenderTargets);
 }
Beispiel #2
0
        public void SetSize(int width, int height)
        {
            if (DepthBuffer != null) DepthBuffer.Dispose();
            if (DepthBufferView != null) DepthBufferView.Dispose();
            if (RenderTarget != null) RenderTarget.Dispose();

            SwapChain.ResizeBuffers(1, width, height, DXGI.Format.R8G8B8A8_UNorm, DXGI.SwapChainFlags.None);

            RenderTarget = new Texturing.RenderTarget(this, width, height);

            D3D.Texture2DDescription depthbufferdesc = new D3D.Texture2DDescription()
            {
                Width = width,
                Height = height,
                MipLevels = 1,
                ArraySize = 1,
                Format = SlimDX.DXGI.Format.D24_UNorm_S8_UInt,
                SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
                Usage = D3D.ResourceUsage.Default,
                BindFlags = D3D.BindFlags.DepthStencil,
                CpuAccessFlags = D3D.CpuAccessFlags.None,
                OptionFlags = D3D.ResourceOptionFlags.None
            };

            DepthBuffer = new D3D.Texture2D(Device, depthbufferdesc);
            DepthBufferView = new D3D.DepthStencilView(Device, DepthBuffer);

            Viewport = new D3D.Viewport()
            {
                X = 0,
                Y = 0,
                Width = width,
                Height = height,
                MinZ = 0.0f,
                MaxZ = 1.0f
            };
            Device.Rasterizer.SetViewports(Viewport);
            SetOutputTargets();
        }