From 2ed733b1d5addad027f48acfdd407e64b71427fc Mon Sep 17 00:00:00 2001 From: gdkchan Date: Fri, 23 Feb 2018 18:48:27 -0300 Subject: Somewhat better NvFlinger (I guess) (fixes #30) --- Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs | 40 +++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs') diff --git a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs index 7429569b..6bf17d09 100644 --- a/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs +++ b/Ryujinx.Graphics/Gal/OpenGL/OpenGLRenderer.cs @@ -1,7 +1,9 @@ +using OpenTK; using OpenTK.Graphics.OpenGL; using System; using System.Collections.Generic; + namespace Ryujinx.Graphics.Gal.OpenGL { public class OpenGLRenderer : IGalRenderer @@ -25,6 +27,8 @@ namespace Ryujinx.Graphics.Gal.OpenGL private Queue ActionsQueue; + private FrameBuffer FbRenderer; + public long FrameBufferPtr { get; set; } public OpenGLRenderer() @@ -36,6 +40,11 @@ namespace Ryujinx.Graphics.Gal.OpenGL ActionsQueue = new Queue(); } + public void InitializeFrameBuffer() + { + FbRenderer = new FrameBuffer(1280, 720); + } + public void QueueAction(Action ActionMthd) { ActionsQueue.Enqueue(ActionMthd); @@ -43,14 +52,18 @@ namespace Ryujinx.Graphics.Gal.OpenGL public void RunActions() { - while (ActionsQueue.Count > 0) + int Count = ActionsQueue.Count; + + while (Count-- > 0) { ActionsQueue.Dequeue()(); } - } + } public void Render() { + FbRenderer.Render(); + for (int Index = 0; Index < VertexBuffers.Count; Index++) { VertexBuffer Vb = VertexBuffers[Index]; @@ -62,7 +75,28 @@ namespace Ryujinx.Graphics.Gal.OpenGL GL.DrawArrays(PrimitiveType.TriangleStrip, 0, Vb.PrimCount); } } - + } + + public void SetWindowSize(int Width, int Height) + { + FbRenderer.WindowWidth = Width; + FbRenderer.WindowHeight = Height; + } + + public unsafe void SetFrameBuffer( + byte* Fb, + int Width, + int Height, + float ScaleX, + float ScaleY, + float Rotate) + { + Matrix2 Transform; + + Transform = Matrix2.CreateScale(ScaleX, ScaleY); + Transform *= Matrix2.CreateRotation(Rotate); + + FbRenderer.Set(Fb, Width, Height, Transform); } public void SendVertexBuffer(int Index, byte[] Buffer, int Stride, GalVertexAttrib[] Attribs) -- cgit v1.2.3