mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-12-23 15:05:47 +00:00
a1ddaa2736
* ui: Only wait on _exitEvent when MainLoop is active under GTK This fixes a dispose issue under Horizon/GTK, we don't check if the ApplicationClient is null so it throw NCE. We don't check if the main loop is active and waiting an event which is set in the main loop... So that could lead to a freeze. Everything works fine in GTK now. Related issue: https://github.com/Ryujinx/Ryujinx/issues/3873 As a side note, same kind of issue appear in Avalonia UI too. Firmware's popup doesn't show anything and the emulator just freeze. * TSRBerry's change Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com> * Fix Avalonia crashing/freezing * Add Avalonia OpenGL fixes * Fix firmware popup on windows * Fixes everything * Add _initialized bool to VulkanRenderer and OpenGL Window Co-authored-by: TSRBerry <20988865+TSRBerry@users.noreply.github.com>
85 lines
No EOL
2.3 KiB
C#
85 lines
No EOL
2.3 KiB
C#
using Avalonia;
|
|
using Avalonia.OpenGL;
|
|
using OpenTK.Graphics.OpenGL;
|
|
using Ryujinx.Common.Configuration;
|
|
using SPB.Graphics;
|
|
using SPB.Graphics.OpenGL;
|
|
using SPB.Platform;
|
|
using SPB.Platform.GLX;
|
|
using SPB.Platform.WGL;
|
|
using SPB.Windowing;
|
|
using System;
|
|
|
|
namespace Ryujinx.Ava.Ui.Controls
|
|
{
|
|
public class OpenGLEmbeddedWindow : EmbeddedWindow
|
|
{
|
|
private readonly int _major;
|
|
private readonly int _minor;
|
|
private readonly GraphicsDebugLevel _graphicsDebugLevel;
|
|
private SwappableNativeWindowBase _window;
|
|
public OpenGLContextBase Context { get; set; }
|
|
|
|
public OpenGLEmbeddedWindow(int major, int minor, GraphicsDebugLevel graphicsDebugLevel)
|
|
{
|
|
_major = major;
|
|
_minor = minor;
|
|
_graphicsDebugLevel = graphicsDebugLevel;
|
|
}
|
|
|
|
protected override void OnWindowDestroying()
|
|
{
|
|
Context.Dispose();
|
|
base.OnWindowDestroying();
|
|
}
|
|
|
|
public override void OnWindowCreated()
|
|
{
|
|
base.OnWindowCreated();
|
|
|
|
if (OperatingSystem.IsWindows())
|
|
{
|
|
_window = new WGLWindow(new NativeHandle(WindowHandle));
|
|
}
|
|
else if (OperatingSystem.IsLinux())
|
|
{
|
|
_window = X11Window;
|
|
}
|
|
else
|
|
{
|
|
throw new PlatformNotSupportedException();
|
|
}
|
|
|
|
var flags = OpenGLContextFlags.Compat;
|
|
if (_graphicsDebugLevel != GraphicsDebugLevel.None)
|
|
{
|
|
flags |= OpenGLContextFlags.Debug;
|
|
}
|
|
|
|
Context = PlatformHelper.CreateOpenGLContext(FramebufferFormat.Default, _major, _minor, flags);
|
|
|
|
Context.Initialize(_window);
|
|
Context.MakeCurrent(_window);
|
|
|
|
var bindingsContext = new OpenToolkitBindingsContext(Context.GetProcAddress);
|
|
|
|
GL.LoadBindings(bindingsContext);
|
|
Context.MakeCurrent(null);
|
|
}
|
|
|
|
public void MakeCurrent()
|
|
{
|
|
Context?.MakeCurrent(_window);
|
|
}
|
|
|
|
public void MakeCurrent(NativeWindowBase window)
|
|
{
|
|
Context?.MakeCurrent(window);
|
|
}
|
|
|
|
public void SwapBuffers()
|
|
{
|
|
_window.SwapBuffers();
|
|
}
|
|
}
|
|
} |