diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 3a29d0803081a585868b03fdd87b0bd01b7e8748..8336ea9b82cb39b11cd0b5b95c8e992e8cc3b0dd 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
uses
{$IFDEF WINDOWS}Windows,{$ENDIF}
-{$IFDEF USE_NANOGL}
- nanoGL,
-{$ELSE}
- GL, GLExt,
+{$INCLUDE ../nogl/noGLuses.inc}
+{$IFDEF ENABLE_HOLMES}
+ g_holmes, sdlcarcass, fui_ctls,
{$ENDIF}
SysUtils, Classes, MAPDEF,
SDL2, e_graphics, e_log, e_texture, g_main,
g_console, e_input, g_options, g_game,
g_basic, g_textures, e_sound, g_sound, g_menu, ENet, g_net,
- g_map, g_gfx, g_monsters, g_holmes, xprofiler,
- sdlcarcass, fui_ctls,
+ g_map, g_gfx, g_monsters, xprofiler,
g_touch;
procedure KillGLWindow (preserveGL: Boolean);
begin
+{$IFDEF ENABLE_HOLMES}
if (h_GL <> nil) and (not preserveGL) then begin if (assigned(oglDeinitCB)) then oglDeinitCB(); end;
+{$ENDIF}
if (h_Wnd <> nil) then SDL_DestroyWindow(h_Wnd);
if (h_GL <> nil) and (not preserveGL) then
begin
+
{$IFDEF USE_NANOGL}
nanoGL_Destroy;
-{$ENDIF USE_NANOGL}
+{$ENDIF}
+
+{$IFDEF USE_NOGL}
+ nogl_Quit;
+{$ENDIF}
+
SDL_GL_DeleteContext(h_GL);
end;
h_Wnd := nil;
e_WriteLog('SDL: fullscreen window got invalid size: '+IntToStr(nw)+'x'+IntToStr(nh), TMsgType.Notify);
end;
end;
- fuiScrWdt := gScreenWidth;
- fuiScrHgt := gScreenHeight;
- if (h_GL <> nil) and (not preserveGL) then begin if (assigned(oglInitCB)) then oglInitCB(); end;
+
+ {$IFDEF ENABLE_HOLMES}
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
+ if (h_GL <> nil) and (not preserveGL) then begin if (assigned(oglInitCB)) then oglInitCB(); end;
+ {$ENDIF}
{$ENDIF}
result := true;
end;
-procedure ChangeWindowSize ();
+procedure ChangeWindowSize (requested: Boolean);
begin
e_LogWritefln(' ChangeWindowSize: (ws=%dx%d) (ss=%dx%d)', [gWinSizeX, gWinSizeY, gScreenWidth, gScreenHeight]);
gWinSizeX := gScreenWidth;
gWinSizeY := gScreenHeight;
{$IF not DEFINED(HEADLESS)}
- fuiScrWdt := gScreenWidth;
- fuiScrHgt := gScreenHeight;
+ {$IFDEF ENABLE_HOLMES}
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
+ {$ENDIF}
e_ResizeWindow(gScreenWidth, gScreenHeight);
g_Game_SetupScreenSize();
- g_Menu_Reset();
+ {$IF DEFINED(ANDROID)}
+ (* This will fix menu reset on keyboard showing *)
+ if requested then
+ g_Menu_Reset;
+ {$ELSE}
+ g_Menu_Reset;
+ {$ENDIF}
g_Game_ClearLoading();
{$ENDIF}
end;
if result then
begin
g_Window_SetDisplay(preserve);
- ChangeWindowSize();
+ ChangeWindowSize(true);
end;
{$ENDIF}
end;
SDL_WINDOWEVENT_MINIMIZED:
begin
e_UnpressAllKeys();
+ if (gPlayer1 <> nil) then gPlayer1.releaseAllWeaponSwitchKeys();
+ if (gPlayer2 <> nil) then gPlayer2.releaseAllWeaponSwitchKeys();
if not wMinimized then
begin
e_ResizeWindow(0, 0);
gScreenWidth := ev.data1;
gScreenHeight := ev.data2;
end;
- ChangeWindowSize();
+ ChangeWindowSize(false);
SwapBuffers();
if g_debug_WinMsgs then
begin
begin
wDeactivate := true;
e_UnpressAllKeys();
+ if (gPlayer1 <> nil) then gPlayer1.releaseAllWeaponSwitchKeys();
+ if (gPlayer2 <> nil) then gPlayer2.releaseAllWeaponSwitchKeys();
//e_WriteLog('window lost focus!', MSG_NOTIFY);
end;
end;
gWinActive := false;
- if assigned(winBlurCB) then winBlurCB();
+ {$IFDEF ENABLE_HOLMES}
+ if assigned(winBlurCB) then winBlurCB();
+ {$ENDIF}
end;
end
else if wActivate then
end;
gWinActive := true;
- if assigned(winFocusCB) then winFocusCB();
+
+ {$IFDEF ENABLE_HOLMES}
+ if assigned(winFocusCB) then winFocusCB();
+ {$ENDIF}
end;
end;
end;
if key = SDL_SCANCODE_AC_BACK then
key := SDL_SCANCODE_ESCAPE;
down := (ev.type_ = SDL_KEYDOWN);
- {$IF not DEFINED(HEADLESS)}
+ {$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)}
if fuiOnSDLEvent(ev) then
begin
// event eaten, but...
exit;
end;
{$ENDIF}
- if down then KeyPress(key);
e_KeyUpDown(key, down);
+ if down then KeyPress(key);
end;
- {$IF not DEFINED(HEADLESS)}
+ {$IF not DEFINED(HEADLESS) and DEFINED(ENABLE_HOLMES)}
SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION:
fuiOnSDLEvent(ev);
{$ENDIF}
{$IF not DEFINED(HEADLESS)}
h_GL := SDL_GL_CreateContext(h_Wnd);
if (h_GL = nil) then exit;
- fuiScrWdt := gScreenWidth;
- fuiScrHgt := gScreenHeight;
+ {$IFDEF ENABLE_HOLMES}
+ fuiScrWdt := gScreenWidth;
+ fuiScrHgt := gScreenHeight;
+ {$ENDIF}
SDL_GL_MakeCurrent(h_Wnd, h_GL);
{$IFDEF USE_NANOGL}
if nanoGL_Init() = 0 then
exit;
end;
{$ENDIF}
- if (assigned(oglInitCB)) then oglInitCB();
+{$IFDEF USE_NOGL}
+ nogl_Init;
+{$ENDIF}
+ {$IFDEF ENABLE_HOLMES}
+ if (assigned(oglInitCB)) then oglInitCB();
+ {$ENDIF}
if (h_GL <> nil) then g_SetVSync(gVSync);
{$ENDIF}
procedure InitOpenGL ();
begin
{$IF not DEFINED(HEADLESS)}
- {$IFDEF USE_NANOGL}
+ {$IFDEF USE_GLES1}
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
{$ENDIF}
arg: AnsiString;
mdfo: TStream;
+ {$IFDEF ENABLE_HOLMES}
itmp: Integer;
valres: Word;
+ {$ENDIF}
begin
{$IFDEF HEADLESS}
e_NoGraphics := true;
{$ELSE}
- if (not g_holmes_imfunctional) then
- begin
- uiInitialize();
- uiContext.font := 'win14';
- end;
+ {$IFDEF ENABLE_HOLMES}
+ if (not g_holmes_imfunctional) then
+ begin
+ uiInitialize();
+ uiContext.font := 'win14';
+ end;
+ {$ENDIF}
{$ENDIF}
idx := 1;
if arg = '--aimline' then g_dbg_aimline_on := true;
{.$ENDIF}
+{$IFDEF ENABLE_HOLMES}
if arg = '--holmes' then begin g_holmes_enabled := true; g_Game_SetDebugMode(); end;
if (arg = '--holmes-ui-scale') or (arg = '-holmes-ui-scale') then
Inc(idx);
end;
end;
+{$ENDIF}
if (arg = '--game-scale') or (arg = '-game-scale') then
begin
e_LogWritefln('stencil buffer size: %s', [ltmp]);
gwin_has_stencil := (ltmp > 0);
- if not glHasExtension('GL_ARB_texture_non_power_of_two') then
+ if glHasExtension('GL_ARB_texture_non_power_of_two') or
+ glHasExtension('GL_OES_texture_npot') then
begin
- e_WriteLog('NPOT textures: NO', TMsgType.Warning);
- glLegacyNPOT := true;
+ e_WriteLog('NPOT textures: YES', TMsgType.Notify);
+ glLegacyNPOT := false;
end
else
begin
- e_WriteLog('NPOT textures: YES', TMsgType.Notify);
- glLegacyNPOT := false;
+ e_WriteLog('NPOT textures: NO', TMsgType.Warning);
+ glLegacyNPOT := true;
end;
gwin_dump_extensions := false;
{$ENDIF}