Skip to content

Commit 3b62a38

Browse files
More properly fix EGL issues
1 parent fdb7a0d commit 3b62a38

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/BizHawk.Bizware.Graphics/OpenGL/SDL2OpenGLContext.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// #define DEBUG_OPENGL
22

3-
using System.IO;
4-
53
#if DEBUG_OPENGL
64
using System.Runtime.InteropServices;
7-
using Silk.NET.OpenGL;
85
#endif
96

7+
using Silk.NET.OpenGL;
8+
109
using BizHawk.Common;
10+
using BizHawk.Common.StringExtensions;
1111

1212
using static SDL2.SDL;
1313

@@ -31,7 +31,7 @@ static SDL2OpenGLContext()
3131
// try to use EGL if it is available
3232
// GLX is the old API, and is the more or less "deprecated" at this point, and potentially more buggy with some drivers
3333
// we do need to a bit more work, in case EGL is not actually available or potentially doesn't have desktop GL support
34-
if (!Directory.Exists("/nix")/* this is just for me --yoshi */) SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
34+
SDL_SetHint(SDL_HINT_VIDEO_X11_FORCE_EGL, "1");
3535
}
3636

3737
// init SDL video
@@ -51,6 +51,22 @@ static SDL2OpenGLContext()
5151
{
5252
// check if we can actually create a desktop GL context
5353
using var glContext = new SDL2OpenGLContext(3, 2, true);
54+
using var gl = GL.GetApi(GetGLProcAddress);
55+
var versionString = gl.GetStringS(StringName.Version);
56+
if (versionString.ContainsOrdinal("OpenGL ES"))
57+
{
58+
// driver ended up creating a GL ES context regardless
59+
// hopefully GLX works here
60+
loadGlx = true;
61+
}
62+
else
63+
{
64+
// check if we did in fact get at least GL 3.2
65+
var versionParts = versionString!.Split('.');
66+
var major = int.Parse(versionParts[0]);
67+
var minor = int.Parse(versionParts[1][0].ToString());
68+
loadGlx = major * 10 + minor < 320;
69+
}
5470
}
5571
catch
5672
{

0 commit comments

Comments
 (0)