@@ -291,15 +291,15 @@ protected void createContext(final AppSettings settings) {
291291 disableNvidiaThreadedOptimizations ();
292292 useAngle = AppSettings .ANGLE_GLES3 .equals (settings .getRenderer ());
293293 configureVideoDriverHints (settings );
294- configureAngleHints (settings );
294+ configureOpenGLDriverHints (settings );
295295
296296 if (!SDL_InitSubSystem (SDL_WINDOW_SUBSYSTEM_FLAGS )) {
297297 throw new IllegalStateException ("Unable to initialize SDL video subsystem: " + SDL_GetError ());
298298 }
299299
300300 SDL_SetHint (SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE , "0" );
301301 SDL_GL_ResetAttributes ();
302- boolean srgbFramebufferRequested = configureGLAttributes (settings );
302+ configureGLAttributes (settings );
303303
304304 display = settings .isFullscreen () ? getDisplay (settings .getDisplay ()) : SDL_GetPrimaryDisplay ();
305305 SDL_DisplayMode videoMode = SDL_GetCurrentDisplayMode ((int ) display );
@@ -339,7 +339,7 @@ protected void createContext(final AppSettings settings) {
339339 if (DisplayScaleUtils .requestsHighDensityFramebuffer (settings .getDisplayScaleMode ())) {
340340 windowFlags |= SDL_WINDOW_HIGH_PIXEL_DENSITY ;
341341 }
342- window = createWindow (settings , requestWidth , requestHeight , windowFlags , srgbFramebufferRequested );
342+ window = SDL_CreateWindow (settings . getTitle () , requestWidth , requestHeight , windowFlags );
343343 if (window == NULL ) {
344344 throw new RuntimeException ("Failed to create SDL window: " + SDL_GetError ());
345345 }
@@ -452,10 +452,15 @@ private void configureVideoDriverHints(AppSettings settings) {
452452 }
453453 }
454454
455- private void configureAngleHints (AppSettings settings ) {
455+ private void configureOpenGLDriverHints (AppSettings settings ) {
456456 final boolean angleGles = AppSettings .ANGLE_GLES3 .equals (settings .getRenderer ());
457457 if (!angleGles ) {
458- resetAngleHints ();
458+ resetAngleLibraries ();
459+ if (org .lwjgl .system .Platform .get () == org .lwjgl .system .Platform .LINUX && !settings .isX11PlatformPreferred ()) {
460+ SDL_SetHint (SDL_HINT_VIDEO_FORCE_EGL , "1" );
461+ } else {
462+ SDL_ResetHint (SDL_HINT_VIDEO_FORCE_EGL );
463+ }
459464 return ;
460465 }
461466
@@ -476,44 +481,20 @@ private void configureAngleHints(AppSettings settings) {
476481 SDL_SetHint (SDL_HINT_VIDEO_FORCE_EGL , "1" );
477482 }
478483
479- private void resetAngleHints () {
484+ private void resetAngleLibraries () {
480485 SDL_ResetHint (SDL_HINT_EGL_LIBRARY );
481486 SDL_ResetHint (SDL_HINT_OPENGL_LIBRARY );
482487 SDL_ResetHint (SDL_HINT_OPENGL_ES_DRIVER );
483- SDL_ResetHint (SDL_HINT_VIDEO_FORCE_EGL );
484488 Configuration .OPENGLES_LIBRARY_NAME .set (null );
485489 Configuration .EGL_LIBRARY_NAME .set (null );
486490 }
487491
488- private long createWindow (AppSettings settings , int width , int height , long flags ,
489- boolean srgbFramebufferRequested ) {
490- long createdWindow = SDL_CreateWindow (settings .getTitle (), width , height , flags );
491- if (createdWindow != NULL || !srgbFramebufferRequested ) {
492- return createdWindow ;
493- }
494-
495- String initialError = SDL_GetError ();
496- LOGGER .log (Level .WARNING ,
497- "Unable to create an sRGB-capable SDL window, retrying with a linear default framebuffer and shader sRGB conversion: {0}" ,
498- initialError );
499- SDL_GL_SetAttribute (SDL_GL_FRAMEBUFFER_SRGB_CAPABLE , 0 );
500-
501- createdWindow = SDL_CreateWindow (settings .getTitle (), width , height , flags );
502- if (createdWindow == NULL ) {
503- String retryError = SDL_GetError ();
504- throw new RuntimeException ("Failed to create SDL window: " + initialError
505- + "; retry without sRGB default framebuffer also failed: " + retryError );
506- }
507-
508- return createdWindow ;
509- }
510-
511- private boolean configureGLAttributes (AppSettings settings ) {
492+ private void configureGLAttributes (AppSettings settings ) {
512493 final String renderer = settings .getRenderer ();
513494 final boolean glesContext = AppSettings .ANGLE_GLES3 .equals (renderer );
514495 RENDER_CONFIGS .getOrDefault (renderer , RENDER_CONFIGS .get (AppSettings .LWJGL_OPENGL32 )).run ();
515496
516- if (glesContext && org .lwjgl .system .Platform .get () == org .lwjgl .system .Platform .LINUX ) {
497+ if (org .lwjgl .system .Platform .get () == org .lwjgl .system .Platform .LINUX ) {
517498 if (settings .isX11PlatformPreferred ()) {
518499 SDL_GL_SetAttribute (SDL_GL_EGL_PLATFORM , EGL_PLATFORM_X11_EXT );
519500 } else if ("wayland" .equalsIgnoreCase (System .getenv ("XDG_SESSION_TYPE" ))) {
@@ -537,12 +518,6 @@ private boolean configureGLAttributes(AppSettings settings) {
537518 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLEBUFFERS , settings .getSamples () > 0 ? 1 : 0 );
538519 SDL_GL_SetAttribute (SDL_GL_MULTISAMPLESAMPLES , Math .max (settings .getSamples (), 0 ));
539520
540- boolean srgbFramebufferRequested = false ;
541- if (!SDL_GL_SetAttribute (SDL_GL_FRAMEBUFFER_SRGB_CAPABLE , 0 )) {
542- throw new IllegalStateException ("SDL_GL_SetAttribute(SDL_GL_FRAMEBUFFER_SRGB_CAPABLE) failed: "
543- + SDL_GetError ());
544- }
545-
546521 if (settings .getBitsPerPixel () == 24 ) {
547522 SDL_GL_SetAttribute (SDL_GL_RED_SIZE , 8 );
548523 SDL_GL_SetAttribute (SDL_GL_GREEN_SIZE , 8 );
@@ -553,7 +528,6 @@ private boolean configureGLAttributes(AppSettings settings) {
553528 SDL_GL_SetAttribute (SDL_GL_BLUE_SIZE , 5 );
554529 }
555530
556- return srgbFramebufferRequested ;
557531 }
558532
559533 protected void updateSizes () {
0 commit comments