public void HighResolutionSnapFramebuffer() { using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (HighResolutionSnapFramebuffer snap = new HighResolutionSnapFramebuffer(window.Context, 2, 10, 2)) { Assert.AreEqual(2, snap.AspectRatio); Assert.AreEqual(10, snap.DotsPerInch); Assert.AreEqual(2, snap.WidthInInches); Assert.AreEqual(20, snap.WidthInPixels); Assert.AreEqual(1, snap.HeightInInches); Assert.AreEqual(10, snap.HeightInPixels); window.Context.Framebuffer = snap.Framebuffer; window.Context.Viewport = new Rectangle(0, 0, snap.WidthInPixels, snap.HeightInPixels); window.Context.Clear(new ClearState() { Buffers = ClearBuffers.ColorAndDepthBuffer, Color = Color.Red, Depth = 0.5f }); string colorFile = "color.bmp"; string depthFile = "depth.bmp"; snap.SaveColorBuffer(colorFile); snap.SaveDepthBuffer(depthFile); try { using (Bitmap colorBitmap = new Bitmap(colorFile)) { Assert.AreEqual(snap.WidthInPixels, colorBitmap.Width); Assert.AreEqual(snap.HeightInPixels, colorBitmap.Height); } using (Bitmap depthBitmap = new Bitmap(depthFile)) { Assert.AreEqual(snap.WidthInPixels, depthBitmap.Width); Assert.AreEqual(snap.HeightInPixels, depthBitmap.Height); } } catch { throw; } finally { File.Delete(colorFile); File.Delete(depthFile); } } }
private void PreRenderFrame() { Context context = _window.Context; _snapBuffer = new HighResolutionSnapFramebuffer(context, WidthInInches, DotsPerInch, _sceneState.Camera.AspectRatio); context.Framebuffer = _snapBuffer.Framebuffer; _previousViewport = context.Viewport; context.Viewport = new Rectangle(0, 0, _snapBuffer.WidthInPixels, _snapBuffer.HeightInPixels); _previousSnapScale = _sceneState.HighResolutionSnapScale; _sceneState.HighResolutionSnapScale = (double)context.Viewport.Width / (double)_previousViewport.Width; }
private void PreRenderFrame() { Context context = _window.Context; _snapBuffer = new HighResolutionSnapFramebuffer(context, WidthInInches, DotsPerInch, _sceneState.Camera.AspectRatio); context.Framebuffer = _snapBuffer.Framebuffer; _previousViewport = context.Viewport; context.Viewport = new Rectangle(0, 0, _snapBuffer.WidthInPixels, _snapBuffer.HeightInPixels); _previousSnapScale = _sceneState.HighResolutionSnapScale; _sceneState.HighResolutionSnapScale = (double)context.Viewport.Width / (double)_previousViewport.Width; }
public void HighResolutionSnapFramebuffer() { using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (HighResolutionSnapFramebuffer snap = new HighResolutionSnapFramebuffer(window.Context, 2, 10, 2)) { Assert.AreEqual(2, snap.AspectRatio); Assert.AreEqual(10, snap.DotsPerInch); Assert.AreEqual(2, snap.WidthInInches); Assert.AreEqual(20, snap.WidthInPixels); Assert.AreEqual(1, snap.HeightInInches); Assert.AreEqual(10, snap.HeightInPixels); window.Context.Framebuffer = snap.Framebuffer; window.Context.Viewport = new Rectangle(0, 0, snap.WidthInPixels, snap.HeightInPixels); window.Context.Clear(new ClearState() { Buffers = ClearBuffers.ColorAndDepthBuffer, Color = Color.Red, Depth = 0.5f }); string colorFile = "color.bmp"; string depthFile = "depth.bmp"; snap.SaveColorBuffer(colorFile); snap.SaveDepthBuffer(depthFile); try { using (Bitmap colorBitmap = new Bitmap(colorFile)) { Assert.AreEqual(snap.WidthInPixels, colorBitmap.Width); Assert.AreEqual(snap.HeightInPixels, colorBitmap.Height); } using (Bitmap depthBitmap = new Bitmap(depthFile)) { Assert.AreEqual(snap.WidthInPixels, depthBitmap.Width); Assert.AreEqual(snap.HeightInPixels, depthBitmap.Height); } } catch { throw; } finally { File.Delete(colorFile); File.Delete(depthFile); } } }