DEADSOFTWARE

fix stub system driver and some warnings
[d2df-sdl.git] / src / game / g_options.pas
index 979fe4510cd9d9144e8e3faff46a47a44cc6fe41..116e6474fd136810e16de5b09963901a06c7b65b 100644 (file)
@@ -96,9 +96,12 @@ implementation
 
 uses
   {$INCLUDE ../nogl/noGLuses.inc}
+  {$IFDEF USE_SDL2}
+    SDL2,
+  {$ENDIF}
   e_log, e_input, g_console, g_window, g_sound, g_gfx, g_player, Math,
   g_map, g_net, g_netmaster, SysUtils, CONFIG, g_game, g_main, e_texture,
-  g_items, wadreader, e_graphics, g_touch, SDL2, envvars;
+  g_items, wadreader, e_graphics, g_touch, envvars;
 
   var
     machine: Integer;
@@ -115,19 +118,27 @@ uses
       Result := Copy(Result, 1, 10) + ' ' + IntToStr(n)
   end;
 
+{$IFDEF USE_SDL2}
 procedure g_Options_SetDefaultVideo;
 var
   target, closest, display: TSDL_DisplayMode;
   percentage: Integer;
 begin
   (* Display 0 = Primary display *)
-  SDL_GetDesktopDisplayMode(0, @display);
-  {$IF DEFINED(ANDROID)}
+  gScreenWidth := 640;
+  gScreenHeight := 480;
+  //gBPP := SDL_BITSPERPIXEL(dispaly.format);
+  gBPP := 32;
+  {$IFDEF ANDROID}
+    gFullScreen := True; (* rotation not allowed? *)
+  {$ELSE}
+    gFullScreen := False;
+  {$ENDIF}
+  if SDL_GetDesktopDisplayMode(0, @display) = 0 then
+  begin
+  {$IFDEF ANDROID}
     gScreenWidth := display.w;
     gScreenHeight := display.h;
-    //gBPP := SDL_BITSPERPIXEL(dispaly.format);
-    gBPP := 32;
-    gFullScreen := True; (* rotation not allowed? *)
   {$ELSE}
     (* Window must be smaller than display *)
     closest.w := display.w;
@@ -152,9 +163,12 @@ begin
     gScreenWidth := closest.w;
     gScreenHeight := closest.h;
     //gBPP := SDL_BITSPERPIXEL(closest.format); (* Resolution list didn't work for some reason *)
-    gBPP := 32;
-    gFullScreen := False;
   {$ENDIF}
+  end
+  else
+  begin
+    e_LogWritefln('SDL: Failed to get desktop display mode: %s', [SDL_GetError])
+  end;
   (* Must be positioned on primary display *)
   gWinRealPosX := SDL_WINDOWPOS_CENTERED;
   gWinRealPosY := SDL_WINDOWPOS_CENTERED;
@@ -165,6 +179,23 @@ begin
   e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
   g_Console_ResetBinds;
 end;
+{$ELSE}
+procedure g_Options_SetDefaultVideo;
+begin
+  gScreenWidth := 640;
+  gScreenHeight := 480;
+  gBPP := 32;
+  gFullScreen := False;
+  gWinRealPosX := 0;
+  gWinRealPosY := 0;
+  gWinMaximized := False;
+  gVSync := True;
+  gTextureFilter := True;
+  glLegacyNPOT := False;
+  e_LogWriteLn('g_Options_SetDefaultVideo: w = ' + IntToStr(gScreenWidth) + ' h = ' + IntToStr(gScreenHeight));
+  g_Console_ResetBinds;
+end;
+{$ENDIF}
 
 procedure g_Options_SetDefault();
 var