summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0a3150d)
raw | patch | inline | side by side (parent: 0a3150d)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 14 Nov 2019 10:32:19 +0000 (13:32 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Thu, 14 Nov 2019 10:32:19 +0000 (13:32 +0300) |
src/game/g_game.pas | patch | blob | history | |
src/game/sdl2/g_system.pas | patch | blob | history |
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 054879203c5008a45ac9b60dbd9f17b4b869e409..ca8ee633877789f8b162f376495952d0c8800025 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
gTempDelete: Boolean = False;
gLastMap: Boolean = False;
gWinSizeX, gWinSizeY: Integer;
- gWinFrameX, gWinFrameY, gWinCaption: Integer;
- gWinActive: Boolean = True; // by default window is active, lol
gResolutionChange: Boolean = False;
gRC_Width, gRC_Height: Integer;
gRC_FullScreen, gRC_Maximized: Boolean;
begin
g_Console_Add(Format('gScreenWidth = %d, gScreenHeight = %d', [gScreenWidth, gScreenHeight]));
g_Console_Add(Format('gWinSizeX = %d, gWinSizeY = %d', [gWinSizeX, gWinSizeY]));
- g_Console_Add(Format('Frame X = %d, Y = %d, Caption Y = %d', [gWinFrameX, gWinFrameY, gWinCaption]));
end
else if cmd = 'd_sounds' then
begin
index 511e06200dd020c08d950a998c3025cc97c08b05..bfb76fb5bae1f5a69f01ff3f575ade72c80c2810 100644 (file)
implementation
uses
- SysUtils, SDL2, Math,
+ SysUtils, SDL2, Math, ctypes,
e_log, e_graphics, e_input, e_sound,
{$INCLUDE ../nogl/noGLuses.inc}
{$IFDEF ENABLE_HOLMES}
var
window: PSDL_Window;
context: TSDL_GLContext;
- display: Integer;
+ display, wx, wy: Integer;
+ wc: Boolean;
JoystickHandle: array [0..e_MaxJoys - 1] of PSDL_Joystick;
JoystickHatState: array [0..e_MaxJoys - 1, 0..e_MaxJoyHats - 1, HAT_LEFT..HAT_DOWN] of Boolean;
JoystickZeroAxes: array [0..e_MaxJoys - 1, 0..e_MaxJoyAxes - 1] of Integer;
end;
function InitWindow (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean;
- var flags: UInt32; x, y: Integer;
+ var flags: UInt32; x, y: cint;
begin
// note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB;
e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
flags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE;
if fullScreen then flags := flags or SDL_WINDOW_FULLSCREEN;
if maximized then flags := flags or SDL_WINDOW_MAXIMIZED;
- x := SDL_WINDOWPOS_CENTERED;
- y := SDL_WINDOWPOS_CENTERED;
+ if wc then
+ begin
+ x := SDL_WINDOWPOS_CENTERED;
+ y := SDL_WINDOWPOS_CENTERED
+ end
+ else
+ begin
+ x := wx;
+ y := wy
+ end;
window := SDL_CreateWindow(GetTitle(), x, y, w, h, flags);
if window <> nil then
begin
{$IFDEF NOGL_INIT}
nogl_Init;
{$ENDIF}
+ if (fullscreen = false) and (maximized = false) and (wc = false) then
+ begin
+ SDL_GetWindowPosition(window, @x, @y);
+ wx := x; wy := y
+ end;
gFullScreen := fullscreen;
gWinMaximized := maximized;
gRC_FullScreen := fullscreen;
end
else
begin
+ // SDL_DestroyWindow(window);
e_LogWritefln('SDL: unable to create OpenGL context: %s', [SDL_GetError])
end
end
else
begin
SDL_SetWindowSize(window, w, h);
+ if wc then
+ begin
+ x := SDL_WINDOWPOS_CENTERED;
+ y := SDL_WINDOWPOS_CENTERED
+ end
+ else
+ begin
+ x := wx;
+ y := wy
+ end;
+ SDL_SetWindowPosition(window, x, y);
+ if (fullscreen = false) and (maximized = false) and (wc = false) then
+ begin
+ SDL_GetWindowPosition(window, @x, @y);
+ wx := x; wy := y
+ end;
if maximized then
SDL_MaximizeWindow(window);
if fullScreen then flags := SDL_WINDOW_FULLSCREEN else flags := 0;
SDL_WINDOWEVENT_RESIZED: UpdateSize(ev.data1, ev.data2);
SDL_WINDOWEVENT_EXPOSED: sys_Repaint;
SDL_WINDOWEVENT_CLOSE: result := true;
+ SDL_WINDOWEVENT_MOVED:
+ begin
+ wx := ev.data1;
+ wy := ev.data2
+ end;
SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED:
begin
e_UnpressAllKeys;
SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_RESTORED:
begin
if ev.event = SDL_WINDOWEVENT_MAXIMIZED then
+ begin
+ gWinMaximized := true;
gRC_Maximized := true
+ end
else if ev.event = SDL_WINDOWEVENT_RESTORED then
- gRC_Maximized := false;
+ begin
+ gWinMaximized := false;
+ gRC_Maximized := false
+ end;
e_MuteChannels(false);
{$IFDEF ENABLE_HOLMES}
if assigned(winFocusCB) then winFocusCB;
initialization
conRegVar('sdl2_display_index', @display, 'use display index as base', '');
+ conRegVar('sdl2_window_x', @wx, 'window position x', '');
+ conRegVar('sdl2_window_y', @wy, 'window position y', '');
+ conRegVar('sdl2_window_center', @wc, 'force window creation at center', '');
+ display := 0;
+ wx := SDL_WINDOWPOS_CENTERED;
+ wy := SDL_WINDOWPOS_CENTERED;
+ wc := false
end.