예제 #1
0
        private void LoadStructures()
        {
            var device = _graphicsDeviceManager.GraphicsDevice;

            var vertexBufferData = new[]
            {
                new SamplingVertex(-1.0f, 1.0f, 0.0f, 0.0f),
                new SamplingVertex(1.0f, 1.0f, 1.0f, 0.0f),
                new SamplingVertex(-1.0f, -1.0f, 0.0f, 1.0f),
                new SamplingVertex(1.0f, -1.0f, 1.0f, 1.0f)
            };

            var indexBufferData = new[] { 0, 1, 2, 3, 2, 1 };

            _viewerGeometry = ToDispose(new SharpDX.Toolkit.Graphics.GeometricPrimitive <SamplingVertex>(device, vertexBufferData, indexBufferData, false));

            var screenViewport = new ViewportF(0f, 0f, device.BackBuffer.Width, device.BackBuffer.Height);
            var targetWidth    = (int)(screenViewport.Width / SampleSettings.Sampling.Ratio);
            var targetHeight   = (int)(screenViewport.Height / SampleSettings.Sampling.Ratio);

            _viewport = new ViewportF(0f, 0f, targetWidth, targetHeight, 0f, 1f);

            _colorTextureRenderTarget = ToDispose(SharpDX.Toolkit.Graphics.RenderTarget2D.New(device,
                                                                                              targetWidth,
                                                                                              targetHeight,
                                                                                              SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm));

            _depthStencilBuffer = ToDispose(SharpDX.Toolkit.Graphics.DepthStencilBuffer.New(device,
                                                                                            targetWidth,
                                                                                            targetHeight,
                                                                                            SharpDX.Toolkit.Graphics.DepthFormat.Depth24Stencil8));

            _viewerEffect = _contentManager.Load <SamplingViewerEffect>("SamplingViewer");

            _viewerEffect.Scale = new Vector2(_viewport.Width / screenViewport.Width,
                                              _viewport.Height / screenViewport.Height);

            _viewerEffect.Offset = new Vector2(2f * (48.0f + _viewport.Width / 2f) / screenViewport.Width - 1f,
                                               1f - 2f * (screenViewport.Height - _viewport.Height - 48.0f + _viewport.Height / 2f) / screenViewport.Height);

            _samplingEffect = _contentManager.Load <SamplingRendererEffect>("SamplingRenderer");

            _samplingEffect.EncodeConstants = new Vector2(SampleSettings.TileSizeInBytes / SampleSettings.Sampling.Ratio, 24f);
        }
예제 #2
0
        private void LoadStructures()
        {
            var device = _graphicsDeviceManager.GraphicsDevice;

            var vertexBufferData = new[]
                                   {
                                       new SamplingVertex(-1.0f, 1.0f, 0.0f, 0.0f),
                                       new SamplingVertex(1.0f, 1.0f, 1.0f, 0.0f),
                                       new SamplingVertex(-1.0f, -1.0f, 0.0f, 1.0f),
                                       new SamplingVertex(1.0f, -1.0f, 1.0f, 1.0f)
                                   };

            var indexBufferData = new[] { 0, 1, 2, 3, 2, 1 };

            _viewerGeometry = ToDispose(new SharpDX.Toolkit.Graphics.GeometricPrimitive<SamplingVertex>(device, vertexBufferData, indexBufferData, false));

            var screenViewport = new ViewportF(0f, 0f, device.BackBuffer.Width, device.BackBuffer.Height);
            var targetWidth = (int)(screenViewport.Width / SampleSettings.Sampling.Ratio);
            var targetHeight = (int)(screenViewport.Height / SampleSettings.Sampling.Ratio);

            _viewport = new ViewportF(0f, 0f, targetWidth, targetHeight, 0f, 1f);

            _colorTextureRenderTarget = ToDispose(SharpDX.Toolkit.Graphics.RenderTarget2D.New(device,
                                                                                              targetWidth,
                                                                                              targetHeight,
                                                                                              SharpDX.Toolkit.Graphics.PixelFormat.B8G8R8A8.UNorm));

            _depthStencilBuffer = ToDispose(SharpDX.Toolkit.Graphics.DepthStencilBuffer.New(device,
                                                                                            targetWidth,
                                                                                            targetHeight,
                                                                                            SharpDX.Toolkit.Graphics.DepthFormat.Depth24Stencil8));

            _viewerEffect = _contentManager.Load<SamplingViewerEffect>("SamplingViewer");

            _viewerEffect.Scale = new Vector2(_viewport.Width / screenViewport.Width,
                                              _viewport.Height / screenViewport.Height);

            _viewerEffect.Offset = new Vector2(2f * (48.0f + _viewport.Width / 2f) / screenViewport.Width - 1f,
                                               1f - 2f * (screenViewport.Height - _viewport.Height - 48.0f + _viewport.Height / 2f) / screenViewport.Height);

            _samplingEffect = _contentManager.Load<SamplingRendererEffect>("SamplingRenderer");

            _samplingEffect.EncodeConstants = new Vector2(SampleSettings.TileSizeInBytes / SampleSettings.Sampling.Ratio, 24f);
        }