DEADSOFTWARE

system: remove direct videomode change
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Sun, 20 Jun 2021 08:52:05 +0000 (11:52 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 07:50:03 +0000 (10:50 +0300)
src/game/g_game.pas
src/game/g_menu.pas
src/game/opengl/r_render.pas

index d49c423c4df2bc1a077536dae63c67422fbbc7d2..febdd2654f139c3ff5adf02665443d4830bfccec 100644 (file)
@@ -92,7 +92,6 @@ procedure g_Game_Update();
 procedure g_Game_PreUpdate();
 procedure g_Game_Quit();
 procedure g_Game_SetupScreenSize();
-procedure g_Game_ChangeResolution(newWidth, newHeight: Word; nowFull, nowMax: Boolean);
 function  g_Game_ModeToText(Mode: Byte): string;
 function  g_Game_TextToMode(Mode: string): Byte;
 procedure g_Game_ExecuteEvent(Name: String);
@@ -449,7 +448,7 @@ uses
 {$IFDEF ENABLE_HOLMES}
   g_holmes,
 {$ENDIF}
-  e_res, g_textures, g_window, g_menu,
+  e_res, g_textures, g_window, g_menu, r_render,
   e_input, e_log, g_console, r_console, g_items, g_map, g_panel,
   g_playermodel, g_gfx, g_options, Math,
   g_triggers, g_monsters, e_sound, CONFIG,
@@ -2378,7 +2377,7 @@ begin
     if gResolutionChange then
     begin
       e_WriteLog('Changing resolution', TMsgType.Notify);
-      g_Game_ChangeResolution(gRC_Width, gRC_Height, gRC_FullScreen, gRC_Maximized);
+      r_Render_Apply;
       gResolutionChange := False;
       g_ActiveWindow := nil;
     end;
@@ -2826,11 +2825,6 @@ begin
   end;
 end;
 
-procedure g_Game_ChangeResolution(newWidth, newHeight: Word; nowFull, nowMax: Boolean);
-begin
-  sys_SetDisplayMode(newWidth, newHeight, gBPP, nowFull, nowMax);
-end;
-
 procedure g_Game_AddPlayer(Team: Byte = TEAM_NONE);
 begin
   if ((not gGameOn) and (gState <> STATE_INTERCUSTOM))
@@ -6307,16 +6301,7 @@ begin
         g_Game_Quit();
       end;
     'r_reset':
-      begin
-        gRC_Width := Max(1, gRC_Width);
-        gRC_Height := Max(1, gRC_Height);
-        gBPP := Max(1, gBPP);
-        if sys_SetDisplayMode(gRC_Width, gRC_Height, gBPP, gRC_FullScreen, gRC_Maximized) = True then
-          e_LogWriteln('resolution changed')
-        else
-          e_LogWriteln('resolution not changed');
-        sys_EnableVSync(gVSync);
-      end;
+       r_Render_Apply;
     'r_maxfps':
       begin
         if Length(p) = 2 then
index 19a9a1dd6cfa86817ebef5a42487a83b73197876..c1bdcf1769f3e7d437e0683d6aa9168762ee589a 100644 (file)
@@ -107,7 +107,6 @@ procedure ProcApplyOptions();
 var
   menu: TGUIMenu;
   i: Integer;
-  ovs: Boolean;
 begin
   menu := TGUIMenu(g_GUI_GetWindow('OptionsVideoMenu').GetControl('mOptionsVideoMenu'));
 
@@ -116,10 +115,7 @@ begin
   else
     gBPP := 32;
 
-  ovs := gVSync;
   gVSync := TGUISwitch(menu.GetControl('swVSync')).ItemIndex = 0;
-  if (ovs <> gVSync) then
-    sys_EnableVSync(gVSync);
 
   gTextureFilter := TGUISwitch(menu.GetControl('swTextureFilter')).ItemIndex = 0;
   glNPOTOverride := not (TGUISwitch(menu.GetControl('swLegacyNPOT')).ItemIndex = 0);
index d547054e8e90103fccecc511949cc62b8e538caf..b768075d9dd1ecf0c84e12c92445f0f354e0dfa2 100644 (file)
@@ -21,13 +21,16 @@ interface
   procedure r_Render_Finalize;
   procedure r_Render_Resize (w, h: Integer);
 
+  procedure r_Render_Apply;
+
 implementation
 
   uses
     {$INCLUDE ../../nogl/noGLuses.inc}
-    SysUtils, Classes,
+    SysUtils, Classes, Math,
     e_log, g_system,
-    g_game, g_options, r_window, r_graphics, r_console, r_playermodel
+    g_game, g_options, g_console,
+    r_window, r_graphics, r_console, r_playermodel
   ;
 
   var
@@ -109,4 +112,13 @@ implementation
     e_InitGL
   end;
 
+  procedure r_Render_Apply;
+  begin
+    if sys_SetDisplayMode(Max(1, gRC_Width), Max(1, gRC_Height), Max(1, gBPP), gRC_FullScreen, gRC_Maximized) then
+      e_LogWriteln('resolution changed')
+    else
+      e_LogWriteln('resolution not changed');
+    sys_EnableVSync(gVSync)
+  end;
+
 end.