Game Development Community

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. :)
Page «Previous 1 2
#1
07/19/2011 (2:26 pm)
In short, you don't really have to handle widescreen resolution in any way. Just set your project to the resolution you want to use. Aspect ratio is a property of the display, as well as fill/fit setting. If it is set to stretch, let it be. Some players do prefer it that way, some just not aware that they have to make some ajustments - either way it is out of your "jurisdiction".

This is a common question, if you do a search you'll be able to find a few threas where it was discused if you are interested in details/options.
#2
07/19/2011 (11:45 pm)
Edit * incomplete post *
#3
07/19/2011 (11:47 pm)
Thanks for the response Rpahut,

Thing is we have had some negative feedback from the stretching that occurs from putting our game on widescreen monitors. Would really love to find a solution that doesn't involve stretching.

I have done some searching for things like "wide screen", haven't turned up much, would you have any links to share on this?
#4
07/20/2011 (1:10 am)
Well, you can not take resposibility for improper settings on user's side, can you? If you do then, to what extent?


Here are some discussions on widescreen and Torque:
Widescreen?

Menu Screen: dealing with widescreen

Torque and Widescreens - What's the Best Approach?
#5
07/20/2011 (10:28 am)
In what world are stretched and distorted images either acceptable or prefered by users.

And how is having a widescreen monitor "improper user settings"?
#6
07/20/2011 (12:11 pm)
You could have a chkbox option in the options menu for widescreen that can be ticked when full screen mode is selected for widescreen monitors.
If ticked, adjust the width and height of the camera in the scene each time the scene is loaded to be wider width than before. Simple math will give you the correct width to use.
Simple and works. :D
#7
07/20/2011 (12:15 pm)
You could have a chkbox option in the options menu for widescreen that can be ticked when full screen mode is selected for widescreen monitors.
If ticked, adjust the width of the camera in the scene each time the scene is loaded, based on the height of the camera. Simple math will give you the correct width to use.

For normal mode;
camera.width = (camera.height /3) *4;

For widescreen mode;
camera.width = (camera.height /9) *16;

Should work fine.
Doing something like this but without the chkbox for the iphone resolution.
#8
07/20/2011 (12:36 pm)
I think the function t2dSceneWindow::loadLevel in the file commongameScriptslevelManagement.cs would be a good place to start as this already sets up the camera, a few small amendments and you will be set.
This is the area of the function you should look at.

// Set the window properties from the scene graph if they are available.
   %cameraPosition = %sceneWindow.getCurrentCameraPosition();
   %cameraSize = t2dVectorSub(getWords(%sceneWindow.getCurrentCameraArea(), 2, 3),
                              getWords(%sceneWindow.getCurrentCameraArea(), 0, 1));
                              
   if (%scenegraph.cameraPosition !$= "")
      %cameraPosition = %scenegraph.cameraPosition;
   if (%scenegraph.cameraSize !$= "")
      %cameraSize = %scenegraph.cameraSize;
      
   %sceneWindow.setCurrentCameraPosition(%cameraPosition, %cameraSize);

scenewindow Dump method info that may help.

setCurrentCameraArea() - (x1 / y1 / x2 / y2) - Set current camera area.@param x1,y1,x2,y2 The coordinates of the minimum and maximum points (top left, bottom right)
The input can be formatted as either "x1 y1 x2 y2", "x1 y1, x2 y2", "x1, y1, x2, y2"
@return No return value.

setCurrentCameraPosition() - (x / y / [width / height]) - Set current camera position.
@param There are 5 possible formats for input: (x1, y1), ("x1 y1"), (x, y, width, height) ("x1 y1", "width height") (x1, y1, x2, y2)@return No return value.
#9
07/21/2011 (1:33 am)
@Bloodknight Will _you_ take a responsibility to decide what is acceptable for user? In what world that is a way of thinkin for a programmer?

