diff options
| author | Mary Guillemard <mary@mary.zone> | 2024-02-10 20:13:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-10 20:13:10 +0100 |
| commit | bd6937ae5ca8bbc7c5e9b7792933d9971cf1768b (patch) | |
| tree | 0fec9888ccca931c436d153cc48c58d987c4aff2 /src/Ryujinx.Graphics.OpenGL | |
| parent | b82e789d4f023f1797c9352bb0e7155595d6f1a2 (diff) | |
Make IOpenGLContext.HasContext context dependent (#6290)
This makes IOpenGLContext.HasContext not static and be implementable.
By doing this, we can support more than WGL and WGL.
This also allows the SDL2 headless version to run under Wayland.
Signed-off-by: Mary <mary@mary.zone>
Diffstat (limited to 'src/Ryujinx.Graphics.OpenGL')
| -rw-r--r-- | src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs | 2 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs | 17 | ||||
| -rw-r--r-- | src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs | 2 |
3 files changed, 4 insertions, 17 deletions
diff --git a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs index ae647e38..f22e0df5 100644 --- a/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs +++ b/src/Ryujinx.Graphics.OpenGL/BackgroundContextWorker.cs @@ -30,6 +30,8 @@ namespace Ryujinx.Graphics.OpenGL _thread.Start(); } + public bool HasContext() => _backgroundContext.HasContext(); + private void Run() { InBackground = true; diff --git a/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs b/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs index a11b9cb2..525418d7 100644 --- a/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs +++ b/src/Ryujinx.Graphics.OpenGL/IOpenGLContext.cs @@ -7,21 +7,6 @@ namespace Ryujinx.Graphics.OpenGL { void MakeCurrent(); - // TODO: Support more APIs per platform. - static bool HasContext() - { - if (OperatingSystem.IsWindows()) - { - return WGLHelper.GetCurrentContext() != IntPtr.Zero; - } - else if (OperatingSystem.IsLinux()) - { - return GLXHelper.GetCurrentContext() != IntPtr.Zero; - } - else - { - return false; - } - } + bool HasContext(); } } diff --git a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs index 3d774aad..eabcb3c1 100644 --- a/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs +++ b/src/Ryujinx.Graphics.OpenGL/OpenGLRenderer.cs @@ -248,7 +248,7 @@ namespace Ryujinx.Graphics.OpenGL { // alwaysBackground is ignored, since we cannot switch from the current context. - if (IOpenGLContext.HasContext()) + if (_window.BackgroundContext.HasContext()) { action(); // We have a context already - use that (assuming it is the main one). } |
