소스 검색

Adds function to better report active device type from GFXDevice
Ensures Window title and options menu correctly displays available and active render api
Fixes AA option so it correctly toggles FXAA

Areloch 4 년 전
부모
커밋
334cd1d205
3개의 변경된 파일46개의 추가작업 그리고 8개의 파일을 삭제
  1. 12 1
      Engine/source/gfx/gfxDevice.cpp
  2. 5 5
      Templates/BaseGame/game/core/gui/scripts/canvas.cs
  3. 29 2
      Templates/BaseGame/game/data/ui/guis/optionsMenu.cs

+ 12 - 1
Engine/source/gfx/gfxDevice.cpp

@@ -1364,6 +1364,17 @@ DefineEngineFunction( getDisplayDeviceInformation, const char*, (),,
    return adapter.getName();
    return adapter.getName();
 }
 }
 
 
+DefineEngineFunction(getDisplayDeviceType, GFXAdapterType, (), ,
+   "Get the string describing the active GFX device type.\n"
+   "@ingroup GFX\n")
+{
+   if (!GFXDevice::devicePresent())
+      return NullDevice;
+
+   const GFXAdapter& adapter = GFX->getAdapter();
+   return adapter.mType;
+}
+
 DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
 DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
    "Returns the best texture format for storage of HDR data for the active device.\n"
    "Returns the best texture format for storage of HDR data for the active device.\n"
    "@ingroup GFX\n" )
    "@ingroup GFX\n" )
@@ -1388,4 +1399,4 @@ DefineEngineFunction( getBestHDRFormat, GFXFormat, (),,
 DefineEngineFunction(ResetGFX, void, (), , "forces the gbuffer to be reinitialized in cases of improper/lack of buffer clears.")
 DefineEngineFunction(ResetGFX, void, (), , "forces the gbuffer to be reinitialized in cases of improper/lack of buffer clears.")
 {
 {
    GFX->beginReset();
    GFX->beginReset();
-}
+}

+ 5 - 5
Templates/BaseGame/game/core/gui/scripts/canvas.cs

@@ -37,7 +37,7 @@ function createCanvas(%windowTitle)
    // Set the window title
    // Set the window title
    if (isObject(Canvas)) 
    if (isObject(Canvas)) 
    {
    {
-      Canvas.setWindowTitle(%windowTitle @ " - " @ $pref::Video::displayDevice);
+      Canvas.setWindowTitle(%windowTitle @ " - " @ getDisplayDeviceType());
       configureCanvas();
       configureCanvas();
    } 
    } 
    else 
    else 
@@ -107,7 +107,7 @@ function configureCanvas()
    %resY = $pref::Video::Resolution.y;
    %resY = $pref::Video::Resolution.y;
    %bpp  = $pref::Video::BitDepth;
    %bpp  = $pref::Video::BitDepth;
    %rate = $pref::Video::RefreshRate;
    %rate = $pref::Video::RefreshRate;
-   %fsaa = $pref::Video::AA;
+   %aa = $pref::Video::AA;
    %fs = ($pref::Video::deviceMode == 2);
    %fs = ($pref::Video::deviceMode == 2);
 
 
    echo("Accepted Mode: " NL
    echo("Accepted Mode: " NL
@@ -115,7 +115,7 @@ function configureCanvas()
       "--Screen Mode    : " @ %fsLabel NL
       "--Screen Mode    : " @ %fsLabel NL
       "--Bits Per Pixel : " @ %bpp NL
       "--Bits Per Pixel : " @ %bpp NL
       "--Refresh Rate   : " @ %rate NL
       "--Refresh Rate   : " @ %rate NL
-      "--FSAA Level     : " @ %fsaa NL
+      "--FSAA Level     : " @ %aa NL
       "--------------");
       "--------------");
 
 
    // Actually set the new video mode
    // Actually set the new video mode
@@ -132,8 +132,8 @@ function configureCanvas()
    // We need to parse the setting between AA modes, and then it's level
    // We need to parse the setting between AA modes, and then it's level
    // It's formatted as AATypexAALevel
    // It's formatted as AATypexAALevel
    // So, FXAAx4 or MLAAx2
    // So, FXAAx4 or MLAAx2
-   if ( isObject( FXAA_PostEffect ) )
-      FXAA_PostEffect.Enabled = ( %aa > 0 ) ? true : false;
+   if ( isObject( FXAAPostFX ) )
+      FXAAPostFX.Enabled = ( %aa > 0 ) ? true : false;
 }
 }
 
 
 function GuiCanvas::modeStrToPrefs(%this, %modeStr)
 function GuiCanvas::modeStrToPrefs(%this, %modeStr)

+ 29 - 2
Templates/BaseGame/game/data/ui/guis/optionsMenu.cs

@@ -196,7 +196,32 @@ function OptionsMenu::populateDisplaySettingsList(%this)
    OptionName.setText("");
    OptionName.setText("");
    OptionDescription.setText("");
    OptionDescription.setText("");
    
    
-   OptionsMenuSettingsList.addOptionRow("Display API", "D3D11\tOpenGL", false, "", -1, -30, true, "The display API used for rendering.", $pref::Video::displayDevice);
+   //First, lets double-check the active device is accurate. Sometimes the default value in our prefs doesn't match the active one
+   %displayDevice = getDisplayDeviceType();
+   if($changingDisplayDevice !$= "")
+      %displayDevice = $changingDisplayDevice;
+      
+   %apiList = "";
+   %apiCount = GFXInit::getAdapterCount();
+   %apiIdx = 0;
+   for(%i=0; %i < %apiCount; %i++)
+   {
+      %api = GFXInit::getAdapterType(%i);
+      
+      if(%api !$= "NullDevice")
+      {
+         if(%apiIdx==0)
+            %apiList = %api;
+         else
+            %apiList = %apiList TAB %api;
+            
+         %apiIdx++;
+      }
+   }   
+   
+   trim(%apiList);
+   
+   OptionsMenuSettingsList.addOptionRow("Display API", %apiList, false, "", -1, -30, true, "The display API used for rendering.", %displayDevice);
    
    
    %numDevices = Canvas.getMonitorCount();
    %numDevices = Canvas.getMonitorCount();
    %devicesList = "";
    %devicesList = "";
@@ -246,7 +271,7 @@ function OptionsMenu::populateDisplaySettingsList(%this)
 
 
 function OptionsMenu::applyDisplaySettings(%this)
 function OptionsMenu::applyDisplaySettings(%this)
 {
 {
-	%newDevice     = OptionsMenuSettingsList.getCurrentOption(0);
+	%newDevice = OptionsMenuSettingsList.getCurrentOption(0);
 							
 							
    // Change the device.
    // Change the device.
    if ( %newDevice !$= $pref::Video::displayDevice )
    if ( %newDevice !$= $pref::Video::displayDevice )
@@ -257,6 +282,8 @@ function OptionsMenu::applyDisplaySettings(%this)
       $pref::Video::displayDevice = %newDevice;
       $pref::Video::displayDevice = %newDevice;
       if( %newAdapter !$= getDisplayDeviceInformation() )
       if( %newAdapter !$= getDisplayDeviceInformation() )
          MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
          MessageBoxOK( "Change requires restart", "Please restart the game for a display device change to take effect." );
+         
+      $changingDisplayDevice = %newDevice;
    }
    }
    
    
    updateDisplaySettings();
    updateDisplaySettings();