I prefer to not take my users as stupid beings incapable of adjusting their displays to their peronal liking. I assume that if display is set to stretch, there is a reason for that.
#10
07/21/2011 (3:43 am)
You are assuming that all widescreen monitors have a choice, that assumption is one that's incorrect. The game itself should gracefully adapt the aspect ratio in such cases.
#11
07/21/2011 (5:00 am)
I assume that display claiming it supports 4:3 resolution should be able to handle it properly.

In general, I assume my game will run on properly set hardware, because otherwise it will have to gracefully adapt to borked mices and worn off keyboards, lack of free RAM or harddrive space, missing drivers, incomplete installation and god knows what else.
#12
07/21/2011 (5:23 am)
Granted, PC development isnt without its issues, but as far as widescreen monitors go, ive had 1 in 3 that actually supports 4:3, and 0 in 3 laptops that support 4:3.

The issue here is that TGB doesnt gracefully support multi-resolutions in a user friendly way or even a developer friendly way that ive noticed. Something i hope will be addressed in future editions.
#13
07/21/2011 (8:01 am)
@Bloodknight Can't confirm your statistics. 1024x768 is the most widely supported resolution. That's why it is used so often by game developers in the first place!

There are minor number of displays not supporting it, primarly over laptops I must agree, especially over non-gaming kind. One will have to decide if he wants to add a support for these rarely used for gaming freak extremes, or rather spend same time and effort to add some more profitable features to the game.

I'm not saying again that 'smart' resolution selection can be completely replaced with hardcoded 1024x768, but considering effort-coverage ratio it is far from not acceptible.
#14
07/21/2011 (11:08 am)
@ Bloodknight:
I agree that TGB should auto detect the screen width and adjust so the game will always display without being stretched, but think supplying a game engine with this setup as default might not be the right thing to do. A bit of creative thinking is all thats needed by the programmer.

The code above is the area you need to amend.
If you can detect the screen resolution through script or amend the engine to do this for you and pass it to script, you can easily do this auto on launching the game. Wouldn't need a chkbox to tick, You would just always adjust the camera width to match the screen width based on the camera height and screen height.
Simple.
#15
07/21/2011 (5:06 pm)
Thank you everyone for all the feedback. So after reading thru the links provided, and everyone's info, and doing some thinking, I think I will do this, tell me if I missed something.

- When switching to fullscreen, call getDesktopResolution() and figure out ratio, because of bug with taskbar, find ratio that is closest, from 16:9, 16:10 and 4:3 (that's what we decided to support, sorry 5:4 screen owners).

- After figuring out full screen ratio, if its widescreen, then keep camera height at 768, and make the new camera width be 768 * full screen ratio. Call setScreenMode with these numbers. Also call SetCameraArea() to match.

- Either add larger background graphics on the new vertical areas for things like full screen images for menu screens etc (keep current screen graphics centered horizontally), or in game redo the layout of the graphic elements taking advantage of new extra wide layout.


How does that sound?
#16
07/21/2011 (5:40 pm)
Sounds good.
You can simply work out the CameraWidth = CameraHeight*(deskwidth/deskheight)
Tricky bit is getting the deskwidth and deskheight. :D
That should work on any resolution and keep thinks correct I think.
#17
07/21/2011 (7:17 pm)
Yeah thats why I am going to use getDesktopResolution() and then see what known screen ratio it is closest too, since the results change if taskbar is hidden or not.

I appreciate the help!
#18
07/22/2011 (12:42 am)
One thing left to add, more for people fwo will read this thread later.

The fix to getDesktopResolution. Would prefer it not being broken in the first place.

getDesktopResolution (platformWin32\winWindow.cc line 1338)
//Result.w = winState.desktopClientWidth;
   //Result.h = winState.desktopClientHeight;
   Result.w = winState.desktopWidth;
   Result.h = winState.desktopHeight;

Another reason to buy Pro... Hate GG for dirty tricks like that.
#19
07/23/2011 (7:09 am)
@ Rpahut
What version of TBG do you have.
Its not like that in 1.7.4
#20
07/23/2011 (7:59 am)
Oh yes. Should have mention that I believe. 1.7.5 it is.
Page «Previous 1 2