X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fsdl2%2Fg_system.pas;h=31c5b1cde5c4147282cd52211f24446cd9a47e12;hb=e565c26d23694783974b5b8a971213e24a820654;hp=e4bd07046a8576bbecdc7763b13cbe282295e062;hpb=14771a7395dda16d199b88c71d975d840c7e5b14;p=d2df-sdl.git diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index e4bd070..31c5b1c 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -74,6 +74,28 @@ implementation (* --------- Graphics --------- *) + function LoadGL: Boolean; + begin + result := true; + {$IFDEF NOGL_INIT} + nogl_Init; + if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then + {$ELSE} + if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then + {$ENDIF} + begin + e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering'); + glRenderToFBO := false; + end; + end; + + procedure FreeGL; + begin + {$IFDEF NOGL_INIT} + nogl_Quit(); + {$ENDIF} + end; + procedure UpdateSize (w, h: Integer); begin gWinSizeX := w; @@ -156,15 +178,11 @@ implementation context := SDL_GL_CreateContext(window); if context <> nil then begin - {$IFDEF NOGL_INIT} - nogl_Init; - if (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) and glRenderToFBO then - {$ELSE} - if (not Load_GL_ARB_framebuffer_object()) and glRenderToFBO then - {$ENDIF} + if not LoadGL then begin - e_LogWriteln('SDL: no framebuffer object support detected'); - glRenderToFBO := False + e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal); + SDL_GL_DeleteContext(context); context := nil; + exit; end; if (fullscreen = false) and (maximized = false) and (wc = false) then begin @@ -564,9 +582,7 @@ implementation e_WriteLog('Releasing SDL2', TMsgType.Notify); if context <> nil then begin - {$IFDEF NOGL_INIT} - nogl_Quit; - {$ENDIF} + FreeGL; SDL_GL_DeleteContext(context); context := nil; end;