Game Development Community

My resolution keeps changing... a fix?

by amaranthia · in Torque Game Builder · 01/18/2007 (11:54 am) · 3 replies

I've set the game's default resolution to 1024x768. However, on some computers, the resolution is changed to 800x600. I have no idea why this is happening, but when it does happen, my GUIs don't adjust. Is there a way to keep the resolution static when it is in windowed mode?

Each time I run the game on my laptop, this field changes in pref.cs:

Before: $pref::Video::windowedRes = "1024 768 32";
After: $pref::Video::windowedRes = "800 600 32";

(Now, I would love to be able to have my GUIs adjust automatically, but I've yet to get this to work. Is there a way to control where they appear using percentages, not fixed numbers?)

#1
01/18/2007 (3:34 pm)
Duh! figured it out! I needed to change every single vertSizing and horizSizing to relative (was only setting the parent guis before.) :D
#2
01/18/2007 (5:25 pm)
If your desktop resolution is 1024x768 and the prefs say windowed at that res, it will drop to the next smaller resolution supported by the vid card. In other words, the highest possible windowed resolution is always one less than the current desktop resolution. Hopefully that makes sense!

#3
01/18/2007 (6:06 pm)
Try setting your default windowed resolution to 1024x768 in defaultPrefs.cs if you definitely want the game forced to 1024x768 windowed when it starts up. I'm pretty sure that'll do it, but since I got around the issue in an unrelated way, I'm not 100% sure that just that will do it, so here's the reasoning

Take a look at common/gameScripts/canvas.cs. If you are defaulting to windowed mode and your windowed resolution is not set, it goes through and best fits the resolution to one resolution under your current desktop resolution. If the user runs the game for the first time and their desktop resolution is 1024x768, that would be 800x600.

If you are shipping your game by using the packaging utility and then sending that output folder off, prefs.cs and prefs.cs.dso are not included (and probably shouldn't be), which is where the resolutions will always be stored after the first run. Only defaultPrefs.cs.dso is, which does not by default define the full-screen or windowed resolutions.

As for relative sizing, be careful about using it if you're changing resolutions while the game is running. You may start to notice your controls slowly drift out of place, one or two pixels at a time. This is because it doesn't keep track of the original position it resized from, nor does it keep around a fractional value for resizes. I think just 1024x768 to 800x600 and back might be okay though because the scaling factor of 1.28 between them shouldn't cause any rounding problems. For example, going from 1024x768 to 640x480 (a scaling factor of 1.6) your control at x=159 goes to 99 (99.384). Now go back to 1024x768 and it moves to 158 (158.4), which is not where it came from. The solution to the general problem requires rewriting the way relative positioning works in the engine, so don't worry about it unless you have the issue. Just a heads up.