sound: allow to completelly disable sound
[d2df-sdl.git] / src / game / sdl2 / g_system.pas
blob662a899f60a4b00e445702c4967f6b82b828aa14
1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
16 unit g_system;
18 interface
20 uses Utils;
22 (* --- Utils --- *)
23 function sys_GetTicks (): Int64;
24 procedure sys_Delay (ms: Integer);
26 (* --- Graphics --- *)
27 function sys_GetDisplayModes (bpp: Integer): SSArray;
28 function sys_SetDisplayMode (w, h, bpp: Integer; fullscreen, maximized: Boolean): Boolean;
29 procedure sys_EnableVSync (yes: Boolean);
30 procedure sys_Repaint;
32 (* --- Input --- *)
33 function sys_HandleEvents (): Boolean;
34 procedure sys_RequestQuit;
36 (* --- Init --- *)
37 procedure sys_Init;
38 procedure sys_Final;
40 implementation
42 uses
43 SysUtils, SDL2, Math, ctypes,
44 e_log, e_graphics, e_input,
45 {$INCLUDE ../nogl/noGLuses.inc}
46 {$IFDEF ENABLE_HOLMES}
47 g_holmes, sdlcarcass, fui_ctls,
48 {$ENDIF}
49 {$IFDEF ENABLE_SOUND}
50 e_sound,
51 {$ENDIF}
52 g_touch, g_options, g_window, g_console, g_game, g_menu, g_gui, g_main, g_basic;
54 const
55 GameTitle = 'Doom 2D: Forever (SDL 2, %s)';
57 var
58 window: PSDL_Window;
59 context: TSDL_GLContext;
60 display, wx, wy: Integer;
61 wc: Boolean;
62 JoystickHandle: array [0..e_MaxJoys - 1] of PSDL_Joystick;
63 JoystickHatState: array [0..e_MaxJoys - 1, 0..e_MaxJoyHats - 1, HAT_LEFT..HAT_DOWN] of Boolean;
64 JoystickZeroAxes: array [0..e_MaxJoys - 1, 0..e_MaxJoyAxes - 1] of Integer;
66 (* --------- Utils --------- *)
68 function sys_GetTicks (): Int64;
69 begin
70 result := SDL_GetTicks()
71 end;
73 procedure sys_Delay (ms: Integer);
74 begin
75 SDL_Delay(ms)
76 end;
78 (* --------- Graphics --------- *)
80 function LoadGL: Boolean;
81 var ltmp: Integer;
82 begin
83 result := true;
84 {$IFDEF NOGL_INIT}
85 nogl_Init;
86 if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then
87 begin
88 e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
89 glRenderToFBO := false;
90 end;
91 {$ELSE}
92 if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then
93 begin
94 e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
95 glRenderToFBO := false;
96 end;
97 {$ENDIF}
98 if SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, @ltmp) = 0 then
99 begin
100 e_LogWritefln('stencil buffer size: %s', [ltmp]);
101 gwin_has_stencil := (ltmp > 0);
102 end;
103 end;
105 procedure FreeGL;
106 begin
107 {$IFDEF NOGL_INIT}
108 nogl_Quit();
109 {$ENDIF}
110 end;
112 procedure UpdateSize (w, h: Integer);
113 begin
114 gWinSizeX := w;
115 gWinSizeY := h;
116 gRC_Width := w;
117 gRC_Height := h;
118 if glRenderToFBO then
119 begin
120 // store real window size in gWinSize, downscale resolution now
121 w := round(w / r_pixel_scale);
122 h := round(h / r_pixel_scale);
123 if not e_ResizeFramebuffer(w, h) then
124 begin
125 e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
126 glRenderToFBO := False;
127 w := gWinSizeX;
128 h := gWinSizeY;
129 end;
130 end;
131 gScreenWidth := w;
132 gScreenHeight := h;
133 {$IFDEF ENABLE_HOLMES}
134 fuiScrWdt := w;
135 fuiScrHgt := h;
136 {$ENDIF}
137 e_ResizeWindow(w, h);
138 e_InitGL;
139 g_Game_SetupScreenSize;
140 {$IFNDEF ANDROID}
141 (* This will fix menu reset on keyboard showing *)
142 g_Menu_Reset;
143 {$ENDIF}
144 g_Game_ClearLoading;
145 {$IFDEF ENABLE_HOLMES}
146 if assigned(oglInitCB) then oglInitCB;
147 {$ENDIF}
148 end;
150 function GetTitle (): AnsiString;
151 var info: AnsiString;
152 begin
153 info := g_GetBuildHash(false);
154 if info = 'custom build' then
155 info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME;
156 result := Format(GameTitle, [info]);
157 end;
159 function InitWindow (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean;
160 var flags: UInt32; x, y: cint; title: AnsiString;
161 begin
162 // NB: On window close, do this for FlexUI: if @oglDeinitCB <> nil then oglDeinitCB();
163 e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
164 result := false;
165 if window = nil then
166 begin
167 {$IFDEF USE_GLES1}
168 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
169 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
170 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
171 {$ELSE}
172 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
173 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
174 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
175 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
176 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
177 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
178 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
179 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // lights; it is enough to have 1-bit stencil buffer for lighting, but...
180 {$ENDIF}
181 flags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE;
182 if fullScreen then flags := flags or SDL_WINDOW_FULLSCREEN;
183 if maximized then flags := flags or SDL_WINDOW_MAXIMIZED;
184 if wc then
185 begin
186 x := SDL_WINDOWPOS_CENTERED;
187 y := SDL_WINDOWPOS_CENTERED
189 else
190 begin
191 x := wx;
192 y := wy
193 end;
194 title := GetTitle();
195 window := SDL_CreateWindow(PChar(title), x, y, w, h, flags);
196 if window <> nil then
197 begin
198 context := SDL_GL_CreateContext(window);
199 if context <> nil then
200 begin
201 if not LoadGL then
202 begin
203 e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal);
204 SDL_GL_DeleteContext(context); context := nil;
205 exit;
206 end;
207 if (fullscreen = false) and (maximized = false) and (wc = false) then
208 begin
209 SDL_GetWindowPosition(window, @x, @y);
210 wx := x; wy := y
211 end;
212 gFullScreen := fullscreen;
213 gWinMaximized := maximized;
214 gRC_FullScreen := fullscreen;
215 gRC_Maximized := maximized;
216 UpdateSize(w, h);
217 result := true
219 else
220 begin
221 // SDL_DestroyWindow(window);
222 e_LogWritefln('SDL: unable to create OpenGL context: %s', [SDL_GetError])
225 else
226 begin
227 e_LogWritefln('SDL: unable to create window: %s', [SDL_GetError])
230 else
231 begin
232 if fullScreen then flags := SDL_WINDOW_FULLSCREEN else flags := 0;
233 SDL_SetWindowFullscreen(window, flags);
234 SDL_SetWindowSize(window, w, h);
235 if maximized then SDL_MaximizeWindow(window);
236 // always reset to center when changing fullscreen->windowed for safety purposes
237 if wc or (gFullscreen and not fullscreen) or (gWinMaximized and not maximized) then
238 begin
239 x := SDL_WINDOWPOS_CENTERED;
240 y := SDL_WINDOWPOS_CENTERED
242 else
243 begin
244 x := wx;
245 y := wy
246 end;
247 SDL_SetWindowPosition(window, x, y);
248 if (fullscreen = false) and (maximized = false) and (wc = false) then
249 begin
250 SDL_GetWindowPosition(window, @x, @y);
251 wx := x; wy := y
252 end;
253 gFullScreen := fullscreen;
254 gWinMaximized := maximized;
255 gRC_FullScreen := fullscreen;
256 gRC_Maximized := maximized;
257 UpdateSize(w, h);
258 result := true
260 end;
262 procedure sys_Repaint;
263 begin
264 SDL_GL_SwapWindow(window)
265 end;
267 procedure sys_EnableVSync (yes: Boolean);
268 begin
269 SDL_GL_SetSwapInterval(Ord(yes));
270 end;
272 function sys_GetDisplayModes (bpp: Integer): SSArray;
273 var i, count, num, pw, ph: Integer; m: TSDL_DisplayMode;
274 begin
275 result := nil;
276 num := SDL_GetNumDisplayModes(display);
277 if num < 0 then
278 e_LogWritefln('SDL: unable to get number of available display modes: %s', [SDL_GetError]);
279 if num > 0 then
280 begin
281 e_LogWritefln('Video modes for display %s:', [display]);
282 SetLength(result, num);
283 i := 0; count := 0; pw := 0; ph := 0;
284 while i < num do
285 begin
286 SDL_GetDisplayMode(display, i, @m);
287 if ((pw <> m.w) or (ph <> m.h)) then
288 begin
289 e_LogWritefln('* %sx%sx%s@%s', [m.w, m.h, SDL_BITSPERPIXEL(m.format), m.refresh_rate]);
290 pw := m.w; ph := m.h;
291 result[count] := IntToStr(m.w) + 'x' + IntToStr(m.h);
292 Inc(count);
294 else
295 begin
296 e_LogWritefln('- %sx%sx%s@%s', [m.w, m.h, SDL_BITSPERPIXEL(m.format), m.refresh_rate]);
297 end;
298 Inc(i)
299 end;
300 SetLength(result, count)
302 end;
304 function sys_SetDisplayMode (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean;
305 begin
306 result := InitWindow(w, h, bpp, fullScreen, maximized)
307 end;
309 (* --------- Joystick --------- *)
311 procedure HandleJoyButton (var ev: TSDL_JoyButtonEvent);
312 var down: Boolean; key: Integer;
313 begin
314 if (ev.which < e_MaxJoys) and (ev.button < e_MaxJoyBtns) then
315 begin
316 key := e_JoyButtonToKey(ev.which, ev.button);
317 down := ev.type_ = SDL_JOYBUTTONDOWN;
318 if g_dbg_input then
319 e_LogWritefln('Input Debug: jbutton, joy=%s, button=%s, keycode=%s, press=%s', [ev.which, ev.button, key, down]);
320 e_KeyUpDown(key, down);
321 g_Console_ProcessBind(key, down)
323 else
324 begin
325 if g_dbg_input then
326 begin
327 down := ev.type_ = SDL_JOYBUTTONDOWN;
328 e_LogWritefln('Input Debug: NOT IN RANGE! jbutton, joy=%s, button=%s, press=%s', [ev.which, ev.button, down])
331 end;
333 procedure HandleJoyAxis (var ev: TSDL_JoyAxisEvent);
334 var key, minuskey: Integer;
335 begin
336 if (ev.which < e_MaxJoys) and (ev.axis < e_MaxJoyAxes) then
337 begin
338 key := e_JoyAxisToKey(ev.which, ev.axis, AX_PLUS);
339 minuskey := e_JoyAxisToKey(ev.which, ev.axis, AX_MINUS);
341 if g_dbg_input then
342 e_LogWritefln('Input Debug: jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev.which, ev.axis, ev.value, JoystickZeroAxes[ev.which, ev.axis], e_JoystickDeadzones[ev.which]]);
344 if ev.value < JoystickZeroAxes[ev.which, ev.axis] - e_JoystickDeadzones[ev.which] then
345 begin
346 if (e_KeyPressed(key)) then
347 begin
348 e_KeyUpDown(key, False);
349 g_Console_ProcessBind(key, False)
350 end;
351 e_KeyUpDown(minuskey, True);
352 g_Console_ProcessBind(minuskey, True)
354 else if ev.value > JoystickZeroAxes[ev.which, ev.axis] + e_JoystickDeadzones[ev.which] then
355 begin
356 if (e_KeyPressed(minuskey)) then
357 begin
358 e_KeyUpDown(minuskey, False);
359 g_Console_ProcessBind(minuskey, False)
360 end;
361 e_KeyUpDown(key, True);
362 g_Console_ProcessBind(key, True)
364 else
365 begin
366 if (e_KeyPressed(minuskey)) then
367 begin
368 e_KeyUpDown(minuskey, False);
369 g_Console_ProcessBind(minuskey, False)
370 end;
371 if (e_KeyPressed(key)) then
372 begin
373 e_KeyUpDown(key, False);
374 g_Console_ProcessBind(key, False)
378 else
379 begin
380 if g_dbg_input then
381 e_LogWritefln('Input Debug: NOT IN RANGE! jaxis, joy=%s, axis=%s, value=%s, zeroaxes=%s, deadzone=%s', [ev.which, ev.axis, ev.value, JoystickZeroAxes[ev.which, ev.axis], e_JoystickDeadzones[ev.which]])
383 end;
385 procedure HandleJoyHat (var ev: TSDL_JoyHatEvent);
387 down: Boolean;
388 i, key: Integer;
389 hat: array [HAT_LEFT..HAT_DOWN] of Boolean;
390 begin
391 if (ev.which < e_MaxJoys) and (ev.hat < e_MaxJoyHats) then
392 begin
393 if g_dbg_input then
394 e_LogWritefln('Input Debug: jhat, joy=%s, hat=%s, value=%s', [ev.which, ev.hat, ev.value]);
395 hat[HAT_UP] := LongBool(ev.value and SDL_HAT_UP);
396 hat[HAT_DOWN] := LongBool(ev.value and SDL_HAT_DOWN);
397 hat[HAT_LEFT] := LongBool(ev.value and SDL_HAT_LEFT);
398 hat[HAT_RIGHT] := LongBool(ev.value and SDL_HAT_RIGHT);
399 for i := HAT_LEFT to HAT_DOWN do
400 begin
401 if JoystickHatState[ev.which, ev.hat, i] <> hat[i] then
402 begin
403 down := hat[i];
404 key := e_JoyHatToKey(ev.which, ev.hat, i);
405 e_KeyUpDown(key, down);
406 g_Console_ProcessBind(key, down)
408 end;
409 JoystickHatState[ev.which, ev.hat] := hat
411 else
412 begin
413 if g_dbg_input then
414 e_LogWritefln('Input Debug: NOT IN RANGE! jhat, joy=%s, hat=%s, value=%s', [ev.which, ev.hat, ev.value])
416 end;
418 procedure HandleJoyAdd (var ev: TSDL_JoyDeviceEvent);
419 var i: Integer;
420 begin
421 if (ev.which < e_MaxJoys) then
422 begin
423 JoystickHandle[ev.which] := SDL_JoystickOpen(ev.which);
424 if JoystickHandle[ev.which] <> nil then
425 begin
426 e_LogWritefln('Added Joystick %s', [ev.which]);
427 e_JoystickAvailable[ev.which] := True;
428 for i := 0 to Min(SDL_JoystickNumAxes(JoystickHandle[ev.which]), e_MaxJoyAxes) - 1 do
429 JoystickZeroAxes[ev.which, i] := SDL_JoystickGetAxis(JoystickHandle[ev.which], i)
431 else
432 begin
433 e_LogWritefln('Warning! Failed to open Joystick %s', [ev.which])
436 else
437 begin
438 e_LogWritefln('Warning! Added Joystick %s, but we support only <= %s', [ev.which, e_MaxJoys])
440 end;
442 procedure HandleJoyRemove (var ev: TSDL_JoyDeviceEvent);
443 begin
444 e_LogWritefln('Removed Joystick %s', [ev.which]);
445 if (ev.which < e_MaxJoys) then
446 begin
447 e_JoystickAvailable[ev.which] := False;
448 if JoystickHandle[ev.which] <> nil then
449 SDL_JoystickClose(JoystickHandle[ev.which]);
450 JoystickHandle[ev.which] := nil
452 end;
454 (* --------- Input --------- *)
456 function HandleWindow (var ev: TSDL_WindowEvent): Boolean;
457 begin
458 result := false;
459 if g_dbg_input then
460 e_LogWritefln('Window Event: event = %s, data1 = %s, data2 = %s', [ev.event, ev.data1, ev.data2]);
461 case ev.event of
462 SDL_WINDOWEVENT_RESIZED: UpdateSize(ev.data1, ev.data2);
463 SDL_WINDOWEVENT_EXPOSED: sys_Repaint;
464 SDL_WINDOWEVENT_CLOSE: result := true;
465 SDL_WINDOWEVENT_MOVED:
466 begin
467 wx := ev.data1;
468 wy := ev.data2
469 end;
470 SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED:
471 begin
472 e_UnpressAllKeys;
473 {$IFDEF ENABLE_SOUND}
474 if gMuteWhenInactive then
475 e_MuteChannels(true);
476 {$ENDIF}
477 {$IFDEF ENABLE_HOLMES}
478 if assigned(winBlurCB) then winBlurCB;
479 {$ENDIF}
480 end;
481 SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_RESTORED:
482 begin
483 if ev.event = SDL_WINDOWEVENT_MAXIMIZED then
484 begin
485 gWinMaximized := true;
486 gRC_Maximized := true
488 else if ev.event = SDL_WINDOWEVENT_RESTORED then
489 begin
490 gWinMaximized := false;
491 gRC_Maximized := false
492 end;
493 {$IFDEF ENABLE_SOUND}
494 e_MuteChannels(false);
495 {$ENDIF}
496 {$IFDEF ENABLE_HOLMES}
497 if assigned(winFocusCB) then winFocusCB;
498 {$ENDIF}
499 end;
501 end;
503 procedure HandleKeyboard (var ev: TSDL_KeyboardEvent);
504 var down: Boolean; key: Integer;
505 begin
506 key := ev.keysym.scancode;
507 down := (ev.type_ = SDL_KEYDOWN);
508 if key = SDL_SCANCODE_AC_BACK then
509 key := SDL_SCANCODE_ESCAPE;
510 {$IFDEF ENABLE_HOLMES}
511 if fuiOnSDLEvent(PSDL_Event(@ev)^) then
512 begin
513 // event eaten, but...
514 if not down then e_KeyUpDown(key, false);
515 exit;
516 end;
517 {$ENDIF}
518 if ev._repeat = 0 then
519 begin
520 if g_dbg_input then
521 e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s', [down, key]);
522 e_KeyUpDown(key, down);
523 g_Console_ProcessBind(key, down);
525 else
526 begin
527 if g_dbg_input then
528 e_LogWritefln('Input Debug: keyrep, scancode=%s', [key]);
529 g_Console_ProcessBindRepeat(key);
531 end;
533 procedure HandleTextInput (var ev: TSDL_TextInputEvent);
534 var ch: UnicodeChar; sch: AnsiChar;
535 begin
536 Utf8ToUnicode(@ch, PChar(ev.text), 1);
537 sch := AnsiChar(wchar2win(ch));
538 if g_dbg_input then
539 e_LogWritefln('Input Debug: text, text="%s", ch = %s, sch = %s', [ev.text, Ord(ch), Ord(sch)]);
540 if IsValid1251(Word(ch)) and IsPrintable1251(ch) then
541 CharPress(sch);
542 end;
544 function sys_HandleEvents (): Boolean;
545 var ev: TSDL_Event;
546 begin
547 result := false;
548 ZeroMemory(@ev, sizeof(ev));
549 while SDL_PollEvent(@ev) <> 0 do
550 begin
551 case ev.type_ of
552 SDL_QUITEV: result := true;
553 SDL_WINDOWEVENT: result := HandleWindow(ev.window);
554 SDL_KEYUP, SDL_KEYDOWN: HandleKeyboard(ev.key);
555 SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: HandleJoyButton(ev.jbutton);
556 SDL_JOYAXISMOTION: HandleJoyAxis(ev.jaxis);
557 SDL_JOYHATMOTION: HandleJoyHat(ev.jhat);
558 SDL_JOYDEVICEADDED: HandleJoyAdd(ev.jdevice);
559 SDL_JOYDEVICEREMOVED: HandleJoyRemove(ev.jdevice);
560 SDL_TEXTINPUT: HandleTextInput(ev.text);
561 SDL_FINGERMOTION, SDL_FINGERDOWN, SDL_FINGERUP: g_Touch_HandleEvent(ev.tfinger);
562 {$IFDEF ENABLE_HOLMES}
563 SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION: fuiOnSDLEvent(ev);
564 {$ENDIF}
567 end;
569 procedure sys_RequestQuit;
570 var ev: TSDL_Event;
571 begin
572 ev.type_ := SDL_QUITEV;
573 SDL_PushEvent(@ev)
574 end;
576 (* --------- Init --------- *)
578 procedure sys_Init;
579 var flags: UInt32;
580 begin
581 e_WriteLog('Init SDL2', TMsgType.Notify);
582 {$IFDEF HEADLESS}
583 {$IFDEF USE_SDLMIXER}
584 flags := SDL_INIT_TIMER or SDL_INIT_AUDIO or $00004000;
585 {$ELSE}
586 flags := SDL_INIT_TIMER or $00004000;
587 {$ENDIF}
588 {$ELSE}
589 flags := SDL_INIT_TIMER or SDL_INIT_VIDEO;
590 {$ENDIF}
591 SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, '0');
592 if SDL_Init(flags) <> 0 then
593 raise Exception.Create('SDL: Init failed: ' + SDL_GetError);
594 {$IFNDEF HEADLESS}
595 if SDL_InitSubSystem(SDL_INIT_JOYSTICK) <> 0 then
596 e_LogWritefln('SDL: Init subsystem failed: %s', [SDL_GetError()]);
597 {$ENDIF}
598 SDL_ShowCursor(SDL_DISABLE);
599 end;
601 procedure sys_Final;
602 begin
603 e_WriteLog('Releasing SDL2', TMsgType.Notify);
604 if context <> nil then
605 begin
606 FreeGL;
607 SDL_GL_DeleteContext(context);
608 context := nil;
609 end;
610 if window <> nil then
611 begin
612 SDL_DestroyWindow(window);
613 window := nil;
614 end;
615 SDL_Quit
616 end;
618 initialization
619 conRegVar('sdl2_display_index', @display, 'use display index as base', '');
620 conRegVar('sdl2_window_x', @wx, 'window position x', '');
621 conRegVar('sdl2_window_y', @wy, 'window position y', '');
622 conRegVar('sdl2_window_center', @wc, 'force window creation at center', '');
623 display := 0;
624 wx := SDL_WINDOWPOS_CENTERED;
625 wy := SDL_WINDOWPOS_CENTERED;
626 wc := false
627 end.