diff --git a/distribution/macos/create_app_bundle.sh b/distribution/macos/create_app_bundle.sh
old mode 100644
new mode 100755
diff --git a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs
index 7ea6e14..c715307 100644
--- a/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs
+++ b/src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs
@@ -65,8 +65,8 @@ namespace Ryujinx.Headless.SDL2.OpenGL
// Ensure we share our contexts.
SetupOpenGLAttributes(true, GraphicsDebugLevel.None);
- 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);
+ IntPtr windowHandle = SDL_GL_GetCurrentWindow();
+ IntPtr context = SDL_GL_GetCurrentContext();
GL.LoadBindings(new OpenToolkitBindingsContext());
diff --git a/src/Ryujinx.Headless.SDL2/Program.cs b/src/Ryujinx.Headless.SDL2/Program.cs
index 4ee2712..a30bd62 100644
--- a/src/Ryujinx.Headless.SDL2/Program.cs
+++ b/src/Ryujinx.Headless.SDL2/Program.cs
@@ -34,11 +34,13 @@ using Silk.NET.Vulkan;
using System;
using System.Collections.Generic;
using System.IO;
+using System.Runtime.InteropServices;
using System.Text.Json;
using System.Threading;
using ConfigGamepadInputId = Ryujinx.Common.Configuration.Hid.Controller.GamepadInputId;
using ConfigStickInputId = Ryujinx.Common.Configuration.Hid.Controller.StickInputId;
using Key = Ryujinx.Common.Configuration.Hid.Key;
+using static SDL2.SDL;
namespace Ryujinx.Headless.SDL2
{
@@ -100,6 +102,18 @@ namespace Ryujinx.Headless.SDL2
.WithNotParsed(errors => errors.Output());
}
+ [UnmanagedCallersOnly(EntryPoint = "external_main")]
+ public static int ExternalMain(IntPtr rawWindow, IntPtr rawGlContext, int argc, IntPtr argv)
+ {
+ Console.WriteLine("external_main: host provided window: " + rawWindow);
+ Console.WriteLine("external_main: host provided GL context: " + rawGlContext);
+
+ SDL_GL_MakeCurrent(rawWindow, rawGlContext);
+
+ Main(new string[0]);
+ return 0;
+ }
+
private static InputConfig HandlePlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
{
if (inputId == null)
@@ -354,8 +368,8 @@ namespace Ryujinx.Headless.SDL2
{
if (option.GraphicsBackend == GraphicsBackend.OpenGl)
{
- option.GraphicsBackend = GraphicsBackend.Vulkan;
- Logger.Warning?.Print(LogClass.Application, "OpenGL is not supported on macOS, switching to Vulkan!");
+ //option.GraphicsBackend = GraphicsBackend.Vulkan;
+ Logger.Warning?.Print(LogClass.Application, "OpenGL is not supported on macOS, switching to Vulkan!"); // fuck you!
}
}
@@ -507,9 +521,7 @@ namespace Ryujinx.Headless.SDL2
private static WindowBase CreateWindow(Options options)
{
- return options.GraphicsBackend == GraphicsBackend.Vulkan
- ? new VulkanWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode)
- : new OpenGLWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode);
+ return new OpenGLWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode);
}
private static IRenderer CreateRenderer(Options options, WindowBase window)
diff --git a/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj b/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj
index 6102295..928d4f0 100644
--- a/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj
+++ b/src/Ryujinx.Headless.SDL2/Ryujinx.Headless.SDL2.csproj
@@ -3,7 +3,7 @@
net8.0
win-x64;osx-x64;linux-x64
- Exe
+ Library
true
1.0.0-dirty
$(DefineConstants);$(ExtraDefineConstants)
@@ -16,7 +16,7 @@
-
+
@@ -64,9 +64,9 @@
..\Ryujinx\Ryujinx.ico
-
- true
- true
- partial
-
+
+ true
+ true
+ partial
+
diff --git a/src/Ryujinx.Headless.SDL2/WindowBase.cs b/src/Ryujinx.Headless.SDL2/WindowBase.cs
index 8768913..8c10faf 100644
--- a/src/Ryujinx.Headless.SDL2/WindowBase.cs
+++ b/src/Ryujinx.Headless.SDL2/WindowBase.cs
@@ -142,6 +142,7 @@ namespace Ryujinx.Headless.SDL2
}
iconStream.Close();
+
unsafe
{
@@ -184,7 +185,7 @@ namespace Ryujinx.Headless.SDL2
FullscreenFlag = SDL_WindowFlags.SDL_WINDOW_FULLSCREEN_DESKTOP;
}
- WindowHandle = SDL_CreateWindow($"Ryujinx {Program.Version}{titleNameSection}{titleVersionSection}{titleIdSection}{titleArchSection}", SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), SDL_WINDOWPOS_CENTERED_DISPLAY(DisplayId), Width, Height, DefaultFlags | FullscreenFlag | GetWindowFlags());
+ WindowHandle = SDL_GL_GetCurrentWindow();
if (WindowHandle == IntPtr.Zero)
{