1
1
// #define DEBUG_OPENGL
2
2
3
- using System . IO ;
4
-
5
3
#if DEBUG_OPENGL
6
4
using System . Runtime . InteropServices ;
7
- using Silk . NET . OpenGL ;
8
5
#endif
9
6
7
+ using Silk . NET . OpenGL ;
8
+
10
9
using BizHawk . Common ;
10
+ using BizHawk . Common . StringExtensions ;
11
11
12
12
using static SDL2 . SDL ;
13
13
@@ -31,7 +31,7 @@ static SDL2OpenGLContext()
31
31
// try to use EGL if it is available
32
32
// GLX is the old API, and is the more or less "deprecated" at this point, and potentially more buggy with some drivers
33
33
// 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" ) ;
35
35
}
36
36
37
37
// init SDL video
@@ -51,6 +51,22 @@ static SDL2OpenGLContext()
51
51
{
52
52
// check if we can actually create a desktop GL context
53
53
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
+ }
54
70
}
55
71
catch
56
72
{
0 commit comments