mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-22 18:05:46 +00:00
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>
This commit is contained in:
parent
b82e789d4f
commit
bd6937ae5c
6 changed files with 10 additions and 17 deletions
|
@ -29,6 +29,8 @@ namespace Ryujinx.Ava.UI.Renderer
|
|||
_context.MakeCurrent(_window);
|
||||
}
|
||||
|
||||
public bool HasContext() => _context.IsCurrent;
|
||||
|
||||
public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
|
||||
{
|
||||
OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
_thread.Start();
|
||||
}
|
||||
|
||||
public bool HasContext() => _backgroundContext.HasContext();
|
||||
|
||||
private void Run()
|
||||
{
|
||||
InBackground = true;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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).
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
|||
}
|
||||
}
|
||||
|
||||
public bool HasContext() => SDL_GL_GetCurrentContext() != IntPtr.Zero;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
SDL_GL_DeleteContext(_context);
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Ryujinx.Ui
|
|||
_context.MakeCurrent(_window);
|
||||
}
|
||||
|
||||
public bool HasContext() => _context.IsCurrent;
|
||||
|
||||
public static SPBOpenGLContext CreateBackgroundContext(OpenGLContextBase sharedContext)
|
||||
{
|
||||
OpenGLContextBase context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, 3, 3, OpenGLContextFlags.Compat, true, sharedContext);
|
||||
|
|
Loading…
Reference in a new issue