diff --git a/Assets/dll/mupen64plus.dll b/Assets/dll/mupen64plus.dll index 33c0df9adf..1bc2bcc28e 100644 Binary files a/Assets/dll/mupen64plus.dll and b/Assets/dll/mupen64plus.dll differ diff --git a/libmupen64plus/mupen64plus-core/src/api/vidext_sdl2_compat.h b/libmupen64plus/mupen64plus-core/src/api/vidext_sdl2_compat.h index 53da2bf49b..6d8f781e35 100644 --- a/libmupen64plus/mupen64plus-core/src/api/vidext_sdl2_compat.h +++ b/libmupen64plus/mupen64plus-core/src/api/vidext_sdl2_compat.h @@ -636,6 +636,10 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) /* If we're in OpenGL mode, just create a stub surface and we're done! */ if (flags & SDL_OPENGL) { + // make sure to set version/flag attributes, those might have been changed from the defaults + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, 0); SDL_VideoContext = SDL_GL_CreateContext(SDL_VideoWindow); if (!SDL_VideoContext) { return NULL; diff --git a/src/BizHawk.Bizware.Graphics.Controls/Controls/OpenGLControl.cs b/src/BizHawk.Bizware.Graphics.Controls/Controls/OpenGLControl.cs index 107759e1f7..c9c5a6c354 100644 --- a/src/BizHawk.Bizware.Graphics.Controls/Controls/OpenGLControl.cs +++ b/src/BizHawk.Bizware.Graphics.Controls/Controls/OpenGLControl.cs @@ -41,7 +41,7 @@ namespace BizHawk.Bizware.Graphics.Controls protected override void OnHandleCreated(EventArgs e) { base.OnHandleCreated(e); - Context = new(Handle, 3, 2, true, false); + Context = new(Handle, 3, 2, true); } protected override void OnHandleDestroyed(EventArgs e) diff --git a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs index 3ae9573750..af66b7706b 100644 --- a/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs +++ b/src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs @@ -30,17 +30,6 @@ namespace BizHawk.Bizware.Graphics throw new($"Could not load default OpenGL library! SDL Error: {SDL_GetError()}"); } - // set some sensible defaults - SDL_GL_ResetAttributes(); - if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) is not 0 - || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) is not 0 - || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) is not 0 - || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) is not 0 - || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) is not 0) - { - throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}"); - } - // we will be turning a foreign window into an SDL window // we need this so it knows that it is capable of using OpenGL functions SDL_SetHint(SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL, "1"); @@ -58,8 +47,19 @@ namespace BizHawk.Bizware.Graphics private IntPtr _sdlWindow; private IntPtr _glContext; - private void CreateContext(int majorVersion, int minorVersion, bool coreProfile, bool forwardCompatible) + private void CreateContext(int majorVersion, int minorVersion, bool coreProfile) { + // set some sensible defaults + SDL_GL_ResetAttributes(); + if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 0) is not 0 + || SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1) is not 0) + { + throw new($"Could not set GL attributes! SDL Error: {SDL_GetError()}"); + } + if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, majorVersion) != 0) { throw new($"Could not set GL Major Version! SDL Error: {SDL_GetError()}"); @@ -70,13 +70,6 @@ namespace BizHawk.Bizware.Graphics throw new($"Could not set GL Minor Version! SDL Error: {SDL_GetError()}"); } - // TODO: Debug flag / debug callback with DEBUG build - if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, forwardCompatible - ? (int)SDL_GLcontext.SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG : 0) != 0) - { - throw new($"Could not set GL Context Flags! SDL Error: {SDL_GetError()}"); - } - #if DEBUG_OPENGL if (SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, (int)SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG) != 0) { @@ -111,7 +104,7 @@ namespace BizHawk.Bizware.Graphics #endif } - public SDL2OpenGLContext(IntPtr nativeWindowhandle, int majorVersion, int minorVersion, bool coreProfile, bool forwardCompatible) + public SDL2OpenGLContext(IntPtr nativeWindowhandle, int majorVersion, int minorVersion, bool coreProfile) { _sdlWindow = SDL_CreateWindowFrom(nativeWindowhandle); if (_sdlWindow == IntPtr.Zero) @@ -125,10 +118,10 @@ namespace BizHawk.Bizware.Graphics throw new($"Could not set share context attribute! SDL Error: {SDL_GetError()}"); } - CreateContext(majorVersion, minorVersion, coreProfile, forwardCompatible); + CreateContext(majorVersion, minorVersion, coreProfile); } - public SDL2OpenGLContext(int majorVersion, int minorVersion, bool coreProfile, bool forwardCompatible) + public SDL2OpenGLContext(int majorVersion, int minorVersion, bool coreProfile) { _sdlWindow = SDL_CreateWindow(null, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1, 1, SDL_WindowFlags.SDL_WINDOW_OPENGL | SDL_WindowFlags.SDL_WINDOW_HIDDEN); @@ -144,7 +137,7 @@ namespace BizHawk.Bizware.Graphics throw new($"Could not set share context attribute! SDL Error: {SDL_GetError()}"); } - CreateContext(majorVersion, minorVersion, coreProfile, forwardCompatible); + CreateContext(majorVersion, minorVersion, coreProfile); } public void Dispose() diff --git a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs index 117e66c71f..c8418da1e0 100644 --- a/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs +++ b/src/BizHawk.Client.EmuHawk/GraphicsImplementations/OpenGLProvider.cs @@ -13,8 +13,8 @@ namespace BizHawk.Client.EmuHawk public bool SupportsGLVersion(int major, int minor) => OpenGLVersion.SupportsVersion(major, minor); - public object RequestGLContext(int major, int minor, bool coreProfile, bool forwardCompatible) - => new SDL2OpenGLContext(major, minor, coreProfile, forwardCompatible); + public object RequestGLContext(int major, int minor, bool coreProfile) + => new SDL2OpenGLContext(major, minor, coreProfile); public void ReleaseGLContext(object context) => ((SDL2OpenGLContext)context).Dispose(); diff --git a/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs b/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs index 3d498f5264..61e0e74935 100644 --- a/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs +++ b/src/BizHawk.Emulation.Common/Interfaces/IOpenGLProvider.cs @@ -14,13 +14,12 @@ namespace BizHawk.Emulation.Common public bool SupportsGLVersion(int major, int minor); /// - /// Requests an OpenGL context with specified major / minor + /// Requests an OpenGL context with specified major / minor version /// The core profile can be requested (otherwise, the compatibility profile will be used) - /// The forward compatible bit can also be requested /// The requested OpenGL context will be shared with the current context /// Note: creating a context implicitly makes that created context current /// - public object RequestGLContext(int major, int minor, bool coreProfile, bool forwardCompatible); + public object RequestGLContext(int major, int minor, bool coreProfile); /// /// Frees this OpenGL context diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs index ac709d26b7..1b4c176ad4 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs @@ -169,7 +169,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.N3DS private IntPtr RequestGLContextCallback() { - var context = _openGLProvider.RequestGLContext(4, 3, true, false); + var context = _openGLProvider.RequestGLContext(4, 3, true); _glContexts.Add(context); var handle = GCHandle.Alloc(context, GCHandleType.Weak); return GCHandle.ToIntPtr(handle); diff --git a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs index 634d11137b..1d882581fb 100644 --- a/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs +++ b/src/BizHawk.Emulation.Cores/Consoles/Nintendo/NDS/MelonDS.cs @@ -162,7 +162,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS } else { - _glContext = _openGLProvider.RequestGLContext(majorGlVersion, minorGlVersion, true, false); + _glContext = _openGLProvider.RequestGLContext(majorGlVersion, minorGlVersion, true); } } @@ -174,7 +174,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.NDS } else { - _glContext = _openGLProvider.RequestGLContext(3, 1, true, false); + _glContext = _openGLProvider.RequestGLContext(3, 1, true); } }