From: Dmitry D. Chernov Date: Thu, 23 Mar 2023 18:02:48 +0000 (+1000) Subject: Game: Fixed missing check for the availability of stencil buffer X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=e84299fd3f1bf3f58e7aeddc017d2b6dc835f676;p=d2df-sdl.git Game: Fixed missing check for the availability of stencil buffer This fixes experimental dynamic light effects ('light_enabled 1' and 'light_player_halo') which were broken by 0e101bd452c40da601236aaa2dd4106be47ddce1. It's worth noting that they even work on my laptop's integrated video if I just set 'gwin_has_stencil' to True, even though the driver says it doesn't support stencils. The discrete GPU on the same laptop reports it correctly. --- diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 0fcad1a..cc8704c 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -78,12 +78,22 @@ implementation (* --------- Graphics --------- *) function LoadGL: Boolean; + {$IFNDEF NOGL_INIT} + var + ltmp: Integer; + {$ENDIF} begin result := true; {$IFDEF NOGL_INIT} nogl_Init; if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then {$ELSE} + if SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp) = 0 then + begin + e_LogWritefln('stencil buffer size: %s', [ltmp]); + gwin_has_stencil := (ltmp > 0); + end; + if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then {$ENDIF} begin diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index 9cd1ee1..b3005d5 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -75,12 +75,22 @@ implementation (* --------- Graphics --------- *) function LoadGL: Boolean; + {$IFNDEF NOGL_INIT} + var + ltmp: Integer; + {$ENDIF} begin result := true; {$IFDEF NOGL_INIT} nogl_Init; if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then {$ELSE} + if SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp) = 0 then + begin + e_LogWritefln('stencil buffer size: %s', [ltmp]); + gwin_has_stencil := (ltmp > 0); + end; + if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then {$ENDIF} begin