X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fsdl%2Fg_system.pas;h=7593b02398811605b2981aed31267e8760e8a20c;hb=c3750b33c7c32ef74637ae0f6be98974af391ab9;hp=a4cbe649a3f7b4fcb39f7d908365e366776c9903;hpb=14771a7395dda16d199b88c71d975d840c7e5b14;p=d2df-sdl.git diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index a4cbe64..7593b02 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -70,6 +70,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; @@ -125,15 +147,10 @@ implementation screen := SDL_SetVideoMode(w, h, bpp, flags); if screen <> 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); + exit; end; SDL_WM_SetCaption(GetTitle(), nil); gFullScreen := fullscreen; @@ -497,9 +514,7 @@ implementation RemoveJoystick(i); if screen <> nil then begin - {$IFDEF NOGL_INIT} - nogl_Quit; - {$ENDIF} + FreeGL; SDL_FreeSurface(screen) end; SDL_Quit