How to handle fullscreen on widescreen monitor?
by Blake Drolson · in Torque Game Builder · 07/18/2011 (9:27 pm) · 22 replies
Hi there TGB lovers,
So in developing the game my partner and I are working on , we noticed that when switching to a full screen view on a wide screen monitor, our screen is stretched horizontally a bit to make up the screen space. I would like to set it up so that the window is matching the aspect ratio of the monitor when going full screen. I would be thankful for any advice or examples or handling widescreen.
Now we normally run our game at 1024 x 768 in windowed mode and full screen on a 4 : 3 monitor. Does anyone know if I can set the "setScreenMode()" call to set the screen to a proper wide screen resolution, then use "setCurrentCameraArea()" to set the camera size to height = 768, and the width = %newWidth,
where %newWidth = 768 * %wideScreenAspectRatio ? This way I can deal with only changing x coordinates on the screen switch.
The other part is how to determine the correct display size? Probably getDesktopResolution()??? thing is when I do that its almost right, if my taskbar is showing then it gives me 1600 x 870, where its really 900. If I set my taskbar to auto-hide then the function returns the correct 1600 x 900.
I also looked at getResolutionList(), and it gave me the following list, really aspect ratios all over the place... seems less use than getDesktopResolution(), since the first resolution matches.
1600 900 32 640 480 32 720 480 32 720 576 32 800 600 32 1024 768 32 1152 864 32 1280 720 32 1280 768 32 1280 800 32 1280 960 32 1280 1024 32 1360 768 32 640 480 16 720 480 16 720 576 16 800 600 16 1024 768 16 1152 864 16 1280 720 16 1280 768 16 1280 800 16 1280 960 16 1280 1024 16 1360 768 16 1600 900 16 640 360 16 640 360 32
Finally, right now when switching to full screen I have used toggleFullScreen(). When I switch from a windowed screen in 4:3 aspect ratio, to a full screen in widescreen, should I just use setScreenMode()??, setting the proper sizes? Other calls to be made?
This is a bit tricky, if anyone has working examples would be great to see. Thanks in advance for any help. :)
So in developing the game my partner and I are working on , we noticed that when switching to a full screen view on a wide screen monitor, our screen is stretched horizontally a bit to make up the screen space. I would like to set it up so that the window is matching the aspect ratio of the monitor when going full screen. I would be thankful for any advice or examples or handling widescreen.
Now we normally run our game at 1024 x 768 in windowed mode and full screen on a 4 : 3 monitor. Does anyone know if I can set the "setScreenMode()" call to set the screen to a proper wide screen resolution, then use "setCurrentCameraArea()" to set the camera size to height = 768, and the width = %newWidth,
where %newWidth = 768 * %wideScreenAspectRatio ? This way I can deal with only changing x coordinates on the screen switch.
The other part is how to determine the correct display size? Probably getDesktopResolution()??? thing is when I do that its almost right, if my taskbar is showing then it gives me 1600 x 870, where its really 900. If I set my taskbar to auto-hide then the function returns the correct 1600 x 900.
I also looked at getResolutionList(), and it gave me the following list, really aspect ratios all over the place... seems less use than getDesktopResolution(), since the first resolution matches.
1600 900 32 640 480 32 720 480 32 720 576 32 800 600 32 1024 768 32 1152 864 32 1280 720 32 1280 768 32 1280 800 32 1280 960 32 1280 1024 32 1360 768 32 640 480 16 720 480 16 720 576 16 800 600 16 1024 768 16 1152 864 16 1280 720 16 1280 768 16 1280 800 16 1280 960 16 1280 1024 16 1360 768 16 1600 900 16 640 360 16 640 360 32
Finally, right now when switching to full screen I have used toggleFullScreen(). When I switch from a windowed screen in 4:3 aspect ratio, to a full screen in widescreen, should I just use setScreenMode()??, setting the proper sizes? Other calls to be made?
This is a bit tricky, if anyone has working examples would be great to see. Thanks in advance for any help. :)
#22
05/07/2014 (8:00 am)
Thanks for the contribution Jeff. Something worth nothing, though, is that this is a pretty old post. Because the content of this necro actually contains a solution, we can let it slide. Be sure to check the date next time. It might be worth you creating a new thread with the solution so it's at the top of someone's search.
Torque Owner Jeff Moretti
function sceneWindow2D::onExtentChange( %this, %data )
{
if( $qInExtentChange ) return;
$qInExtentChange = true;
setAcceptableScreenRatio();
// If the current scene has an extent change method, call it
//$lastLoadedScene.onExtentChange(); - commented out by Jeff, I dont think this is needed
$qInExtentChange = false;
}
function setAcceptableScreenRatio()
{
%screenWidth = getWord( Canvas.extent, 0 );
%screenHeight = getWord( Canvas.extent, 1 );
%screenRatio = %screenWidth / %screenHeight;
%optimalRatio = 800 / 600;
%newWidth = %screenWidth;
%newHeight = %screenHeight;
if( %screenRatio < %optimalRatio )
%newHeight = %screenWidth / %optimalRatio;
else if( %screenRatio > %optimalRatio )
%newWidth = %screenHeight * %optimalRatio;
%newX = (%screenWidth - %newWidth) / 2.0;
%newY = (%screenHeight - %newHeight) / 2.0;
sceneWindow2D.setPosition( %newX, %newY );
sceneWindow2D.setExtent( %newWidth, %newHeight );
}
Got this from a previous post. Feel free to use! Note, I think this only works with the old version of torque (1.8.0 and before). 2.0 and above I don't think this works