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, either version 3 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 {$INCLUDE ../shared/a_modes.inc}
24 function SDLMain (): Integer;
25 function GetTimer (): Int64;
26 procedure ResetTimer ();
27 procedure PushExitEvent ();
28 function ProcessMessage (): Boolean;
29 procedure ReDrawWindow ();
30 procedure SwapBuffers ();
31 procedure Sleep (ms
: LongWord);
32 function GetDisplayModes (dbpp
: LongWord; var selres
: LongWord): SSArray
;
33 function g_Window_SetDisplay (preserveGL
: Boolean=false): Boolean;
34 function g_Window_SetSize (w
, h
: Word; fullscreen
: Boolean): Boolean;
36 procedure ProcessLoading (forceUpdate
: Boolean=false);
38 // returns `true` if quit event was received
39 function g_ProcessMessages (): Boolean;
43 gwin_dump_extensions
: Boolean = false;
44 gwin_has_stencil
: Boolean = false;
45 gwin_k8_enable_light_experiments
: Boolean = false;
46 g_dbg_aimline_on
: Boolean = false;
52 {$IFDEF WINDOWS}Windows
,{$ENDIF}
53 SysUtils
, Classes
, MAPDEF
,
54 SDL2
, GL
, GLExt
, e_graphics
, e_log
, e_texture
, g_main
,
55 g_console
, e_input
, g_options
, g_game
,
56 g_basic
, g_textures
, e_sound
, g_sound
, g_menu
, ENet
, g_net
,
57 g_map
, g_gfx
, g_monsters
, g_holmes
, xprofiler
,
62 ProgressUpdateMSecs
= 1;//100;
65 h_Wnd
: PSDL_Window
= nil;
66 h_GL
: TSDL_GLContext
= nil;
67 Time
, Time_Delta
, Time_Old
: Int64;
69 {$IF not DEFINED(HEADLESS)}
71 wasFullscreen
: Boolean = true; // so we need to recreate the window
72 wMaximized
: Boolean = false;
74 wNeedTimeReset
: Boolean = false;
75 wMinimized
: Boolean = false;
76 wLoadingProgress
: Boolean = false;
77 wLoadingQuit
: Boolean = false;
79 ticksOverflow
: Int64 = -1;
80 lastTicks
: Uint32
= 0; // to detect overflow
84 procedure KillGLWindow (preserveGL
: Boolean);
86 if (h_GL
<> nil) and (not preserveGL
) then begin if (assigned(oglDeinitCB
)) then oglDeinitCB(); end;
87 if (h_Wnd
<> nil) then SDL_DestroyWindow(h_Wnd
);
88 if (h_GL
<> nil) and (not preserveGL
) then SDL_GL_DeleteContext(h_GL
);
90 if (not preserveGL
) then h_GL
:= nil;
94 function g_Window_SetDisplay (preserveGL
: Boolean = false): Boolean;
95 {$IF not DEFINED(HEADLESS)}
97 mode
, cmode
: TSDL_DisplayMode
;
102 {$IF not DEFINED(HEADLESS)}
105 e_WriteLog('Setting display mode...', TMsgType
.Notify
);
107 wFlags
:= SDL_WINDOW_OPENGL
{or SDL_WINDOW_RESIZABLE};
108 if gFullscreen
then wFlags
:= wFlags
or SDL_WINDOW_FULLSCREEN
else wFlags
:= wFlags
or SDL_WINDOW_RESIZABLE
;
109 if (not gFullscreen
) and (not preserveGL
) and gWinMaximized
then wFlags
:= wFlags
or SDL_WINDOW_MAXIMIZED
else gWinMaximized
:= false;
113 mode
.w
:= gScreenWidth
;
114 mode
.h
:= gScreenHeight
;
116 mode
.refresh_rate
:= 0;
117 mode
.driverdata
:= nil;
118 if (SDL_GetClosestDisplayMode(0, @mode
, @cmode
) = nil) then
120 e_WriteLog('SDL: cannot find display mode for '+IntToStr(gScreenWidth
), TMsgType
.Notify
);
122 gScreenHeight
:= 600;
126 e_WriteLog('SDL: found display mode for '+IntToStr(gScreenWidth
)+'x'+IntToStr(gScreenHeight
)+': '+IntToStr(cmode
.w
)+'x'+IntToStr(cmode
.h
), TMsgType
.Notify
);
127 gScreenWidth
:= cmode
.w
;
128 gScreenHeight
:= cmode
.h
;
132 if (preserveGL
) and (h_Wnd
<> nil) and (not gFullscreen
) and (not wasFullscreen
) then
134 //SDL_SetWindowMaximumSize(h_Wnd, gScreenWidth, gScreenHeight);
135 //SDL_SetWindowDisplayMode(h_Wnd, @cmode);
136 if (wMaximized
) then SDL_RestoreWindow(h_Wnd
);
138 gWinMaximized
:= false;
139 SDL_SetWindowSize(h_Wnd
, gScreenWidth
, gScreenHeight
);
140 //SDL_SetWindowFullscreen(h_Wnd, SDL_WINDOW_FULLSCREEN);
141 //SDL_SetWindowFullscreen(h_Wnd, 0);
145 KillGLWindow(preserveGL
);
146 h_Wnd
:= SDL_CreateWindow(PChar(wTitle
), gWinRealPosX
, gWinRealPosY
, gScreenWidth
, gScreenHeight
, wFlags
);
147 if (h_Wnd
= nil) then exit
;
149 wasFullscreen
:= gFullscreen
;
151 SDL_GL_MakeCurrent(h_Wnd
, h_GL
);
152 SDL_ShowCursor(SDL_DISABLE
);
153 if (gFullscreen
) then
157 SDL_GetWindowSize(h_Wnd
, @nw
, @nh
);
158 if (nw
> 128) and (nh
> 128) then
160 e_WriteLog('SDL: fullscreen window got size '+IntToStr(nw
)+'x'+IntToStr(nh
)+': '+IntToStr(gScreenWidth
)+'x'+IntToStr(gScreenHeight
), TMsgType
.Notify
);
166 e_WriteLog('SDL: fullscreen window got invalid size: '+IntToStr(nw
)+'x'+IntToStr(nh
), TMsgType
.Notify
);
169 fuiScrWdt
:= gScreenWidth
;
170 fuiScrHgt
:= gScreenHeight
;
171 if (h_GL
<> nil) and (not preserveGL
) then begin if (assigned(oglInitCB
)) then oglInitCB(); end;
178 function GetDisplayModes (dbpp
: LongWord; var selres
: LongWord): SSArray
;
180 mode
: TSDL_DisplayMode
;
181 res
, i
, k
, n
, pw
, ph
: Integer;
183 SetLength(result
, 0);
184 {$IFDEF HEADLESS}exit
;{$ENDIF}
186 n
:= SDL_GetNumDisplayModes(0);
190 res
:= SDL_GetDisplayMode(0, i
, @mode
);
191 if res
< 0 then continue
;
192 if SDL_BITSPERPIXEL(mode
.format
) = gBPP
then continue
;
193 if (mode
.w
= pw
) and (mode
.h
= ph
) then continue
;
194 if (mode
.w
= gScreenWidth
) and (mode
.h
= gScreenHeight
) then
197 SetLength(result
, k
);
198 result
[k
-1] := IntToStr(mode
.w
) + 'x' + IntToStr(mode
.h
);
199 pw
:= mode
.w
; ph
:= mode
.h
202 e_WriteLog('SDL: Got ' + IntToStr(k
) + ' resolutions.', TMsgType
.Notify
);
206 procedure Sleep (ms
: LongWord);
212 procedure ChangeWindowSize ();
214 e_LogWritefln(' ChangeWindowSize: (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
215 gWinSizeX
:= gScreenWidth
;
216 gWinSizeY
:= gScreenHeight
;
217 {$IF not DEFINED(HEADLESS)}
218 fuiScrWdt
:= gScreenWidth
;
219 fuiScrHgt
:= gScreenHeight
;
220 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
221 g_Game_SetupScreenSize();
223 g_Game_ClearLoading();
228 function g_Window_SetSize (w
, h
: Word; fullscreen
: Boolean): Boolean;
229 {$IF not DEFINED(HEADLESS)}
235 {$IF not DEFINED(HEADLESS)}
238 if (gScreenWidth
<> w
) or (gScreenHeight
<> h
) then
246 if (gFullscreen
<> fullscreen
) then
250 gFullscreen
:= fullscreen
;
256 g_Window_SetDisplay(preserve
);
263 function WindowEventHandler (constref ev
: TSDL_WindowEvent
): Boolean;
265 wActivate
, wDeactivate
: Boolean;
269 wDeactivate
:= false;
272 SDL_WINDOWEVENT_MOVED
:
274 if not (gFullscreen
or gWinMaximized
) then
276 gWinRealPosX
:= ev
.data1
;
277 gWinRealPosY
:= ev
.data2
;
281 SDL_WINDOWEVENT_MINIMIZED
:
284 if not wMinimized
then
286 e_ResizeWindow(0, 0);
288 if g_debug_WinMsgs
then
290 g_Console_Add('Now minimized');
291 e_WriteLog('[DEBUG] WinMsgs: Now minimized', TMsgType
.Notify
);
297 SDL_WINDOWEVENT_RESIZED
:
299 e_LogWritefln('Resize: (os=%dx%d) (ns=%dx%d)', [gScreenWidth
, gScreenHeight
, Integer(ev
.data1
), Integer(ev
.data2
)]);
300 {if (gFullscreen) then
302 e_LogWriteln(' fullscreen fix applied.');
303 if (gScreenWidth <> ev.data1) or (gScreenHeight <> ev.data2) then
305 SDL_SetWindowSize(h_Wnd, gScreenWidth, gScreenHeight);
310 gScreenWidth
:= ev
.data1
;
311 gScreenHeight
:= ev
.data2
;
315 if g_debug_WinMsgs
then
317 g_Console_Add('Resized to ' + IntToStr(ev
.data1
) + 'x' + IntToStr(ev
.data2
));
318 e_WriteLog('[DEBUG] WinMsgs: Resized to ' + IntToStr(ev
.data1
) + 'x' + IntToStr(ev
.data2
), TMsgType
.Notify
);
322 SDL_WINDOWEVENT_EXPOSED
:
325 SDL_WINDOWEVENT_MAXIMIZED
:
330 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
334 if (not gWinMaximized
) and (not gFullscreen
) then
336 gWinMaximized
:= true;
337 if g_debug_WinMsgs
then
339 g_Console_Add('Now maximized');
340 e_WriteLog('[DEBUG] WinMsgs: Now maximized', TMsgType
.Notify
);
345 SDL_WINDOWEVENT_RESTORED
:
350 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
354 gWinMaximized
:= false;
355 if g_debug_WinMsgs
then
357 g_Console_Add('Now restored');
358 e_WriteLog('[DEBUG] WinMsgs: Now restored', TMsgType
.Notify
);
362 SDL_WINDOWEVENT_FOCUS_GAINED
:
365 //e_WriteLog('window gained focus!', MSG_NOTIFY);
368 SDL_WINDOWEVENT_FOCUS_LOST
:
372 //e_WriteLog('window lost focus!', MSG_NOTIFY);
380 e_WriteLog('deactivating window', TMsgType
.Notify
);
381 e_EnableInput
:= false;
382 e_ClearInputBuffer();
384 if gMuteWhenInactive
then
386 //e_WriteLog('deactivating sounds', MSG_NOTIFY);
387 e_MuteChannels(true);
390 if g_debug_WinMsgs
then
392 g_Console_Add('Now inactive');
393 e_WriteLog('[DEBUG] WinMsgs: Now inactive', TMsgType
.Notify
);
398 if assigned(winBlurCB
) then winBlurCB();
401 else if wActivate
then
403 if not gWinActive
then
405 //e_WriteLog('activating window', MSG_NOTIFY);
406 e_EnableInput
:= true;
408 if gMuteWhenInactive
then
410 //e_WriteLog('activating sounds', MSG_NOTIFY);
411 e_MuteChannels(false);
414 if g_debug_WinMsgs
then
416 g_Console_Add('Now active');
417 e_WriteLog('[DEBUG] WinMsgs: Now active', TMsgType
.Notify
);
421 if assigned(winFocusCB
) then winFocusCB();
427 function EventHandler (var ev
: TSDL_Event
): Boolean;
437 result
:= WindowEventHandler(ev
.window
);
441 if (gExit
<> EXIT_QUIT
) then
443 if not wLoadingProgress
then
450 wLoadingQuit
:= true;
456 SDL_KEYDOWN
, SDL_KEYUP
:
458 key
:= ev
.key
.keysym
.scancode
;
459 down
:= (ev
.type_
= SDL_KEYDOWN
);
460 {$IF not DEFINED(HEADLESS)}
461 if fuiOnSDLEvent(ev
) then
463 // event eaten, but...
464 if not down
then e_KeyUpDown(key
, false);
468 if down
then KeyPress(key
);
469 e_KeyUpDown(key
, down
);
472 {$IF not DEFINED(HEADLESS)}
473 SDL_MOUSEBUTTONDOWN
, SDL_MOUSEBUTTONUP
, SDL_MOUSEWHEEL
, SDL_MOUSEMOTION
:
479 Utf8ToUnicode(@uc
, PChar(ev
.text.text), 1);
481 if (keychr
> 127) then keychr
:= Word(wchar2win(WideChar(keychr
)));
482 if (keychr
> 0) and (keychr
<= 255) then CharPress(AnsiChar(keychr
));
485 // other key presses and joysticks are handled in e_input
490 procedure SwapBuffers ();
492 {$IF not DEFINED(HEADLESS)}
493 SDL_GL_SwapWindow(h_Wnd
);
498 function CreateGLWindow (Title
: PChar): Boolean;
502 gWinSizeX
:= gScreenWidth
;
503 gWinSizeY
:= gScreenHeight
;
505 {$IF not DEFINED(HEADLESS)}
508 e_WriteLog('Creating window', TMsgType
.Notify
);
510 if not g_Window_SetDisplay() then
513 e_WriteLog('Window creation error (resolution not supported?)', TMsgType
.Fatal
);
517 {$IF not DEFINED(HEADLESS)}
518 h_GL
:= SDL_GL_CreateContext(h_Wnd
);
519 if (h_GL
= nil) then exit
;
520 fuiScrWdt
:= gScreenWidth
;
521 fuiScrHgt
:= gScreenHeight
;
522 if (assigned(oglInitCB
)) then oglInitCB();
525 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
533 // windoze sux; in headless mode `GetTickCount()` (and SDL) returns shit
534 function GetTimer (): Int64;
538 QueryPerformanceFrequency(F
);
539 QueryPerformanceCounter(C
);
540 result
:= Round(C
/F
*1000{000});
543 function GetTimer (): Int64;
549 if (ticksOverflow
= -1) then
556 if (lastTicks
> t
) then
558 // overflow, increment overflow ;-)
559 ticksOverflow
:= ticksOverflow
+(Int64($ffffffff)+Int64(1));
560 tt
:= (Int64($ffffffff)+Int64(1))+Int64(t
);
561 t
:= Uint32(tt
-lastTicks
);
565 result
:= ticksOverflow
+Int64(t
);
570 procedure ResetTimer ();
572 wNeedTimeReset
:= true;
576 procedure PushExitEvent ();
580 ev
.type_
:= SDL_QUITEV
;
586 prevLoadingUpdateTime
: UInt64 = 0;
588 procedure ProcessLoading (forceUpdate
: Boolean=false);
594 FillChar(ev
, sizeof(ev
), 0);
595 wLoadingProgress
:= true;
597 while (SDL_PollEvent(@ev
) > 0) do
600 if (ev
.type_
= SDL_QUITEV
) then break
;
604 if (ev
.type_
= SDL_QUITEV
) or (gExit
= EXIT_QUIT
) then
606 wLoadingProgress
:= false;
610 if not wMinimized
then
614 prevLoadingUpdateTime
:= getTimeMilli();
618 stt
:= getTimeMilli();
619 if (stt
< prevLoadingUpdateTime
) or (stt
-prevLoadingUpdateTime
>= ProgressUpdateMSecs
) then
621 prevLoadingUpdateTime
:= stt
;
628 if g_Texture_Get('INTER', ID
) then
630 e_DrawSize(ID
, 0, 0, 0, false, false, gScreenWidth
, gScreenHeight
);
631 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
635 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
645 if NetMode
= NET_SERVER
then
651 if (NetMode
= NET_CLIENT
) and (NetState
<> NET_STATE_AUTH
) then g_Net_Client_UpdateWhileLoading();
654 wLoadingProgress
:= false;
658 function g_ProcessMessages (): Boolean;
663 FillChar(ev
, SizeOf(ev
), 0);
664 while (SDL_PollEvent(@ev
) > 0) do
666 result
:= EventHandler(ev
);
667 if (ev
.type_
= SDL_QUITEV
) then exit
;
673 function ProcessMessage (): Boolean;
677 result
:= g_ProcessMessages();
680 Time_Delta
:= Time
-Time_Old
;
684 if wNeedTimeReset
then
687 wNeedTimeReset
:= false;
690 g_Map_ProfilersBegin();
691 g_Mons_ProfilersBegin();
693 t
:= Time_Delta
div 28;
699 if (NetMode
= NET_SERVER
) then g_Net_Host_Update()
700 else if (NetMode
= NET_CLIENT
) then g_Net_Client_Update();
706 if (NetMode
= NET_SERVER
) then g_Net_Host_Update()
707 else if (NetMode
= NET_CLIENT
) then g_Net_Client_Update();
710 g_Map_ProfilersEnd();
711 g_Mons_ProfilersEnd();
719 if (gExit
= EXIT_QUIT
) then
725 // Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ
728 Time_Old
:= Time
-(Time_Delta
mod 28);
729 if (not wMinimized
) then
737 Sleep(1); // release time slice, so we won't eat 100% CPU
744 procedure ReDrawWindow ();
750 procedure InitOpenGL (vsync
: Boolean);
751 {$IF not DEFINED(HEADLESS)}
756 {$IF not DEFINED(HEADLESS)}
757 if vsync
then v
:= 1 else v
:= 0;
758 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION
, 2);
759 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION
, 1);
760 SDL_GL_SetAttribute(SDL_GL_RED_SIZE
, 8);
761 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE
, 8);
762 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE
, 8);
763 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE
, 16);
764 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER
, 1);
765 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE
, 8); // lights; it is enough to have 1-bit stencil buffer for lighting, but...
766 SDL_GL_SetSwapInterval(v
);
771 function glHasExtension (const name
: AnsiString): Boolean;
776 extName
: ShortString;
779 if (Length(name
) = 0) then exit
;
780 exts
:= glGetString(GL_EXTENSIONS
);
781 if (exts
= nil) then exit
;
782 while (exts
[0] <> #0) and (exts
[0] = ' ') do Inc(exts
);
783 while (exts
[0] <> #0) do
785 if gwin_dump_extensions
then
788 while (exts
[i
] <> #0) and (exts
[i
] <> ' ') do Inc(i
);
791 e_WriteLog('FUUUUUUUUUUUUU', TMsgType
.Warning
);
795 Move(exts
^, extName
[1], i
);
796 extName
[0] := Char(i
);
797 e_WriteLog(Format('EXT: %s', [extName
]), TMsgType
.Notify
);
801 for i
:= 0 to length(name
)-1 do
803 if (exts
[i
] = #0) then begin found
:= false; break
; end;
804 if (exts
[i
] <> name
[i
+1]) then begin found
:= false; break
; end;
806 if found
and ((exts
[Length(name
)] = #0) or (exts
[Length(name
)] = ' ')) then begin result
:= true; exit
; end;
807 while (exts
[0] <> #0) and (exts
[0] <> ' ') do Inc(exts
);
808 while (exts
[0] <> #0) and (exts
[0] = ' ') do Inc(exts
);
813 function SDLMain (): Integer;
816 {$IF not DEFINED(HEADLESS)}
825 e_NoGraphics
:= true;
827 if (not g_holmes_imfunctional
) then
830 uiContext
.font
:= 'win14';
835 while (idx
<= ParamCount
) do
837 arg
:= ParamStr(idx
);
839 if arg
= '--opengl-dump-exts' then gwin_dump_extensions
:= true;
840 //if arg = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
841 if arg
= '--jah' then g_profile_history_size
:= 100;
842 if arg
= '--no-particles' then gpart_dbg_enabled
:= false;
843 if arg
= '--no-los' then gmon_dbg_los_enabled
:= false;
845 if arg
= '--profile-render' then g_profile_frame_draw
:= true;
846 if arg
= '--profile-coldet' then g_profile_collision
:= true;
847 if arg
= '--profile-los' then g_profile_los
:= true;
849 if arg
= '--no-part-phys' then gpart_dbg_phys_enabled
:= false;
850 if arg
= '--no-part-physics' then gpart_dbg_phys_enabled
:= false;
851 if arg
= '--no-particles-phys' then gpart_dbg_phys_enabled
:= false;
852 if arg
= '--no-particles-physics' then gpart_dbg_phys_enabled
:= false;
853 if arg
= '--no-particle-phys' then gpart_dbg_phys_enabled
:= false;
854 if arg
= '--no-particle-physics' then gpart_dbg_phys_enabled
:= false;
856 {.$IF DEFINED(D2F_DEBUG)}
857 if arg
= '--aimline' then g_dbg_aimline_on
:= true;
860 if arg
= '--holmes' then begin g_holmes_enabled
:= true; g_Game_SetDebugMode(); end;
862 if (arg
= '--holmes-ui-scale') or (arg
= '-holmes-ui-scale') then
864 if (idx
<= ParamCount
) then
866 if not conParseFloat(fuiRenderScale
, ParamStr(idx
)) then fuiRenderScale
:= 1.0;
871 if (arg
= '--holmes-font') or (arg
= '-holmes-font') then
873 if (idx
<= ParamCount
) then
876 val(ParamStr(idx
), itmp
, valres
);
878 if (valres
= 0) and (not g_holmes_imfunctional
) then
881 8: uiContext
.font
:= 'win8';
882 14: uiContext
.font
:= 'win14';
883 16: uiContext
.font
:= 'win16';
895 if (arg
= '--game-scale') or (arg
= '-game-scale') then
897 if (idx
<= ParamCount
) then
899 if not conParseFloat(g_dbg_scale
, ParamStr(idx
)) then g_dbg_scale
:= 1.0;
904 if (arg
= '--write-mapdef') or (arg
= '-write-mapdef') then
906 mdfo
:= createDiskFile('mapdef.txt');
907 mdfo
.WriteBuffer(defaultMapDef
[1], Length(defaultMapDef
));
913 e_WriteLog('Initializing OpenGL', TMsgType
.Notify
);
916 e_WriteLog('Creating GL window', TMsgType
.Notify
);
917 if not CreateGLWindow(PChar(Format('Doom 2D: Forever %s', [GAME_VERSION
]))) then
923 {EnumDisplayModes();}
926 //gwin_k8_enable_light_experiments := false;
927 gwin_has_stencil
:= false;
928 glLegacyNPOT
:= false;
929 gwin_dump_extensions
:= false;
931 SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE
, @ltmp
);
932 e_LogWritefln('stencil buffer size: %s', [ltmp
]);
933 gwin_has_stencil
:= (ltmp
> 0);
935 if not glHasExtension('GL_ARB_texture_non_power_of_two') then
937 e_WriteLog('NPOT textures: NO', TMsgType
.Warning
);
938 glLegacyNPOT
:= true;
942 e_WriteLog('NPOT textures: YES', TMsgType
.Notify
);
943 glLegacyNPOT
:= false;
945 gwin_dump_extensions
:= false;
949 Time_Old
:= GetTimer();
952 if (ParamCount
> 0) then g_Game_Process_Params();
955 if (not gGameOn
) and gAskLanguage
then g_Menu_AskLanguage();
957 e_WriteLog('Entering the main loop', TMsgType
.Notify
);
960 while not ProcessMessage() do begin end;