From 86761b84b67f3976b10ff56a3fcd6695caeef2fa Mon Sep 17 00:00:00 2001
From: Morilli <35152647+Morilli@users.noreply.github.com>
Date: Thu, 25 Jun 2026 13:11:36 +0200
Subject: [PATCH] remove OpenGLProvider and add project reference instead
---
.../GraphicsImplementations/OpenGLProvider.cs | 29 ------------
src/BizHawk.Client.EmuHawk/MainForm.cs | 3 +-
src/BizHawk.Emulation.Common/CoreComms.cs | 9 +---
.../Interfaces/IOpenGLProvider.cs | 44 -------------------
.../BizHawk.Emulation.Cores.csproj | 1 +
.../AmstradCPC/Media/Disk/FloppyDisk.cs | 7 ++-
.../SinclairSpectrum/Media/Disk/FloppyDisk.cs | 7 ++-
.../Consoles/Nintendo/3DS/Encore.IEmulator.cs | 2 +-
.../Consoles/Nintendo/3DS/Encore.cs | 23 +++++-----
.../Nintendo/NDS/MelonDS.ISettable.cs | 2 +-
.../Consoles/Nintendo/NDS/MelonDS.cs | 34 +++++---------
11 files changed, 33 insertions(+), 128 deletions(-)
delete mode 100644 src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs
delete mode 100644 src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs
diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs
deleted file mode 100644
index b4793c7e8d4..00000000000
--- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using BizHawk.Bizware.Graphics;
-using BizHawk.Emulation.Common;
-
-namespace BizHawk.Client.EmuHawk
-{
- ///
- /// Provides a way for a core to use OpenGL
- ///
- public class OpenGLProvider : IOpenGLProvider
- {
- public bool SupportsGLVersion(int major, int minor)
- => OpenGLVersion.SupportsVersion(major, minor);
-
- public object RequestGLContext(int major, int minor, bool coreProfile)
- => new SDL2OpenGLContext(major, minor, coreProfile);
-
- public void ReleaseGLContext(object context)
- => ((SDL2OpenGLContext)context).Dispose();
-
- public void ActivateGLContext(object context)
- => ((SDL2OpenGLContext)context).MakeContextCurrent();
-
- public void DeactivateGLContext()
- => SDL2OpenGLContext.MakeNoneCurrent();
-
- public IntPtr GetGLProcAddress(string proc)
- => SDL2OpenGLContext.GetGLProcAddress(proc);
- }
-}
diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs
index 13b08dd0b01..65232e21d0f 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.cs
@@ -322,8 +322,7 @@ public CoreComm CreateCoreComm()
message => this.ModalMessageBox(message, "Warning", EMsgBoxIcon.Warning),
AddOnScreenMessage,
cfp,
- prefs,
- new OpenGLProvider());
+ prefs);
}
private void SetImages()
diff --git a/src/BizHawk.Emulation.Common/CoreComms.cs b/src/BizHawk.Emulation.Common/CoreComms.cs
index 630e4228868..a7ce83cd453 100644
--- a/src/BizHawk.Emulation.Common/CoreComms.cs
+++ b/src/BizHawk.Emulation.Common/CoreComms.cs
@@ -18,15 +18,13 @@ public CoreComm(
ModalMessageBoxCallback showMessage,
AddOnScreenMessageCallback notifyMessage,
ICoreFileProvider coreFileProvider,
- CorePreferencesFlags prefs,
- IOpenGLProvider oglProvider
+ CorePreferencesFlags prefs
)
{
ShowMessage = showMessage;
Notify = notifyMessage;
CoreFileProvider = coreFileProvider;
CorePreferences = prefs;
- OpenGLProvider = oglProvider;
}
public ICoreFileProvider CoreFileProvider { get; }
@@ -53,10 +51,5 @@ public enum CorePreferencesFlags
/// Yeah, I put more stuff in corecomm. If you don't like it, change the settings/syncsettings stuff to support multiple "settings sets" to act like ini file sections kind of, so that we can hand a generic settings object to cores instead of strictly ones defined by the cores
///
public CorePreferencesFlags CorePreferences { get; }
-
- ///
- /// Interface to provide OpenGL resources to the core
- ///
- public IOpenGLProvider OpenGLProvider { get; }
}
}
diff --git a/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs b/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs
deleted file mode 100644
index 8acd2d0cbd3..00000000000
--- a/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-namespace BizHawk.Emulation.Common
-{
- ///
- /// Defines an interface for cores to obtain OpenGL contexts and functions
- ///
- public interface IOpenGLProvider
- {
- ///
- /// Checks if specified OpenGL version is supported
- /// The current context will be preserved
- ///
- bool SupportsGLVersion(int major, int minor);
-
- ///
- /// Requests an OpenGL context with specified major / minor version
- /// The core profile can be requested (otherwise, the compatibility profile will be used)
- /// The requested OpenGL context will be shared with the current context
- /// Note: creating a context implicitly makes that created context current
- ///
- object RequestGLContext(int major, int minor, bool coreProfile);
-
- ///
- /// Frees this OpenGL context
- ///
- void ReleaseGLContext(object context);
-
- ///
- /// Sets this OpenGL context to current
- ///
- void ActivateGLContext(object context);
-
- ///
- /// Deactivates the current OpenGL context
- /// No context will be current after this call
- ///
- void DeactivateGLContext();
-
- ///
- /// Gets an OpenGL function pointer
- /// The user must make a context active before using this
- ///
- IntPtr GetGLProcAddress(string? proc);
- }
-}
diff --git a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
index 16f5e5e251c..d99bba5f879 100644
--- a/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
+++ b/src/BizHawk.Emulation.Cores/BizHawk.Emulation.Cores.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs
index 581db2ef738..661e92972fd 100644
--- a/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs
+++ b/src/BizHawk.Emulation.Cores/Computers/AmstradCPC/Media/Disk/FloppyDisk.cs
@@ -1,11 +1,10 @@
-using BizHawk.Common;
-
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
-using BizHawk.Common.CollectionExtensions;
+using BizHawk.Common;
using BizHawk.Common.StringExtensions;
+using CollectionExtensions = BizHawk.Common.CollectionExtensions.CollectionExtensions;
namespace BizHawk.Emulation.Cores.Computers.AmstradCPC
{
diff --git a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs
index cbe56f61e13..0aaa5e45896 100644
--- a/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs
+++ b/src/BizHawk.Emulation.Cores/Computers/SinclairSpectrum/Media/Disk/FloppyDisk.cs
@@ -1,11 +1,10 @@
-using BizHawk.Common;
-
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Text;
-using BizHawk.Common.CollectionExtensions;
+using BizHawk.Common;
using BizHawk.Common.StringExtensions;
+using CollectionExtensions = BizHawk.Common.CollectionExtensions.CollectionExtensions;
namespace BizHawk.Emulation.Cores.Computers.SinclairSpectrum
{
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.IEmulator.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.IEmulator.cs
index 1ae176e10e3..118b6e20ce3 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.IEmulator.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.IEmulator.cs
@@ -82,7 +82,7 @@ public void Dispose()
foreach (var glContext in _glContexts)
{
- _openGLProvider.ReleaseGLContext(glContext);
+ glContext.Dispose();
}
_glContexts.Clear();
diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs
index eecb6b7a93b..79a61cab174 100644
--- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs
+++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs
@@ -5,6 +5,7 @@
using System.Text;
using BizHawk.BizInvoke;
+using BizHawk.Bizware.Graphics;
using BizHawk.Common;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.Common;
@@ -39,9 +40,8 @@ private static void ResetEncoreResolver()
private static Encore CurrentCore;
- private readonly IOpenGLProvider _openGLProvider;
private readonly bool _supportsOpenGL43;
- private readonly List