DEADSOFTWARE

cleanup: remove g_main.pas
[d2df-sdl.git] / src / game / sdl2 / g_system.pas
1 (* Copyright (C) Doom 2D: Forever Developers
2 *
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.
6 *
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.
11 *
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/>.
14 *)
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_HandleInput (): Boolean;
34 procedure sys_RequestQuit;
36 (* --- Init --- *)
37 procedure sys_Init;
38 procedure sys_Final;
40 var (* hooks *)
41 sys_CharPress: procedure (ch: AnsiChar) = nil;
43 implementation
45 uses
46 SysUtils, SDL2, Math, ctypes,
47 e_log, r_graphics, e_input, e_sound,
48 {$INCLUDE ../nogl/noGLuses.inc}
49 {$IFDEF ENABLE_HOLMES}
50 g_holmes, sdlcarcass, fui_ctls,
51 {$ENDIF}
52 g_touch, g_options, g_window, g_console, g_game, g_menu, g_gui, 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 begin
82 result := true;
83 {$IFDEF NOGL_INIT}
84 nogl_Init;
85 if glRenderToFBO and (not nogl_ExtensionSupported('GL_OES_framebuffer_object')) then
86 {$ELSE}
87 if glRenderToFBO and (not Load_GL_ARB_framebuffer_object) then
88 {$ENDIF}
89 begin
90 e_LogWriteln('GL: framebuffer objects not supported; disabling FBO rendering');
91 glRenderToFBO := false;
92 end;
93 end;
95 procedure FreeGL;
96 begin
97 {$IFDEF NOGL_INIT}
98 nogl_Quit();
99 {$ENDIF}
100 end;
102 procedure UpdateSize (w, h: Integer);
103 begin
104 gWinSizeX := w;
105 gWinSizeY := h;
106 gRC_Width := w;
107 gRC_Height := h;
108 if glRenderToFBO then
109 begin
110 // store real window size in gWinSize, downscale resolution now
111 w := round(w / r_pixel_scale);
112 h := round(h / r_pixel_scale);
113 if not e_ResizeFramebuffer(w, h) then
114 begin
115 e_LogWriteln('GL: could not create framebuffer, falling back to --no-fbo');
116 glRenderToFBO := False;
117 w := gWinSizeX;
118 h := gWinSizeY;
119 end;
120 end;
121 gScreenWidth := w;
122 gScreenHeight := h;
123 {$IFDEF ENABLE_HOLMES}
124 fuiScrWdt := w;
125 fuiScrHgt := h;
126 {$ENDIF}
127 e_ResizeWindow(w, h);
128 e_InitGL;
129 g_Game_SetupScreenSize;
130 {$IFNDEF ANDROID}
131 (* This will fix menu reset on keyboard showing *)
132 g_Menu_Reset;
133 {$ENDIF}
134 g_Game_ClearLoading;
135 {$IFDEF ENABLE_HOLMES}
136 if assigned(oglInitCB) then oglInitCB;
137 {$ENDIF}
138 end;
140 function GetTitle (): PChar;
141 var info: AnsiString;
142 begin
143 info := g_GetBuildHash(false);
144 if info = 'custom build' then
145 info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME;
146 result := PChar(Format(GameTitle, [info]))
147 end;
149 function InitWindow (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean;
150 var flags: UInt32; x, y: cint;
151 begin
152 // note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB;
153 e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]);
154 result := false;
155 if window = nil then
156 begin
157 {$IFDEF USE_GLES1}
158 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
159 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
160 SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
161 {$ELSE}
162 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
163 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
164 SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
165 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
166 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
167 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
168 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
169 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); // lights; it is enough to have 1-bit stencil buffer for lighting, but...
170 {$ENDIF}
171 flags := SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE;
172 if fullScreen then flags := flags or SDL_WINDOW_FULLSCREEN;
173 if maximized then flags := flags or SDL_WINDOW_MAXIMIZED;
174 if wc then
175 begin
176 x := SDL_WINDOWPOS_CENTERED;
177 y := SDL_WINDOWPOS_CENTERED
178 end
179 else
180 begin
181 x := wx;
182 y := wy
183 end;
184 window := SDL_CreateWindow(GetTitle(), x, y, w, h, flags);
185 if window <> nil then
186 begin
187 context := SDL_GL_CreateContext(window);
188 if context <> nil then
189 begin
190 if not LoadGL then
191 begin
192 e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal);
193 SDL_GL_DeleteContext(context); context := nil;
194 exit;
195 end;
196 if (fullscreen = false) and (maximized = false) and (wc = false) then
197 begin
198 SDL_GetWindowPosition(window, @x, @y);
199 wx := x; wy := y
200 end;
201 gFullScreen := fullscreen;
202 gWinMaximized := maximized;
203 gRC_FullScreen := fullscreen;
204 gRC_Maximized := maximized;
205 UpdateSize(w, h);
206 result := true
207 end
208 else
209 begin
210 // SDL_DestroyWindow(window);
211 e_LogWritefln('SDL: unable to create OpenGL context: %s', [SDL_GetError])
212 end
213 end
214 else
215 begin
216 e_LogWritefln('SDL: unable to create window: %s', [SDL_GetError])
217 end
218 end
219 else
220 begin
221 if fullScreen then flags := SDL_WINDOW_FULLSCREEN else flags := 0;
222 SDL_SetWindowFullscreen(window, flags);
223 SDL_SetWindowSize(window, w, h);
224 if maximized then SDL_MaximizeWindow(window);
225 // always reset to center when changing fullscreen->windowed for safety purposes
226 if wc or (gFullscreen and not fullscreen) or (gWinMaximized and not maximized) then
227 begin
228 x := SDL_WINDOWPOS_CENTERED;
229 y := SDL_WINDOWPOS_CENTERED
230 end
231 else
232 begin
233 x := wx;
234 y := wy
235 end;
236 SDL_SetWindowPosition(window, x, y);
237 if (fullscreen = false) and (maximized = false) and (wc = false) then
238 begin
239 SDL_GetWindowPosition(window, @x, @y);
240 wx := x; wy := y
241 end;
242 gFullScreen := fullscreen;
243 gWinMaximized := maximized;
244 gRC_FullScreen := fullscreen;
245 gRC_Maximized := maximized;
246 UpdateSize(w, h);
247 result := true
248 end
249 end;
251 procedure sys_Repaint;
252 begin
253 SDL_GL_SwapWindow(window)
254 end;
256 procedure sys_EnableVSync (yes: Boolean);
257 begin
258 if yes then
259 SDL_GL_SetSwapInterval(1)
260 else
261 SDL_GL_SetSwapInterval(0)
262 end;
264 function sys_GetDisplayModes (bpp: Integer): SSArray;
265 var i, count, num, pw, ph: Integer; m: TSDL_DisplayMode;
266 begin
267 result := nil;
268 num := SDL_GetNumDisplayModes(display);
269 if num < 0 then
270 e_LogWritefln('SDL: unable to get numer of available display modes: %s', [SDL_GetError]);
271 if num > 0 then
272 begin
273 e_LogWritefln('Video modes for display %s:', [display]);
274 SetLength(result, num);
275 i := 0; count := 0; pw := 0; ph := 0;
276 while i < num do
277 begin
278 SDL_GetDisplayMode(display, i, @m);
279 if ((pw <> m.w) or (ph <> m.h)) then
280 begin
281 e_LogWritefln('* %sx%sx%s@%s', [m.w, m.h, SDL_BITSPERPIXEL(m.format), m.refresh_rate]);
282 pw := m.w; ph := m.h;
283 result[count] := IntToStr(m.w) + 'x' + IntToStr(m.h);
284 Inc(count);
285 end
286 else
287 begin
288 e_LogWritefln('- %sx%sx%s@%s', [m.w, m.h, SDL_BITSPERPIXEL(m.format), m.refresh_rate]);
289 end;
290 Inc(i)
291 end;
292 SetLength(result, count)
293 end
294 end;
296 function sys_SetDisplayMode (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean;
297 begin
298 result := InitWindow(w, h, bpp, fullScreen, maximized)
299 end;
301 (* --------- Joystick --------- *)
303 procedure HandleJoyButton (var ev: TSDL_JoyButtonEvent);
304 var down: Boolean; key: Integer;
305 begin
306 if (ev.which < e_MaxJoys) and (ev.button < e_MaxJoyBtns) then
307 begin
308 key := e_JoyButtonToKey(ev.which, ev.button);
309 down := ev.type_ = SDL_JOYBUTTONDOWN;
310 if g_dbg_input then
311 e_LogWritefln('Input Debug: jbutton, joy=%s, button=%s, keycode=%s, press=%s', [ev.which, ev.button, key, down]);
312 e_KeyUpDown(key, down);
313 g_Console_ProcessBind(key, down)
314 end
315 else
316 begin
317 if g_dbg_input then
318 begin
319 down := ev.type_ = SDL_JOYBUTTONDOWN;
320 e_LogWritefln('Input Debug: NOT IN RANGE! jbutton, joy=%s, button=%s, press=%s', [ev.which, ev.button, down])
321 end
322 end
323 end;
325 procedure HandleJoyAxis (var ev: TSDL_JoyAxisEvent);
326 var key, minuskey: Integer;
327 begin
328 if (ev.which < e_MaxJoys) and (ev.axis < e_MaxJoyAxes) then
329 begin
330 key := e_JoyAxisToKey(ev.which, ev.axis, AX_PLUS);
331 minuskey := e_JoyAxisToKey(ev.which, ev.axis, AX_MINUS);
333 if g_dbg_input then
334 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]]);
336 if ev.value < JoystickZeroAxes[ev.which, ev.axis] - e_JoystickDeadzones[ev.which] then
337 begin
338 if (e_KeyPressed(key)) then
339 begin
340 e_KeyUpDown(key, False);
341 g_Console_ProcessBind(key, False)
342 end;
343 e_KeyUpDown(minuskey, True);
344 g_Console_ProcessBind(minuskey, True)
345 end
346 else if ev.value > JoystickZeroAxes[ev.which, ev.axis] + e_JoystickDeadzones[ev.which] then
347 begin
348 if (e_KeyPressed(minuskey)) then
349 begin
350 e_KeyUpDown(minuskey, False);
351 g_Console_ProcessBind(minuskey, False)
352 end;
353 e_KeyUpDown(key, True);
354 g_Console_ProcessBind(key, True)
355 end
356 else
357 begin
358 if (e_KeyPressed(minuskey)) then
359 begin
360 e_KeyUpDown(minuskey, False);
361 g_Console_ProcessBind(minuskey, False)
362 end;
363 if (e_KeyPressed(key)) then
364 begin
365 e_KeyUpDown(key, False);
366 g_Console_ProcessBind(key, False)
367 end
368 end
369 end
370 else
371 begin
372 if g_dbg_input then
373 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]])
374 end
375 end;
377 procedure HandleJoyHat (var ev: TSDL_JoyHatEvent);
378 var
379 down: Boolean;
380 i, key: Integer;
381 hat: array [HAT_LEFT..HAT_DOWN] of Boolean;
382 begin
383 if (ev.which < e_MaxJoys) and (ev.hat < e_MaxJoyHats) then
384 begin
385 if g_dbg_input then
386 e_LogWritefln('Input Debug: jhat, joy=%s, hat=%s, value=%s', [ev.which, ev.hat, ev.value]);
387 hat[HAT_UP] := LongBool(ev.value and SDL_HAT_UP);
388 hat[HAT_DOWN] := LongBool(ev.value and SDL_HAT_DOWN);
389 hat[HAT_LEFT] := LongBool(ev.value and SDL_HAT_LEFT);
390 hat[HAT_RIGHT] := LongBool(ev.value and SDL_HAT_RIGHT);
391 for i := HAT_LEFT to HAT_DOWN do
392 begin
393 if JoystickHatState[ev.which, ev.hat, i] <> hat[i] then
394 begin
395 down := hat[i];
396 key := e_JoyHatToKey(ev.which, ev.hat, i);
397 e_KeyUpDown(key, down);
398 g_Console_ProcessBind(key, down)
399 end
400 end;
401 JoystickHatState[ev.which, ev.hat] := hat
402 end
403 else
404 begin
405 if g_dbg_input then
406 e_LogWritefln('Input Debug: NOT IN RANGE! jhat, joy=%s, hat=%s, value=%s', [ev.which, ev.hat, ev.value])
407 end
408 end;
410 procedure HandleJoyAdd (var ev: TSDL_JoyDeviceEvent);
411 var i: Integer;
412 begin
413 if (ev.which < e_MaxJoys) then
414 begin
415 JoystickHandle[ev.which] := SDL_JoystickOpen(ev.which);
416 if JoystickHandle[ev.which] <> nil then
417 begin
418 e_LogWritefln('Added Joystick %s', [ev.which]);
419 e_JoystickAvailable[ev.which] := True;
420 for i := 0 to Min(SDL_JoystickNumAxes(JoystickHandle[ev.which]), e_MaxJoyAxes) - 1 do
421 JoystickZeroAxes[ev.which, i] := SDL_JoystickGetAxis(JoystickHandle[ev.which], i)
422 end
423 else
424 begin
425 e_LogWritefln('Warning! Failed to open Joystick %s', [ev.which])
426 end
427 end
428 else
429 begin
430 e_LogWritefln('Warning! Added Joystick %s, but we support only <= %s', [ev.which, e_MaxJoys])
431 end
432 end;
434 procedure HandleJoyRemove (var ev: TSDL_JoyDeviceEvent);
435 begin
436 e_LogWritefln('Removed Joystick %s', [ev.which]);
437 if (ev.which < e_MaxJoys) then
438 begin
439 e_JoystickAvailable[ev.which] := False;
440 if JoystickHandle[ev.which] <> nil then
441 SDL_JoystickClose(JoystickHandle[ev.which]);
442 JoystickHandle[ev.which] := nil
443 end
444 end;
446 (* --------- Input --------- *)
448 function HandleWindow (var ev: TSDL_WindowEvent): Boolean;
449 begin
450 result := false;
451 if g_dbg_input then
452 e_LogWritefln('Window Event: event = %s, data1 = %s, data2 = %s', [ev.event, ev.data1, ev.data2]);
453 case ev.event of
454 SDL_WINDOWEVENT_RESIZED: UpdateSize(ev.data1, ev.data2);
455 SDL_WINDOWEVENT_EXPOSED: sys_Repaint;
456 SDL_WINDOWEVENT_CLOSE: result := true;
457 SDL_WINDOWEVENT_MOVED:
458 begin
459 wx := ev.data1;
460 wy := ev.data2
461 end;
462 SDL_WINDOWEVENT_FOCUS_LOST, SDL_WINDOWEVENT_MINIMIZED:
463 begin
464 e_UnpressAllKeys;
465 if gMuteWhenInactive then
466 e_MuteChannels(true);
467 {$IFDEF ENABLE_HOLMES}
468 if assigned(winBlurCB) then winBlurCB;
469 {$ENDIF}
470 end;
471 SDL_WINDOWEVENT_FOCUS_GAINED, SDL_WINDOWEVENT_MAXIMIZED, SDL_WINDOWEVENT_RESTORED:
472 begin
473 if ev.event = SDL_WINDOWEVENT_MAXIMIZED then
474 begin
475 gWinMaximized := true;
476 gRC_Maximized := true
477 end
478 else if ev.event = SDL_WINDOWEVENT_RESTORED then
479 begin
480 gWinMaximized := false;
481 gRC_Maximized := false
482 end;
483 e_MuteChannels(false);
484 {$IFDEF ENABLE_HOLMES}
485 if assigned(winFocusCB) then winFocusCB;
486 {$ENDIF}
487 end;
488 end
489 end;
491 procedure HandleKeyboard (var ev: TSDL_KeyboardEvent);
492 var down: Boolean; key: Integer;
493 begin
494 key := ev.keysym.scancode;
495 down := (ev.type_ = SDL_KEYDOWN);
496 if key = SDL_SCANCODE_AC_BACK then
497 key := SDL_SCANCODE_ESCAPE;
498 {$IFDEF ENABLE_HOLMES}
499 if fuiOnSDLEvent(PSDL_Event(@ev)^) then
500 begin
501 // event eaten, but...
502 if not down then e_KeyUpDown(key, false);
503 exit;
504 end;
505 {$ENDIF}
506 if ev._repeat = 0 then
507 begin
508 if g_dbg_input then
509 e_LogWritefln('Input Debug: keysym, press=%s, scancode=%s', [down, key]);
510 e_KeyUpDown(key, down);
511 g_Console_ProcessBind(key, down);
512 end
513 else
514 begin
515 if g_dbg_input then
516 e_LogWritefln('Input Debug: keyrep, scancode=%s', [key]);
517 g_Console_ProcessBindRepeat(key);
518 end
519 end;
521 procedure HandleTextInput (var ev: TSDL_TextInputEvent);
522 var ch: UnicodeChar; sch: AnsiChar;
523 begin
524 Utf8ToUnicode(@ch, PChar(ev.text), 1);
525 sch := AnsiChar(wchar2win(ch));
526 if g_dbg_input then
527 e_LogWritefln('Input Debug: text, text="%s", ch = %s, sch = %s', [ev.text, Ord(ch), Ord(sch)]);
528 if @sys_CharPress <> nil then
529 if IsValid1251(Word(ch)) and IsPrintable1251(ch) then
530 sys_CharPress(sch)
531 end;
533 function sys_HandleInput (): Boolean;
534 var ev: TSDL_Event;
535 begin
536 result := false;
537 ZeroMemory(@ev, sizeof(ev));
538 while SDL_PollEvent(@ev) <> 0 do
539 begin
540 case ev.type_ of
541 SDL_QUITEV: result := true;
542 SDL_WINDOWEVENT: result := HandleWindow(ev.window);
543 SDL_KEYUP, SDL_KEYDOWN: HandleKeyboard(ev.key);
544 SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP: HandleJoyButton(ev.jbutton);
545 SDL_JOYAXISMOTION: HandleJoyAxis(ev.jaxis);
546 SDL_JOYHATMOTION: HandleJoyHat(ev.jhat);
547 SDL_JOYDEVICEADDED: HandleJoyAdd(ev.jdevice);
548 SDL_JOYDEVICEREMOVED: HandleJoyRemove(ev.jdevice);
549 SDL_TEXTINPUT: HandleTextInput(ev.text);
550 SDL_FINGERMOTION, SDL_FINGERDOWN, SDL_FINGERUP: g_Touch_HandleEvent(ev.tfinger);
551 {$IFDEF ENABLE_HOLMES}
552 SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, SDL_MOUSEWHEEL, SDL_MOUSEMOTION: fuiOnSDLEvent(ev);
553 {$ENDIF}
554 end
555 end
556 end;
558 procedure sys_RequestQuit;
559 var ev: TSDL_Event;
560 begin
561 ev.type_ := SDL_QUITEV;
562 SDL_PushEvent(@ev)
563 end;
565 (* --------- Init --------- *)
567 procedure sys_Init;
568 var flags: UInt32;
569 begin
570 e_WriteLog('Init SDL2', TMsgType.Notify);
571 {$IFDEF HEADLESS}
572 {$IFDEF USE_SDLMIXER}
573 flags := SDL_INIT_TIMER or SDL_INIT_AUDIO or $00004000;
574 {$ELSE}
575 flags := SDL_INIT_TIMER or $00004000;
576 {$ENDIF}
577 {$ELSE}
578 flags := SDL_INIT_TIMER or SDL_INIT_VIDEO;
579 {$ENDIF}
580 SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, '0');
581 if SDL_Init(flags) <> 0 then
582 raise Exception.Create('SDL: Init failed: ' + SDL_GetError);
583 {$IFNDEF HEADLESS}
584 if SDL_InitSubSystem(SDL_INIT_JOYSTICK) <> 0 then
585 e_LogWritefln('SDL: Init subsystem failed: %s', [SDL_GetError()]);
586 {$ENDIF}
587 SDL_ShowCursor(SDL_DISABLE);
588 end;
590 procedure sys_Final;
591 begin
592 e_WriteLog('Releasing SDL2', TMsgType.Notify);
593 if context <> nil then
594 begin
595 FreeGL;
596 SDL_GL_DeleteContext(context);
597 context := nil;
598 end;
599 if window <> nil then
600 begin
601 SDL_DestroyWindow(window);
602 window := nil;
603 end;
604 SDL_Quit
605 end;
607 initialization
608 conRegVar('sdl2_display_index', @display, 'use display index as base', '');
609 conRegVar('sdl2_window_x', @wx, 'window position x', '');
610 conRegVar('sdl2_window_y', @wy, 'window position y', '');
611 conRegVar('sdl2_window_center', @wc, 'force window creation at center', '');
612 display := 0;
613 wx := SDL_WINDOWPOS_CENTERED;
614 wy := SDL_WINDOWPOS_CENTERED;
615 wc := false
616 end.