Refactor OpenGL window handling and update project output type to Library
This commit is contained in:
parent
a59234f5ca
commit
330ea68174
0
distribution/macos/create_app_bundle.sh
Normal file → Executable file
0
distribution/macos/create_app_bundle.sh
Normal file → Executable file
@ -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());
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x64;osx-x64;linux-x64</RuntimeIdentifiers>
|
||||
<OutputType>Exe</OutputType>
|
||||
<OutputType>Library</OutputType>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Version>1.0.0-dirty</Version>
|
||||
<DefineConstants Condition=" '$(ExtraDefineConstants)' != '' ">$(DefineConstants);$(ExtraDefineConstants)</DefineConstants>
|
||||
@ -16,7 +16,7 @@
|
||||
<PackageReference Include="Ryujinx.Graphics.Nvdec.Dependencies" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
|
||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX')) and '$(OutputType)'=='Exe'">
|
||||
<Exec Command="codesign --entitlements '$(ProjectDir)..\..\distribution\macos\entitlements.xml' -f --deep -s $(SigningCertificate) '$(TargetDir)$(TargetName)'" />
|
||||
</Target>
|
||||
|
||||
@ -64,9 +64,9 @@
|
||||
<ApplicationIcon>..\Ryujinx\Ryujinx.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(RuntimeIdentifier)' != ''">
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<TrimMode>partial</TrimMode>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(OutputType)'=='Exe' and '$(RuntimeIdentifier)' != ''">
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<TrimMode>partial</TrimMode>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user