Widescreen?
by Palle M. Pedersen · in Torque Game Builder · 07/29/2007 (1:36 am) · 13 replies
Is there some smart way to prepare a fullscreen game for 4:3 as well af widescreens?
It seems that there now is a number of screen geometries around, so you can't even count on the screen to have either a 4:3 or a 16:9 ratio.
Is the way to proceed to have all graphic resources in the game in both 4:3 and 16:9 (in order to not have them squeeced flat) and then pad the borders somehow for the other geometries?
- Palle
It seems that there now is a number of screen geometries around, so you can't even count on the screen to have either a 4:3 or a 16:9 ratio.
Is the way to proceed to have all graphic resources in the game in both 4:3 and 16:9 (in order to not have them squeeced flat) and then pad the borders somehow for the other geometries?
- Palle
#2
07/29/2007 (12:57 pm)
Thanks for the quick response. Now I know where to look for the solution.
#3
08/13/2007 (2:56 pm)
Could someone please elaborate on how this might be done? We have experimented with such methods to accommodate for widescreen monitors, but we have found that GUIs are not affected by camera adjustment. I would prefer a solution much like Palle was suggesting in the first post, simply adding padding to the sides of the screen so that we would not have to worry about placement on alternate screen resolutions.
#4
You're better off building a simple GUI system using TGB objects
08/13/2007 (3:59 pm)
The old GUI system is not a good way to go if you want to deal with varying screen geometries.You're better off building a simple GUI system using TGB objects
#5
1) Implement all your GUI controls via sceneobjects - then all you have to do is set the camera size and everything will be scaled correctly. The problem is that you have to reimplement any types of controls you want to use, which may not be practical.
2) Implement a seperate version of each GUI for each screen resolution, then switch which ones you load based on the prefs. However, this only works if you're talking about a limited number of resolutions.
3) Modify the engine code to counterscale GUIs. This requires the Pro version and is a fair amount of work, but only needs to be implemented once. But there's one big flaw - text doesn't look good when scaled this way. So you'll need a workaround for that.
That said, there may be better alternatives out there, these are just the ones I'm aware of.
08/14/2007 (1:56 pm)
I've run into that problem, and it's not an easy one to fix. There seem to be three solutions:1) Implement all your GUI controls via sceneobjects - then all you have to do is set the camera size and everything will be scaled correctly. The problem is that you have to reimplement any types of controls you want to use, which may not be practical.
2) Implement a seperate version of each GUI for each screen resolution, then switch which ones you load based on the prefs. However, this only works if you're talking about a limited number of resolutions.
3) Modify the engine code to counterscale GUIs. This requires the Pro version and is a fair amount of work, but only needs to be implemented once. But there's one big flaw - text doesn't look good when scaled this way. So you'll need a workaround for that.
That said, there may be better alternatives out there, these are just the ones I'm aware of.
#6
www.garagegames.com/mg/forums/result.thread.php?qt=66074
08/15/2007 (6:26 am)
I have to agree with Spider. I have some simple GUI widgets using scene objects and it's much nicer to work with. It's just taking some time to get all of the widgets together and working correctly. Has anyone had success with this approach? I've created a new thread for this topic:www.garagegames.com/mg/forums/result.thread.php?qt=66074
#7
08/15/2007 (8:22 am)
Another option, while maybe not the best but could work in some situations; Just restrict the user from choosing a widescreen resolution. Most widescreen monitors should create black bars to the side of the game automatically.
#8
08/16/2007 (1:50 pm)
Setting fullscreen with a non-widescreen resolution (800x600, for instance), results in the image being stretched, on all widescreen monitors I've seen.
#9
And most monitors are 16:10, rather than the 16:9 of TVs.
08/16/2007 (3:35 pm)
But most monitors will have "fit" option that will put black borders around the actual screen so it appears in the right aspect ratio.And most monitors are 16:10, rather than the 16:9 of TVs.
#10
Default settings for drivers as well as bios is stretch to fullscreen, not "don't stretch" or "keep aspect ratio on stretch", I fear ...
08/16/2007 (11:56 pm)
No most monitors actually will not.Default settings for drivers as well as bios is stretch to fullscreen, not "don't stretch" or "keep aspect ratio on stretch", I fear ...
#11
08/17/2007 (4:06 am)
That's weird. I'm pretty sure all my widescreen monitors maintain the correct aspect ratio (as in, it adds black bars) even if they're set to stretch. (I could of course be wrong though.... have to check more thoroughly some day).
#12
Even though this code is pretty specific to my own needs, maybe it'll be helpful to someone else, perhaps only in knowing that certain functions exist.
08/17/2007 (10:55 am)
In my game, the camera size is fixed, so I have the option when going full-screen of either stretching-to-fit wider displays (default), or displaying black bars on the sides (custom code required). The handleWidescreenChange() function handles this.Even though this code is pretty specific to my own needs, maybe it'll be helpful to someone else, perhaps only in knowing that certain functions exist.
function doMyToggleFullscreen()
{
%info = getDesktopResolution();
%width = getWord(%info, 0);
%height = getWord(%info, 1);
%depth = getWord(%info, 2);
if ( isFullScreen() )
{
setScreenMode(800,600,32,false);
resetWidescreen();
}
else
{
setScreenMode(%width, %height, 32, true);
handleWidescreenChange();
}
// OTHER COMMANDS:
// setRes(width, height, bitDepth);
// toggleFullScreen(); // Keeps bit depth the same, so it can look blocky full-screen if you're not careful
// isFullScreen(); // Is it currently fullscreen?
// getResolutionList();
// getDesktopResolution(); // returns width, height, and bitdepth
}
// Call this when returning to original window size.
function resetWidescreen()
{
// Get the resolution of the window
%info = getRes();
%width = getWord(%info, 0);
%height = getWord(%info, 1);
// Set everything to be that same resolution
mainScreenGui.setExtent( %width, %height );
sceneWindow2D.setExtent( %width, %height );
sceneWindow2D.setPosition( 0, 0 );
}
// NOTE: See "MainScreen.gui" in the "game/gui" folder for names of GUI elements
// that we access directly here. ("sceneWindow2D" and "mainScreenGui")
// I can add more GUI elements or rename them in that file.
function handleWidescreenChange()
{
// Get the current resolution of our game *window* (not of the desktop)
// NOTE: it's possible to be full-screen, and still a much lower resolution that the desktop res
%info = getRes();
%width = getWord(%info, 0);
%height = getWord(%info, 1);
// setExtent = set the size of the control
mainScreenGui.setExtent( %width, %height );
%info = sceneWindow2D.getExtent();
%windowWidth = getWord(%info, 0);
%windowHeight = getWord(%info, 1);
%ratio = 800 / 600;
%newWidth = mCeil( %height * %ratio );
// Is the window the correct size for the game anyway? Then don't allow any widescreen changes.
%canHaveBlackBorders = (%newWidth != %windowWidth);
// Were we already widescreen? Then switch to black borders on the sides.
if ($wideScreenIsOn == false && %canHaveBlackBorders)
{
// sceneWindow2D is a GUI control that is put INSIDE of the mainScreenGui control
sceneWindow2D.setExtent( %newWidth, %height );
sceneWindow2D.setPosition( 140, 0 );
}
else
{
// Switch to widescreen
sceneWindow2D.setExtent( %width, %height );
sceneWindow2D.setPosition( 0, 0 );
}
}
$wideScreenIsOn = true; // Default value
function toggleWidescreen()
{
$wideScreenIsOn = !$wideScreenIsOn;
handleWidescreenChange();
}
#13
tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/GuiResolution
The main point of this tutorial is
All GUIs have an attribute called HorizSizing and VertSizing.
Go through your entire project and change the value for these attributes to "relative". This will also ensure that images used in GUIs are re-sized.
This seems handles the GUI part of the widescreen issue.
09/07/2007 (6:18 am)
FWIW, i found a nice tutorial on dynamicllay re-sizing your gui based on the screen resolution.tdn.garagegames.com/wiki/Torque_2D/StandardTutorials/Basics/GuiResolution
The main point of this tutorial is
All GUIs have an attribute called HorizSizing and VertSizing.
Go through your entire project and change the value for these attributes to "relative". This will also ensure that images used in GUIs are re-sized.
This seems handles the GUI part of the widescreen issue.
Associate Tom Eastman (Eastbeast314)
Anyway, you don't need to modify your assets at all. As long as the aspect ratio of the camera size matches the resolution's, then everything will look right.
That probably didn't make much sense :)
I'd recommend looking at the reference doc for the camera and resolution functions (or playing with them in the levelbuilder) and seeing how they change things.