mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2025-01-05 23:43:04 +00:00
Hook up SDL2 and GTK
This commit is contained in:
parent
e72bf35c03
commit
3e422f020c
6 changed files with 28 additions and 44 deletions
|
@ -504,7 +504,7 @@ namespace Ryujinx.UI
|
|||
}
|
||||
else
|
||||
{
|
||||
renderer = new Graphics.OpenGL.OpenGLRenderer();
|
||||
renderer = new Graphics.OpenGL.OpenGLRenderer(((OpenGLRenderer)RendererWidget).GetApi());
|
||||
}
|
||||
|
||||
BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Silk.NET.OpenGL.Legacy;
|
||||
using Ryujinx.Common.Configuration;
|
||||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Input.HLE;
|
||||
using Silk.NET.OpenGL.Legacy;
|
||||
using SPB.Graphics;
|
||||
using SPB.Graphics.Exceptions;
|
||||
using SPB.Graphics.OpenGL;
|
||||
|
@ -96,11 +96,18 @@ namespace Ryujinx.UI
|
|||
|
||||
_openGLContext.MakeCurrent(_nativeWindow);
|
||||
|
||||
GL.ClearColor(0, 0, 0, 1.0f);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
var api = GetApi();
|
||||
|
||||
api.ClearColor(0, 0, 0, 1.0f);
|
||||
api.Clear(ClearBufferMask.ColorBufferBit);
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
public GL GetApi()
|
||||
{
|
||||
return GL.GetApi(_openGLContext.GetProcAddress);
|
||||
}
|
||||
|
||||
public override void SwapBuffers()
|
||||
{
|
||||
_nativeWindow.SwapBuffers();
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
using SPB.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.UI
|
||||
{
|
||||
public class OpenToolkitBindingsContext : OpenTK.IBindingsContext
|
||||
{
|
||||
private readonly IBindingsContext _bindingContext;
|
||||
|
||||
public OpenToolkitBindingsContext(IBindingsContext bindingsContext)
|
||||
{
|
||||
_bindingContext = bindingsContext;
|
||||
}
|
||||
|
||||
public IntPtr GetProcAddress(string procName)
|
||||
{
|
||||
return _bindingContext.GetProcAddress(procName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
using Silk.NET.OpenGL.Legacy;
|
||||
using Ryujinx.Graphics.OpenGL;
|
||||
using Silk.NET.OpenGL.Legacy;
|
||||
using SPB.Graphics;
|
||||
using SPB.Graphics.OpenGL;
|
||||
using SPB.Platform;
|
||||
|
@ -9,11 +9,13 @@ namespace Ryujinx.UI
|
|||
{
|
||||
class SPBOpenGLContext : IOpenGLContext
|
||||
{
|
||||
public 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.UI
|
|||
context.Initialize(window);
|
||||
context.MakeCurrent(window);
|
||||
|
||||
GL.LoadBindings(new OpenToolkitBindingsContext(context));
|
||||
GL api = GL.GetApi(context.GetProcAddress);
|
||||
|
||||
context.MakeCurrent(null);
|
||||
|
||||
return new SPBOpenGLContext(context, window);
|
||||
return new SPBOpenGLContext(api, context, window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,22 +38,16 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
|||
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STEREO, 0));
|
||||
}
|
||||
|
||||
private class OpenToolkitBindingsContext : IBindingsContext
|
||||
{
|
||||
public IntPtr GetProcAddress(string procName)
|
||||
{
|
||||
return SDL_GL_GetProcAddress(procName);
|
||||
}
|
||||
}
|
||||
|
||||
private class SDL2OpenGLContext : IOpenGLContext
|
||||
{
|
||||
public readonly GL Api;
|
||||
private readonly IntPtr _context;
|
||||
private readonly IntPtr _window;
|
||||
private readonly bool _shouldDisposeWindow;
|
||||
|
||||
public SDL2OpenGLContext(IntPtr context, IntPtr window, bool shouldDisposeWindow = true)
|
||||
public SDL2OpenGLContext(GL api, IntPtr context, IntPtr window, bool shouldDisposeWindow = true)
|
||||
{
|
||||
Api = api;
|
||||
_context = context;
|
||||
_window = window;
|
||||
_shouldDisposeWindow = shouldDisposeWindow;
|
||||
|
@ -68,13 +62,13 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
|||
IntPtr windowHandle = SDL_CreateWindow("Ryujinx background context window", 0, 0, 1, 1, SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL_WindowFlags.SDL_WINDOW_HIDDEN);
|
||||
IntPtr context = SDL_GL_CreateContext(windowHandle);
|
||||
|
||||
GL.LoadBindings(new OpenToolkitBindingsContext());
|
||||
GL api = GL.GetApi((_ => context));
|
||||
|
||||
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0));
|
||||
|
||||
CheckResult(SDL_GL_MakeCurrent(windowHandle, IntPtr.Zero));
|
||||
|
||||
return new SDL2OpenGLContext(context, windowHandle);
|
||||
return new SDL2OpenGLContext(api, context, windowHandle);
|
||||
}
|
||||
|
||||
public void MakeCurrent()
|
||||
|
@ -111,6 +105,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
|||
|
||||
private readonly GraphicsDebugLevel _glLogLevel;
|
||||
private SDL2OpenGLContext _openGLContext;
|
||||
public GL Api => _openGLContext.Api;
|
||||
|
||||
public OpenGLWindow(
|
||||
InputManager inputManager,
|
||||
|
@ -142,15 +137,15 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
|||
}
|
||||
|
||||
// NOTE: The window handle needs to be disposed by the thread that created it and is handled separately.
|
||||
_openGLContext = new SDL2OpenGLContext(context, WindowHandle, false);
|
||||
_openGLContext = new SDL2OpenGLContext(GL.GetApi((_ => context)), context, WindowHandle, false);
|
||||
|
||||
// First take exclusivity on the OpenGL context.
|
||||
((OpenGLRenderer)Renderer).InitializeBackgroundContext(SDL2OpenGLContext.CreateBackgroundContext(_openGLContext));
|
||||
|
||||
_openGLContext.MakeCurrent();
|
||||
|
||||
GL.ClearColor(0, 0, 0, 1.0f);
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
_openGLContext.Api.ClearColor(0, 0, 0, 1.0f);
|
||||
_openGLContext.Api.Clear(ClearBufferMask.ColorBufferBit);
|
||||
SwapBuffers();
|
||||
|
||||
if (IsExclusiveFullscreen)
|
||||
|
|
|
@ -532,8 +532,8 @@ namespace Ryujinx.Headless.SDL2
|
|||
preferredGpuId);
|
||||
}
|
||||
|
||||
var openGlWindow = (OpenGLWindow)window;
|
||||
return new OpenGLRenderer(window.);
|
||||
var openGlWindow = window as OpenGLWindow;
|
||||
return new OpenGLRenderer(openGlWindow.Api);
|
||||
}
|
||||
|
||||
private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options)
|
||||
|
|
Loading…
Reference in a new issue