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
73 wNeedTimeReset
: Boolean = false;
74 wMinimized
: Boolean = false;
75 wMaximized
: 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
);
148 SDL_SetWindowFullscreen(h_Wnd
, SDL_WINDOW_FULLSCREEN
);
149 if (h_Wnd
= nil) then exit
;
151 wasFullscreen
:= gFullscreen
;
153 SDL_GL_MakeCurrent(h_Wnd
, h_GL
);
154 SDL_ShowCursor(SDL_DISABLE
);
155 if (gFullscreen
) then
159 SDL_GetWindowSize(h_Wnd
, @nw
, @nh
);
160 if (nw
> 128) and (nh
> 128) then
162 e_WriteLog('SDL: fullscreen window got size '+IntToStr(nw
)+'x'+IntToStr(nh
)+': '+IntToStr(gScreenWidth
)+'x'+IntToStr(gScreenHeight
), TMsgType
.Notify
);
168 e_WriteLog('SDL: fullscreen window got invalid size: '+IntToStr(nw
)+'x'+IntToStr(nh
), TMsgType
.Notify
);
171 fuiScrWdt
:= gScreenWidth
;
172 fuiScrHgt
:= gScreenHeight
;
173 if (h_GL
<> nil) and (not preserveGL
) then begin if (assigned(oglInitCB
)) then oglInitCB(); end;
180 function GetDisplayModes (dbpp
: LongWord; var selres
: LongWord): SSArray
;
182 mode
: TSDL_DisplayMode
;
183 res
, i
, k
, n
, pw
, ph
: Integer;
185 SetLength(result
, 0);
186 {$IFDEF HEADLESS}exit
;{$ENDIF}
188 n
:= SDL_GetNumDisplayModes(0);
192 res
:= SDL_GetDisplayMode(0, i
, @mode
);
193 if res
< 0 then continue
;
194 if SDL_BITSPERPIXEL(mode
.format
) = gBPP
then continue
;
195 if (mode
.w
= pw
) and (mode
.h
= ph
) then continue
;
196 if (mode
.w
= gScreenWidth
) and (mode
.h
= gScreenHeight
) then
199 SetLength(result
, k
);
200 result
[k
-1] := IntToStr(mode
.w
) + 'x' + IntToStr(mode
.h
);
201 pw
:= mode
.w
; ph
:= mode
.h
204 e_WriteLog('SDL: Got ' + IntToStr(k
) + ' resolutions.', TMsgType
.Notify
);
208 procedure Sleep (ms
: LongWord);
214 procedure ChangeWindowSize ();
216 e_LogWritefln(' ChangeWindowSize: (ws=%dx%d) (ss=%dx%d)', [gWinSizeX
, gWinSizeY
, gScreenWidth
, gScreenHeight
]);
217 gWinSizeX
:= gScreenWidth
;
218 gWinSizeY
:= gScreenHeight
;
219 {$IF not DEFINED(HEADLESS)}
220 fuiScrWdt
:= gScreenWidth
;
221 fuiScrHgt
:= gScreenHeight
;
222 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
223 g_Game_SetupScreenSize();
225 g_Game_ClearLoading();
230 function g_Window_SetSize (w
, h
: Word; fullscreen
: Boolean): Boolean;
231 {$IF not DEFINED(HEADLESS)}
237 {$IF not DEFINED(HEADLESS)}
240 if (gScreenWidth
<> w
) or (gScreenHeight
<> h
) then
248 if (gFullscreen
<> fullscreen
) then
252 gFullscreen
:= fullscreen
;
258 g_Window_SetDisplay(preserve
);
265 function WindowEventHandler (constref ev
: TSDL_WindowEvent
): Boolean;
267 wActivate
, wDeactivate
: Boolean;
271 wDeactivate
:= false;
274 SDL_WINDOWEVENT_MOVED
:
276 if not (gFullscreen
or gWinMaximized
) then
278 gWinRealPosX
:= ev
.data1
;
279 gWinRealPosY
:= ev
.data2
;
283 SDL_WINDOWEVENT_MINIMIZED
:
286 if not wMinimized
then
288 e_ResizeWindow(0, 0);
290 if g_debug_WinMsgs
then
292 g_Console_Add('Now minimized');
293 e_WriteLog('[DEBUG] WinMsgs: Now minimized', TMsgType
.Notify
);
299 SDL_WINDOWEVENT_RESIZED
:
301 e_LogWritefln('Resize: (os=%dx%d) (ns=%dx%d)', [gScreenWidth
, gScreenHeight
, Integer(ev
.data1
), Integer(ev
.data2
)]);
302 {if (gFullscreen) then
304 e_LogWriteln(' fullscreen fix applied.');
305 if (gScreenWidth <> ev.data1) or (gScreenHeight <> ev.data2) then
307 SDL_SetWindowSize(h_Wnd, gScreenWidth, gScreenHeight);
312 gScreenWidth
:= ev
.data1
;
313 gScreenHeight
:= ev
.data2
;
317 if g_debug_WinMsgs
then
319 g_Console_Add('Resized to ' + IntToStr(ev
.data1
) + 'x' + IntToStr(ev
.data2
));
320 e_WriteLog('[DEBUG] WinMsgs: Resized to ' + IntToStr(ev
.data1
) + 'x' + IntToStr(ev
.data2
), TMsgType
.Notify
);
324 SDL_WINDOWEVENT_EXPOSED
:
327 SDL_WINDOWEVENT_MAXIMIZED
:
332 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
336 if (not gWinMaximized
) and (not gFullscreen
) then
338 gWinMaximized
:= true;
339 if g_debug_WinMsgs
then
341 g_Console_Add('Now maximized');
342 e_WriteLog('[DEBUG] WinMsgs: Now maximized', TMsgType
.Notify
);
347 SDL_WINDOWEVENT_RESTORED
:
352 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
356 gWinMaximized
:= false;
357 if g_debug_WinMsgs
then
359 g_Console_Add('Now restored');
360 e_WriteLog('[DEBUG] WinMsgs: Now restored', TMsgType
.Notify
);
364 SDL_WINDOWEVENT_FOCUS_GAINED
:
367 //e_WriteLog('window gained focus!', MSG_NOTIFY);
370 SDL_WINDOWEVENT_FOCUS_LOST
:
374 //e_WriteLog('window lost focus!', MSG_NOTIFY);
382 e_WriteLog('deactivating window', TMsgType
.Notify
);
383 e_EnableInput
:= false;
384 e_ClearInputBuffer();
386 if gMuteWhenInactive
then
388 //e_WriteLog('deactivating sounds', MSG_NOTIFY);
389 e_MuteChannels(true);
392 if g_debug_WinMsgs
then
394 g_Console_Add('Now inactive');
395 e_WriteLog('[DEBUG] WinMsgs: Now inactive', TMsgType
.Notify
);
400 if assigned(winBlurCB
) then winBlurCB();
403 else if wActivate
then
405 if not gWinActive
then
407 //e_WriteLog('activating window', MSG_NOTIFY);
408 e_EnableInput
:= true;
410 if gMuteWhenInactive
then
412 //e_WriteLog('activating sounds', MSG_NOTIFY);
413 e_MuteChannels(false);
416 if g_debug_WinMsgs
then
418 g_Console_Add('Now active');
419 e_WriteLog('[DEBUG] WinMsgs: Now active', TMsgType
.Notify
);
423 if assigned(winFocusCB
) then winFocusCB();
429 function EventHandler (var ev
: TSDL_Event
): Boolean;
439 result
:= WindowEventHandler(ev
.window
);
443 if (gExit
<> EXIT_QUIT
) then
445 if not wLoadingProgress
then
452 wLoadingQuit
:= true;
458 SDL_KEYDOWN
, SDL_KEYUP
:
460 key
:= ev
.key
.keysym
.scancode
;
461 down
:= (ev
.type_
= SDL_KEYDOWN
);
462 {$IF not DEFINED(HEADLESS)}
463 if fuiOnSDLEvent(ev
) then
465 // event eaten, but...
466 if not down
then e_KeyUpDown(key
, false);
470 if down
then KeyPress(key
);
471 e_KeyUpDown(key
, down
);
474 {$IF not DEFINED(HEADLESS)}
475 SDL_MOUSEBUTTONDOWN
, SDL_MOUSEBUTTONUP
, SDL_MOUSEWHEEL
, SDL_MOUSEMOTION
:
481 Utf8ToUnicode(@uc
, PChar(ev
.text.text), 1);
483 if (keychr
> 127) then keychr
:= Word(wchar2win(WideChar(keychr
)));
484 if (keychr
> 0) and (keychr
<= 255) then CharPress(AnsiChar(keychr
));
487 // other key presses and joysticks are handled in e_input
492 procedure SwapBuffers ();
494 {$IF not DEFINED(HEADLESS)}
495 SDL_GL_SwapWindow(h_Wnd
);
500 function CreateGLWindow (Title
: PChar): Boolean;
504 gWinSizeX
:= gScreenWidth
;
505 gWinSizeY
:= gScreenHeight
;
507 {$IF not DEFINED(HEADLESS)}
510 e_WriteLog('Creating window', TMsgType
.Notify
);
512 if not g_Window_SetDisplay() then
515 e_WriteLog('Window creation error (resolution not supported?)', TMsgType
.Fatal
);
519 {$IF not DEFINED(HEADLESS)}
520 h_GL
:= SDL_GL_CreateContext(h_Wnd
);
521 if (h_GL
= nil) then exit
;
522 fuiScrWdt
:= gScreenWidth
;
523 fuiScrHgt
:= gScreenHeight
;
524 if (assigned(oglInitCB
)) then oglInitCB();
527 e_ResizeWindow(gScreenWidth
, gScreenHeight
);
535 // windoze sux; in headless mode `GetTickCount()` (and SDL) returns shit
536 function GetTimer (): Int64;
540 QueryPerformanceFrequency(F
);
541 QueryPerformanceCounter(C
);
542 result
:= Round(C
/F
*1000{000});
545 function GetTimer (): Int64;
551 if (ticksOverflow
= -1) then
558 if (lastTicks
> t
) then
560 // overflow, increment overflow ;-)
561 ticksOverflow
:= ticksOverflow
+(Int64($ffffffff)+Int64(1));
562 tt
:= (Int64($ffffffff)+Int64(1))+Int64(t
);
563 t
:= Uint32(tt
-lastTicks
);
567 result
:= ticksOverflow
+Int64(t
);
572 procedure ResetTimer ();
574 wNeedTimeReset
:= true;
578 procedure PushExitEvent ();
582 ev
.type_
:= SDL_QUITEV
;
588 prevLoadingUpdateTime
: UInt64 = 0;
590 procedure ProcessLoading (forceUpdate
: Boolean=false);
596 FillChar(ev
, sizeof(ev
), 0);
597 wLoadingProgress
:= true;
599 while (SDL_PollEvent(@ev
) > 0) do
602 if (ev
.type_
= SDL_QUITEV
) then break
;
606 if (ev
.type_
= SDL_QUITEV
) or (gExit
= EXIT_QUIT
) then
608 wLoadingProgress
:= false;
612 if not wMinimized
then
616 prevLoadingUpdateTime
:= getTimeMilli();
620 stt
:= getTimeMilli();
621 if (stt
< prevLoadingUpdateTime
) or (stt
-prevLoadingUpdateTime
>= ProgressUpdateMSecs
) then
623 prevLoadingUpdateTime
:= stt
;
630 if g_Texture_Get('INTER', ID
) then
632 e_DrawSize(ID
, 0, 0, 0, false, false, gScreenWidth
, gScreenHeight
);
633 e_DarkenQuadWH(0, 0, gScreenWidth
, gScreenHeight
, 150);
637 e_Clear(GL_COLOR_BUFFER_BIT
, 0, 0, 0);
647 if NetMode
= NET_SERVER
then
653 if (NetMode
= NET_CLIENT
) and (NetState
<> NET_STATE_AUTH
) then g_Net_Client_UpdateWhileLoading();
656 wLoadingProgress
:= false;
660 function g_ProcessMessages (): Boolean;
665 FillChar(ev
, SizeOf(ev
), 0);
666 while (SDL_PollEvent(@ev
) > 0) do
668 result
:= EventHandler(ev
);
669 if (ev
.type_
= SDL_QUITEV
) then exit
;
675 function ProcessMessage (): Boolean;
679 result
:= g_ProcessMessages();
682 Time_Delta
:= Time
-Time_Old
;
686 if wNeedTimeReset
then
689 wNeedTimeReset
:= false;
692 g_Map_ProfilersBegin();
693 g_Mons_ProfilersBegin();
695 t
:= Time_Delta
div 28;
701 if (NetMode
= NET_SERVER
) then g_Net_Host_Update()
702 else if (NetMode
= NET_CLIENT
) then g_Net_Client_Update();
708 if (NetMode
= NET_SERVER
) then g_Net_Host_Update()
709 else if (NetMode
= NET_CLIENT
) then g_Net_Client_Update();
712 g_Map_ProfilersEnd();
713 g_Mons_ProfilersEnd();
721 if (gExit
= EXIT_QUIT
) then
727 // Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ
730 Time_Old
:= Time
-(Time_Delta
mod 28);
731 if (not wMinimized
) then
739 Sleep(1); // release time slice, so we won't eat 100% CPU
746 procedure ReDrawWindow ();
752 procedure InitOpenGL (vsync
: Boolean);
753 {$IF not DEFINED(HEADLESS)}
758 {$IF not DEFINED(HEADLESS)}
759 if vsync
then v
:= 1 else v
:= 0;
760 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION
, 2);
761 SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION
, 1);
762 SDL_GL_SetAttribute(SDL_GL_RED_SIZE
, 8);
763 SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE
, 8);
764 SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE
, 8);
765 SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE
, 16);
766 SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER
, 1);
767 SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE
, 8); // lights; it is enough to have 1-bit stencil buffer for lighting, but...
768 SDL_GL_SetSwapInterval(v
);
773 function glHasExtension (const name
: AnsiString): Boolean;
778 extName
: ShortString;
781 if (Length(name
) = 0) then exit
;
782 exts
:= glGetString(GL_EXTENSIONS
);
783 if (exts
= nil) then exit
;
784 while (exts
[0] <> #0) and (exts
[0] = ' ') do Inc(exts
);
785 while (exts
[0] <> #0) do
787 if gwin_dump_extensions
then
790 while (exts
[i
] <> #0) and (exts
[i
] <> ' ') do Inc(i
);
793 e_WriteLog('FUUUUUUUUUUUUU', TMsgType
.Warning
);
797 Move(exts
^, extName
[1], i
);
798 extName
[0] := Char(i
);
799 e_WriteLog(Format('EXT: %s', [extName
]), TMsgType
.Notify
);
803 for i
:= 0 to length(name
)-1 do
805 if (exts
[i
] = #0) then begin found
:= false; break
; end;
806 if (exts
[i
] <> name
[i
+1]) then begin found
:= false; break
; end;
808 if found
and ((exts
[Length(name
)] = #0) or (exts
[Length(name
)] = ' ')) then begin result
:= true; exit
; end;
809 while (exts
[0] <> #0) and (exts
[0] <> ' ') do Inc(exts
);
810 while (exts
[0] <> #0) and (exts
[0] = ' ') do Inc(exts
);
815 function SDLMain (): Integer;
818 {$IF not DEFINED(HEADLESS)}
827 e_NoGraphics
:= true;
829 if (not g_holmes_imfunctional
) then
832 uiContext
.font
:= 'win14';
837 while (idx
<= ParamCount
) do
839 arg
:= ParamStr(idx
);
841 if arg
= '--opengl-dump-exts' then gwin_dump_extensions
:= true;
842 //if arg = '--twinkletwinkle' then gwin_k8_enable_light_experiments := true;
843 if arg
= '--jah' then g_profile_history_size
:= 100;
844 if arg
= '--no-particles' then gpart_dbg_enabled
:= false;
845 if arg
= '--no-los' then gmon_dbg_los_enabled
:= false;
847 if arg
= '--profile-render' then g_profile_frame_draw
:= true;
848 if arg
= '--profile-coldet' then g_profile_collision
:= true;
849 if arg
= '--profile-los' then g_profile_los
:= true;
851 if arg
= '--no-part-phys' then gpart_dbg_phys_enabled
:= false;
852 if arg
= '--no-part-physics' then gpart_dbg_phys_enabled
:= false;
853 if arg
= '--no-particles-phys' then gpart_dbg_phys_enabled
:= false;
854 if arg
= '--no-particles-physics' then gpart_dbg_phys_enabled
:= false;
855 if arg
= '--no-particle-phys' then gpart_dbg_phys_enabled
:= false;
856 if arg
= '--no-particle-physics' then gpart_dbg_phys_enabled
:= false;
858 {.$IF DEFINED(D2F_DEBUG)}
859 if arg
= '--aimline' then g_dbg_aimline_on
:= true;
862 if arg
= '--holmes' then begin g_holmes_enabled
:= true; g_Game_SetDebugMode(); end;
864 if (arg
= '--holmes-ui-scale') or (arg
= '-holmes-ui-scale') then
866 if (idx
<= ParamCount
) then
868 if not conParseFloat(fuiRenderScale
, ParamStr(idx
)) then fuiRenderScale
:= 1.0;
873 if (arg
= '--holmes-font') or (arg
= '-holmes-font') then
875 if (idx
<= ParamCount
) then
878 val(ParamStr(idx
), itmp
, valres
);
880 if (valres
= 0) and (not g_holmes_imfunctional
) then
883 8: uiContext
.font
:= 'win8';
884 14: uiContext
.font
:= 'win14';
885 16: uiContext
.font
:= 'win16';
897 if (arg
= '--game-scale') or (arg
= '-game-scale') then
899 if (idx
<= ParamCount
) then
901 if not conParseFloat(g_dbg_scale
, ParamStr(idx
)) then g_dbg_scale
:= 1.0;
906 if (arg
= '--write-mapdef') or (arg
= '-write-mapdef') then
908 mdfo
:= createDiskFile('mapdef.txt');
909 mdfo
.WriteBuffer(defaultMapDef
[1], Length(defaultMapDef
));
915 e_WriteLog('Initializing OpenGL', TMsgType
.Notify
);
918 e_WriteLog('Creating GL window', TMsgType
.Notify
);
919 if not CreateGLWindow(PChar(Format('Doom 2D: Forever %s', [GAME_VERSION
]))) then
925 {EnumDisplayModes();}
928 //gwin_k8_enable_light_experiments := false;
929 gwin_has_stencil
:= false;
930 glLegacyNPOT
:= false;
931 gwin_dump_extensions
:= false;
933 SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE
, @ltmp
);
934 e_LogWritefln('stencil buffer size: %s', [ltmp
]);
935 gwin_has_stencil
:= (ltmp
> 0);
937 if not glHasExtension('GL_ARB_texture_non_power_of_two') then
939 e_WriteLog('NPOT textures: NO', TMsgType
.Warning
);
940 glLegacyNPOT
:= true;
944 e_WriteLog('NPOT textures: YES', TMsgType
.Notify
);
945 glLegacyNPOT
:= false;
947 gwin_dump_extensions
:= false;
951 Time_Old
:= GetTimer();
954 if (ParamCount
> 0) then g_Game_Process_Params();
957 if (not gGameOn
) and gAskLanguage
then g_Menu_AskLanguage();
959 e_WriteLog('Entering the main loop', TMsgType
.Notify
);
962 while not ProcessMessage() do begin end;