aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.OpenGL/Window.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.Graphics.OpenGL/Window.cs')
-rw-r--r--Ryujinx.Graphics.OpenGL/Window.cs19
1 files changed, 19 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.OpenGL/Window.cs b/Ryujinx.Graphics.OpenGL/Window.cs
index b7525ae5..35b04d6d 100644
--- a/Ryujinx.Graphics.OpenGL/Window.cs
+++ b/Ryujinx.Graphics.OpenGL/Window.cs
@@ -16,6 +16,8 @@ namespace Ryujinx.Graphics.OpenGL
internal BackgroundContextWorker BackgroundContext { get; private set; }
+ internal bool ScreenCaptureRequested { get; set; }
+
public Window(Renderer renderer)
{
_renderer = renderer;
@@ -106,6 +108,13 @@ namespace Ryujinx.Graphics.OpenGL
int dstY0 = crop.FlipY ? dstPaddingY : _height - dstPaddingY;
int dstY1 = crop.FlipY ? _height - dstPaddingY : dstPaddingY;
+ if (ScreenCaptureRequested)
+ {
+ CaptureFrame(srcX0, srcY0, srcX1, srcY1, view.Format.IsBgra8(), crop.FlipX, crop.FlipY);
+
+ ScreenCaptureRequested = false;
+ }
+
GL.BlitFramebuffer(
srcX0,
srcY0,
@@ -159,6 +168,16 @@ namespace Ryujinx.Graphics.OpenGL
BackgroundContext = new BackgroundContextWorker(baseContext);
}
+ public void CaptureFrame(int x, int y, int width, int height, bool isBgra, bool flipX, bool flipY)
+ {
+ long size = Math.Abs(4 * width * height);
+ byte[] bitmap = new byte[size];
+
+ GL.ReadPixels(x, y, width, height, isBgra ? PixelFormat.Bgra : PixelFormat.Rgba, PixelType.UnsignedByte, bitmap);
+
+ _renderer.OnScreenCaptured(new ScreenCaptureImageInfo(width, height, isBgra, bitmap, flipX, flipY));
+ }
+
public void Dispose()
{
BackgroundContext.Dispose();