示例#1
0
        /* Sets the different device parameters on each reset. */
        private void SetDeviceParameters(IntPtr device)
        {
            SharpDX.Direct3D9.Device localDevice = new SharpDX.Direct3D9.Device(device);

            if (_dx9Settings.EnableMSAA)
            {
                localDevice.SetRenderState(RenderState.MultisampleAntialias, true);
            }

            if (_dx9Settings.EnableAF)
            {
                localDevice.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Anisotropic);
                localDevice.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Anisotropic);
                localDevice.SetSamplerState(0, SamplerState.MaxAnisotropy, _dx9Settings.AFLevel);
            }
        }
        /// <summary>Renders the view.</summary>
        public void Render(Device device)
        {
            device.SetRenderState(RenderState.CullMode, Cull.None);
            device.SetRenderState(RenderState.ZEnable, ZBufferType.DontUseZBuffer);
            device.SetRenderState(RenderState.ZWriteEnable, false);

            device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point);
            device.SetSamplerState(0, SamplerState.MagFilter, _useLinearFiltering ? TextureFilter.Linear : TextureFilter.Point);
            device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Point);

            device.SetRenderState(RenderState.ShadeMode, ShadeMode.Flat);
            device.SetRenderState(RenderState.FillMode, FillMode.Solid);

            device.SetRenderState(RenderState.Lighting, false);
            device.SetTexture(0, _viewTexture);

            device.SetStreamSource(0, _vertexBuffer, 0, Marshal.SizeOf(typeof(DX9TransformedColorTexture)));
            device.VertexDeclaration = _vertexDeclaration;
            device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
        }