Game Development Community

Problem with getDesktopResolution

by James Terry · in Torque Game Builder · 10/03/2006 (4:14 pm) · 3 replies

Yesterday I threw some detection into the game I'm working on

if (GetWord(GetDesktopResolution(),0) <= 1024 && GetWord(GetDesktopResolution(),1) <= 768)
{
if (!isFullScreen())
toggleFullScreen();
GameOptions.IsFullScreen = true;
OptionsFrameFullScreenCheckbox.setActive(false);
}
else
OptionsFrameFullScreenCheckbox.setActive(true);

It was working correctly yesterday that if you're backround desktop resolution was less than 1024x768, full-screen would be forced and you would not be able to select the check box

When I entered the game at 800x600 and ran echo(getDesktopResolution()); it outputted "800 600 32"


When I booted up the game today with the same settings, echo(getDesktopResolution()); outputted "1024 768 32", no matter what I changed my desktop resolution to.

I'm wondering if anyone has had this problem or might have a suggestion on finding a fix.

Thanks,

James

#1
10/03/2006 (8:40 pm)
Were you changing it while TGB was running? It might detect the setting only at startup.
#2
10/03/2006 (9:08 pm)
I know it changes during runtime.

If I start the game in 1280x1024 in windowed mode, I get this output

getDesktopResolution() -> "1280 1024 32"
toggleFullScreen() - now in full screen
getDesktopResolution() -> "1024 768 32"
toggleFullScreen() - now in window
getDesktopResolution() -> "1280 1024 32"
etc.

I am pretty sure given this same scenario when I was trying yesterday would give the output of "1280 1024 32" each call, but I may have had something mistaken.

So I guess my question now is, how would I go about making some functionality where if a player's current desktop resolution is less than 1024x768 it disables the ability to change it to windowed mode?
#3
01/22/2009 (6:20 am)
Yes, when you go fullscreen in torque, it forces system's resoultion to what you set in torque. This is a normal behaviour.

And the problem is that "getDesktopResolution" function gets the system's current resoultion which is changed by the torque.

What you need is a function that returns the original desktop resolution before torque forced to change it (by going full screen).

Maybe you can save it to a global value just when the torque is launched, before setting the system resoution (ie. if it starts in fullscreen mode).

PS: I am using TGE, not TGB. But I guess it is the same thing.