DEADSOFTWARE

sdl2sys: removed compiler warning (fpc warnings sux)
[d2df-sdl.git] / src / game / sdl2 / g_system.pas
index 3e55f4510c99f411bfb28ad649ea34f97b278bc6..b7142a85bc03504b8cda40fc8c380e3a5af21d50 100644 (file)
@@ -42,6 +42,7 @@ implementation
   uses
     SysUtils, SDL2, Math,
     e_log, e_graphics, e_input, e_sound,
+    {$INCLUDE ../nogl/noGLuses.inc}
     {$IFDEF ENABLE_HOLMES}
       g_holmes, sdlcarcass, fui_ctls,
     {$ENDIF}
@@ -87,7 +88,10 @@ implementation
     e_ResizeWindow(w, h);
     e_InitGL;
     g_Game_SetupScreenSize;
-    g_Menu_Reset;
+    {$IFNDEF ANDOIRD}
+      (* This will fix menu reset on keyboard showing *)
+      g_Menu_Reset;
+    {$ENDIF}
     g_Game_ClearLoading;
     {$IFDEF ENABLE_HOLMES}
       if assigned(oglInitCB) then oglInitCB;
@@ -124,6 +128,9 @@ implementation
         context := SDL_GL_CreateContext(window);
         if context <> nil then
         begin
+          {$IFDEF NOGL_INIT}
+            nogl_Init;
+          {$ENDIF}
           UpdateSize(w, h);
           result := true
         end
@@ -415,6 +422,7 @@ implementation
     var ev: TSDL_Event;
   begin
     result := false;
+    ZeroMemory(@ev, sizeof(ev));
     while SDL_PollEvent(@ev) <> 0 do
     begin
       case ev.type_ of
@@ -445,7 +453,7 @@ implementation
   (* --------- Init --------- *)
 
   procedure sys_Init;
-    var flags: UInt32; ok: Boolean;
+    var flags: UInt32;
   begin
     e_WriteLog('Init SDL2', TMsgType.Notify);
     {$IFDEF HEADLESS}
@@ -460,9 +468,6 @@ implementation
     SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, '0');
     if SDL_Init(flags) <> 0 then
       raise Exception.Create('SDL: Init failed: ' + SDL_GetError);
-    ok := InitWindow(gScreenWidth, gScreenHeight, gBPP, gFullscreen);
-    if not ok then
-      raise Exception.Create('SDL: Failed to set videomode: ' + SDL_GetError);
     SDL_ShowCursor(SDL_DISABLE);
   end;
 
@@ -470,11 +475,18 @@ implementation
   begin
     e_WriteLog('Releasing SDL2', TMsgType.Notify);
     if context <> nil then
+    begin
+      {$IFDEF NOGL_INIT}
+        nogl_Quit;
+      {$ENDIF}
       SDL_GL_DeleteContext(context);
+      context := nil;
+    end;
     if window <> nil then
+    begin
       SDL_DestroyWindow(window);
-    window := nil;
-    context := nil;
+      window := nil;
+    end;
     SDL_Quit
   end;