summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f8c006b)
raw | patch | inline | side by side (parent: f8c006b)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sat, 19 Jun 2021 11:13:42 +0000 (14:13 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 29 Jun 2021 09:51:12 +0000 (12:51 +0300) |
src/game/opengl/r_render.pas | patch | blob | history | |
src/game/sdl/g_system.pas | patch | blob | history | |
src/game/sdl2/g_system.pas | patch | blob | history |
index 668fb901f4e850dcd843a09ce3342daaecdccda2..483bd53282af43d03cbeb2e5f53331f2404ebb1b 100644 (file)
implementation
- uses SysUtils, Classes, e_log, g_system, g_game, g_options, r_window, r_graphics, r_console, r_playermodel;
+ uses
+ {$INCLUDE ../../nogl/noGLuses.inc}
+ SysUtils, Classes,
+ e_log, g_system,
+ g_game, g_options, r_window, r_graphics, r_console, r_playermodel
+ ;
+
+ var
+ LoadedGL: Boolean = false;
+
+ procedure LoadGL;
+ begin
+ if LoadedGL = false then
+ begin
+ {$IFDEF NOGL_INIT}
+ nogl_Init;
+ if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then
+ begin
+ e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
+ glRenderToFBO := false
+ end;
+ {$ELSE}
+ if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then
+ begin
+ e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
+ glRenderToFBO := false
+ end;
+ {$ENDIF}
+ LoadedGL := true
+ end
+ end;
+
+ procedure FreeGL;
+ begin
+ if LoadedGL = true then
+ begin
+ {$IFDEF NOGL_INIT}
+ nogl_Quit
+ {$ENDIF}
+ LoadedGL := false
+ end
+ end;
procedure r_Render_Initialize;
begin
if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = False then
raise Exception.Create('Failed to set videomode on startup.');
-
+ LoadGL;
r_Window_Initialize;
r_Console_Init;
r_PlayerModel_Initialize;
procedure r_Render_Finalize;
begin
+ FreeGL;
r_PlayerModel_Finalize;
e_ReleaseEngine
end;
procedure r_Render_Resize (w, h: Integer);
begin
+ LoadGL;
gWinSizeX := w;
gWinSizeY := h;
gRC_Width := w;
index d61dd32687131875cb94971afe76b3e6380e3425..11fd1e08917bc047cf7e3bc60f9f16508f1176d2 100644 (file)
uses
SysUtils, SDL, Math,
- {$INCLUDE ../nogl/noGLuses.inc}
- e_log, r_graphics, e_input, e_sound,
+ e_log, e_input, e_sound,
g_options, g_console, g_game, g_menu, g_gui, g_basic;
const
(* --------- 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;
-
function GetTitle (): PChar;
var info: AnsiString;
begin
screen := SDL_SetVideoMode(w, h, bpp, flags);
if screen <> nil then
begin
- if not LoadGL then
- begin
- e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal);
- exit;
- end;
SDL_WM_SetCaption(GetTitle(), nil);
gFullScreen := fullscreen;
gRC_FullScreen := fullscreen;
if g_dbg_input then
e_LogWritefln('Input Debug: SDL_VIDEORESIZE %s %s', [ev.w, ev.h]);
if (modeResize = 1) and (@sys_ScreenResize <> nil) then
- sys_ScreenResize(ev.w, ev.h);
+ sys_ScreenResize(ev.w, ev.h)
else if modeResize > 1 then
InitWindow(ev.w, ev.h, gBPP, gFullscreen)
end;
for i := 0 to e_MaxJoys - 1 do
RemoveJoystick(i);
if screen <> nil then
- begin
- FreeGL;
- SDL_FreeSurface(screen)
- end;
+ SDL_FreeSurface(screen);
SDL_Quit
end;
index 5468afb36645a728039d44582cae616022672cf9..c6f2cbf9f1c5e127aa62fe2309eb3be4ade48b02 100644 (file)
uses
SysUtils, SDL2, Math, ctypes,
- e_log, r_graphics, e_input, e_sound,
- {$INCLUDE ../nogl/noGLuses.inc}
+ e_log, e_input, e_sound,
{$IFDEF ENABLE_HOLMES}
g_holmes, sdlcarcass, fui_ctls,
{$ENDIF}
(* --------- 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;
-
function GetTitle (): PChar;
var info: AnsiString;
begin
context := SDL_GL_CreateContext(window);
if context <> nil then
begin
- if not LoadGL then
- begin
- 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
SDL_GetWindowPosition(window, @x, @y);
e_WriteLog('Releasing SDL2', TMsgType.Notify);
if context <> nil then
begin
- FreeGL;
SDL_GL_DeleteContext(context);
context := nil;
end;