Jump to content

getting torque to recognize graphics resolution


bsisko

Recommended Posts

I do most of my development on a HP slimline, with a max display resolution of 1024 x 768. The college that I attend have displays that are 1280 x 1024. And then I know there are other graphic modes that display different resolutions.


I know that during design time, it is possible to set the current game mode using the GUI option (F10) but I would like for the 'torquedemo.exe' program to detect what video card the gamer has on his system, determine what graphics mode (800 x 600, 1024 x 768, 1280 x 1024) the card supports, then set the game to use the best graphic mode!


Resistance is futile!!

Link to comment
Share on other sites

Torque has an autodectect graphics function here:

https://github.com/GarageGames/Torque3D/blob/development/Templates/Full/game/core/scripts/client/defaults.cs#L449


You can see there, that it checks for shader version, if the display driver is intel and the amount of video memory.

Maybe you can build something based on that, if not, you have to look for more variables the engine can look up, or build some on your own.

To detect the resolution before launch, you have to run that function on launch obviously, which can make problems, thats probably why Torque launches by default in 1024x768 and then lets you increase it manually.


For now I would just suggest setting it to the lowest resolution the machines can have you want to run it on and then let the users adjust it later if they want bigger resolution.

Link to comment
Share on other sites

  • 6 months later...

Ok, I was able to change to graphics mode in the GUI editor. Observe the followiing snippets of code.

  GuiEditorClassPopup.sort();
  GuiEditorResList.clear();
  GuiEditorResList.add("640 x 480", 640);
  GuiEditorResList.add("800 x 600", 800);
  GuiEditorResList.add("1024 x 768", 1024);

  //     Modification Set 1 of 3 to increase the video mode selection of TGE 1.4
  //     2/3/2019
  GuiEditorResList.add("1280 x 1024", 1280 );
  GuiEditorResList.add("1600 x 1200", 1600 );
  GuiEditorResList.add("1280 x 720", 720 );
  GuiEditorResList.add("1600 x 900", 900 );
  GuiEditorResList.add("1920 x 1080", 1080 );
  GuiEditorResList.add("1440 x 900", 900 );
  GuiEditorResList.add("1680 x 1050", 1050 );
  GuiEditorResList.add("1920 x 1200", 1200); 
  //    ----------------------------------------------------------------------------
  %ext = $Pref::GuiEditor::PreviewResolution;
  if( %ext $= "" )
  {
  %ext = GuiEditorRegion.getExtent();
  echo("extent is " @ %ext );
  switch(getWord(%ext, 0))
  {
     case 640:
        GuiEditorResList.setText("640 x 480");
     case 800:
        GuiEditorResList.setText("800 x 600");
     case 1024:
        GuiEditorResList.setText("1024 x 768");

  //     Modification Set 2 of 3 to increase the video mode selection of TGE 1.4
  //     2/3/2019

  case 1280:
	 GuiEditorResList.setText("1280 x 1024");
  case 1600:
	 GuiEditorResList.setText("1600 x 1200)");
  case 720:
	 GuiEditorResList.setText("1280 x 720)");
  case 900:
	 GuiEditorResList.setText("1600 x 900");
  case 1080:
	 GuiEditorResList.setText("1920 x 1080");
  case 1440:
	 GuiEditorResList.setText("1440 x 900");
  case 1050:
	 GuiEditorResList.setText("1680 x 1050");
  case 1200:
	 GuiEditorResList.setText("1920 x 1200");
     //   ----------------------------------------------------------------------------		 


 

 function GuiEditorResList::onSelect(%this, %id)
{
  switch(%id)
  {
     case 640:
        GuiEditorRegion.resize(0,0,640,480);
        GuiEditorContent.getObject(0).resize(0,0,640,480);
        $Pref::GuiEditor::PreviewResolution = "640 480";
     case 800:
        GuiEditorRegion.resize(0,0,800,600);
        GuiEditorContent.getObject(0).resize(0,0,800,600);
        $Pref::GuiEditor::PreviewResolution = "800 600";
     case 1024:
        GuiEditorRegion.resize(0,0,1024,768);
        GuiEditorContent.getObject(0).resize(0,0,1024,768);
        $Pref::GuiEditor::PreviewResolution = "1024 768";

  //     Modification Set 3 of 3 to increase the video mode selection of TGE 1.4
  //     2/3/2019

  case 1280:
        GuiEditorRegion.resize(0,0,1280,1024);
        GuiEditorContent.getObject(0).resize(0,0,1280,1024);
        $Pref::GuiEditor::PreviewResolution = "1280 1024";
     case 1600:
        GuiEditorRegion.resize(0,0,1600,1200);
        GuiEditorContent.getObject(0).resize(0,0,1600,1200);
        $Pref::GuiEditor::PreviewResolution = "1600 1200";
     case 720:
        GuiEditorRegion.resize(0,0,1280,720);
        GuiEditorContent.getObject(0).resize(0,0,1280,720);
        $Pref::GuiEditor::PreviewResolution = "1280 720";
     case 900:
        GuiEditorRegion.resize(0,0,1600,900);
        GuiEditorContent.getObject(0).resize(0,0,1600,900);
        $Pref::GuiEditor::PreviewResolution = "1600 900";
     case 1080:
        GuiEditorRegion.resize(0,0,1920,1080);
        GuiEditorContent.getObject(0).resize(0,0,1920,1080);
        $Pref::GuiEditor::PreviewResolution = "1920 1080";
     case 1440:
        GuiEditorRegion.resize(0,0,1440,900);
        GuiEditorContent.getObject(0).resize(0,0,1440,900);
        $Pref::GuiEditor::PreviewResolution = "1440 900";
     case 1050:
        GuiEditorRegion.resize(0,0,1680,1050);
        GuiEditorContent.getObject(0).resize(0,0,1680,1050);
        $Pref::GuiEditor::PreviewResolution = "1680 1050";
     case 1200:
        GuiEditorRegion.resize(0,0,1920,1200);
        GuiEditorContent.getObject(0).resize(0,0,1920,1200);
        $Pref::GuiEditor::PreviewResolution = "1920 1200";
// ----------------------------------------------------------------------------------
  }
}

 


Now how do I ensure that the game engine itself gets the resolution that I desire. This is what I found in the platform.cs code

 

//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

#include "platform/platformVideo.h"
#include "gui/core/guiCanvas.h"
#include "console/console.h"
#include "platform/gameInterface.h"

extern void GameDeactivate( bool noRender );
extern void GameReactivate();

// Static class data:
Vector<DisplayDevice*>  Video::smDeviceList;
DisplayDevice*          Video::smCurrentDevice;
bool					Video::smCritical = false;
bool					Video::smNeedResurrect = false;

Resolution  DisplayDevice::smCurrentRes;
bool        DisplayDevice::smIsFullScreen;


ConsoleFunctionGroupBegin(Video, "Video control functions.");

//--------------------------------------------------------------------------
ConsoleFunction( setDisplayDevice, bool, 2, 6, "( string deviceName, int width, int height=NULL, int bpp=NULL, bool fullScreen=NULL )"
               "Attempt to set the screen mode using as much information as is provided.")
{
Resolution currentRes = Video::getResolution();

U32 width = ( argc > 2 ) ? dAtoi( argv[2] ) : currentRes.w;
U32 height =  ( argc > 3 ) ? dAtoi( argv[3] ) : currentRes.h;
U32 bpp = ( argc > 4 ) ? dAtoi( argv[4] ) : currentRes.bpp;
bool fullScreen = ( argc > 5 ) ? dAtob( argv[5] ) : Video::isFullScreen();

  return( Video::setDevice( argv[1], width, height, bpp, fullScreen ) );
}


//--------------------------------------------------------------------------
ConsoleFunction( setScreenMode, bool, 5, 5, "( int width, int height, int bpp, bool fullScreen )" )
{
  return( Video::setScreenMode( dAtoi( argv[1] ), dAtoi( argv[2] ), dAtoi( argv[3] ), dAtob( argv[4] ) ) );
}


//------------------------------------------------------------------------------
ConsoleFunction( toggleFullScreen, bool, 1, 1, "")
{
  return( Video::toggleFullScreen() );
} 

 

... and this is what I found in the defualts.cs script.

 

 $pref::Video::displayDevice = "OpenGL";
$pref::Video::allowOpenGL = 1;
$pref::Video::allowD3D = 1;
$pref::Video::preferOpenGL = 1;
$pref::Video::appliedPref = 0;
$pref::Video::disableVerticalSync = 1;
$pref::Video::monitorNum = 0;
$pref::Video::windowedRes = "800 600";
$pref::Video::screenShotFormat = "PNG";

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...