Game Development Community

Screen aspect ratios

by Vern Jensen · in Torque Game Builder · 06/21/2007 (11:04 am) · 4 replies

Here's a fairly common problem. You design a game at some resolution (say, 800x600), but when it's run fullscreen, it's expanded to fill the *entire* screen, which might end up stretching it so that the images are distorted. For instance, on my iMac's beautiful 20" screen, the native resolution is 1680x1050. That's a 1.6 ratio versus the 1.33 ratio of 800x600. This means images are stretched wider than they should be when I go fullscreen.

I'd like to have the option of having black borders on the sides instead, so the images retain their proper aspect ratio. I'm wondering if this is even possible in Torque, and if so, what the recommended approach is.

My guess is that I'd want to add another t2dSceneGraph to the window (is this even possible?), and resize the original sceneGraph to make it the original proportion, and then add t2dSceneGraphs to the left and right sides, making them black, for the black border. But I'm not sure even which calls I would use to add t2dSceneGraphs to the window, or if it's even possible. Or maybe I'm thinking of going about it all the wrong way.

-Vern

#1
06/23/2007 (4:31 am)
Hi,

I think want you want to do can be done by adjusting mainScreen.gui. Here is an example of displaying a 800x600 scene centered in a 1024x768 window:

%guiContent = new GuiControl(mainScreenGui) {
   canSaveDynamicFields = "0";
   Profile = "GuiBlackContentProfile";
   HorizSizing = "width";
   VertSizing = "height";
   Position = "0 0";
   Extent = "1024 768";
   MinExtent = "8 8";
   canSave = "1";
   Visible = "1";
   useVariable = "0";

   new t2dSceneWindow(sceneWindowPlayer0) {
      canSaveDynamicFields = "0";
      Profile = "GuiContentProfile";
      HorizSizing = "width";
      VertSizing = "height";
      Position = "112 84";
      Extent = "800 600";
      MinExtent = "8 8";
      canSave = "1";
      Visible = "1";
      lockMouse = "0";
      useWindowMouseEvents = "1";
      useObjectMouseEvents = "1";
   };
};
#2
06/23/2007 (10:48 am)
Awesome, I'll give that a try!
#3
06/23/2007 (1:37 pm)
Oh wow, is it really that simple? I thought I was gonna have to jump through hoops to get Widescreen support in any shape or form in my game. I'm bookmarking this page for great justice!
#4
06/26/2007 (2:17 pm)
While this works fine for the scenegraph itself, other GUIs that are pushed onto the Canvas will still be stretched. The only fix I've found for that is either some tweaks to the engine code to resize GUIs as they're pushed to the canvas, or resizing every GUI in script when you go to fullscreen. In either case, text remains an issue - counter-squashing it makes it too aliased. It would be possible to switch fonts for widescreen monitors, however.