From e584f8d37df89fc987df7ac8ecfe2f16e7d1a413 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Thu, 9 May 2024 21:22:38 -0400 Subject: [PATCH] Ava Working? --- src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs | 2 +- src/Ryujinx.Headless.SDL2/Program.cs | 3 ++- src/Ryujinx/AppHost.cs | 2 +- src/Ryujinx/UI/Renderer/EmbeddedWindowOpenGL.cs | 16 +++++++++------- src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs | 10 ++++++---- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs index 4b5e8ddeb..bef71e5a6 100644 --- a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs +++ b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs @@ -1,4 +1,4 @@ -using OpenTK; +// using OpenTK; using Silk.NET.OpenGL.Legacy; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; diff --git a/src/Ryujinx.Headless.SDL2/Program.cs b/src/Ryujinx.Headless.SDL2/Program.cs index 85aff6712..38faa6b8d 100644 --- a/src/Ryujinx.Headless.SDL2/Program.cs +++ b/src/Ryujinx.Headless.SDL2/Program.cs @@ -532,7 +532,8 @@ namespace Ryujinx.Headless.SDL2 preferredGpuId); } - return new OpenGLRenderer(); + var openGlWindow = (OpenGLWindow)window; + return new OpenGLRenderer(window.); } private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options) diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index d405f3205..cddc7429f 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -823,7 +823,7 @@ namespace Ryujinx.Ava } else { - renderer = new OpenGLRenderer(); + renderer = new OpenGLRenderer((RendererHost.EmbeddedWindow as EmbeddedWindowOpenGL).CreateApi()); } BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading; diff --git a/src/Ryujinx/UI/Renderer/EmbeddedWindowOpenGL.cs b/src/Ryujinx/UI/Renderer/EmbeddedWindowOpenGL.cs index 3842301de..92fe2c22e 100644 --- a/src/Ryujinx/UI/Renderer/EmbeddedWindowOpenGL.cs +++ b/src/Ryujinx/UI/Renderer/EmbeddedWindowOpenGL.cs @@ -1,4 +1,4 @@ -using OpenTK.Graphics.OpenGL; +using Silk.NET.OpenGL.Legacy; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; @@ -44,6 +44,13 @@ namespace Ryujinx.Ava.UI.Renderer throw new PlatformNotSupportedException(); } + Context.Initialize(_window); + Context.MakeCurrent(_window); + Context.MakeCurrent(null); + } + + public GL CreateApi() + { var flags = OpenGLContextFlags.Compat; if (ConfigurationState.Instance.Logger.GraphicsDebugLevel != GraphicsDebugLevel.None) { @@ -54,12 +61,7 @@ namespace Ryujinx.Ava.UI.Renderer Context = PlatformHelper.CreateOpenGLContext(graphicsMode, 3, 3, flags); - Context.Initialize(_window); - Context.MakeCurrent(_window); - - GL.LoadBindings(new OpenTKBindingsContext(Context.GetProcAddress)); - - Context.MakeCurrent(null); + return GL.GetApi(Context.GetProcAddress); } public void MakeCurrent(bool unbind = false, bool shouldThrow = true) diff --git a/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs b/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs index 63bf6cf7c..9f94337b3 100644 --- a/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs +++ b/src/Ryujinx/UI/Renderer/SPBOpenGLContext.cs @@ -1,4 +1,4 @@ -using OpenTK.Graphics.OpenGL; +using Silk.NET.OpenGL.Legacy; using Ryujinx.Graphics.OpenGL; using SPB.Graphics; using SPB.Graphics.OpenGL; @@ -9,11 +9,13 @@ namespace Ryujinx.Ava.UI.Renderer { class SPBOpenGLContext : IOpenGLContext { + private readonly GL _api; private readonly OpenGLContextBase _context; private readonly NativeWindowBase _window; - private SPBOpenGLContext(OpenGLContextBase context, NativeWindowBase window) + private SPBOpenGLContext(GL api, OpenGLContextBase context, NativeWindowBase window) { + _api = api; _context = context; _window = window; } @@ -39,11 +41,11 @@ namespace Ryujinx.Ava.UI.Renderer context.Initialize(window); context.MakeCurrent(window); - GL.LoadBindings(new OpenTKBindingsContext(context.GetProcAddress)); + GL api = GL.GetApi(context.GetProcAddress); context.MakeCurrent(null); - return new SPBOpenGLContext(context, window); + return new SPBOpenGLContext(api, context, window); } } }