DEADSOFTWARE

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