Help required! - Game Window / GUI Control
by JW · in Torque Game Engine · 03/07/2005 (9:47 pm) · 12 replies
Hi all,
Please help (point to relevant resource / articles) if anyone has tried this:
- want that the Torgue Game Engine Window (i.e. launched throught the TGE DOS window) to maximize to current desktop resolution at the time of launch. By defult, the TGE Window takes a lower resolution then the desktop resolution.
Please help (point to relevant resource / articles) if anyone has tried this:
- want that the Torgue Game Engine Window (i.e. launched throught the TGE DOS window) to maximize to current desktop resolution at the time of launch. By defult, the TGE Window takes a lower resolution then the desktop resolution.
About the author
#2
If you run TGE without Fullscreen mode then the "Options" dialog box does not provide you the option to select the current desktop resolution, it only gives lower resolution options. Any pointers would be really helpful. Thanks
03/08/2005 (8:42 pm)
No. Actually I wanted the "Windowed version" i.e. the game window with the caption/ title bar on top to run at the current desktop resolution and not the Fullscreen Video. If you run TGE without Fullscreen mode then the "Options" dialog box does not provide you the option to select the current desktop resolution, it only gives lower resolution options. Any pointers would be really helpful. Thanks
#3
03/08/2005 (9:00 pm)
Hmmm....Not sure on that one. I have tried setting the relevant pref ($pref::Video::windowedRes) to my desktop res and it sized it down to something smaller. Maybe someone else has an idea.
#4
03/08/2005 (10:22 pm)
The engine forces you to the next smallest res in windowed mode. It's behaving as designed.
#5
03/08/2005 (11:02 pm)
Thanks Daniel. I know that but have a requirement to override this default behaviour. BTW, do you have an idea why the design is done for the next smallest resolution? I could not figureout why you can not run the game in the current desktop resolution.
#6
In all actuality, what you probably want to do is something like what the show tool pro does, right? (If you don't have it, grab the demo to see) It starts in a window, with the maximize/minimize/close buttons (which Torque does not have by default). STP does not start maximized but this is a simple setting in the window creation code (not script).
You should be able to change the settings related to window creation to get the engine to start you in a window, one lower than current desktop resolution, then tell windows to maximize it. I only know how to do this on Windows, so I can try to help you with that, but if you need cross-platform, you're out of luck. :)
03/09/2005 (10:06 am)
I can't say that I agree with whoever decided the engine should do that, but I think their reasoning was that if you let the user make it the current desktop res, the window controls would be cut off. In all actuality, what you probably want to do is something like what the show tool pro does, right? (If you don't have it, grab the demo to see) It starts in a window, with the maximize/minimize/close buttons (which Torque does not have by default). STP does not start maximized but this is a simple setting in the window creation code (not script).
You should be able to change the settings related to window creation to get the engine to start you in a window, one lower than current desktop resolution, then tell windows to maximize it. I only know how to do this on Windows, so I can try to help you with that, but if you need cross-platform, you're out of luck. :)
#7
1. Changed the code for selecting the next lower resolution to current desktop resolution in OpenGLDevice::setScreenMode (in winOGLVideo.cc and other respective cc file for D3D) and
2. also commented the code that used to handle the positioning of window when it was not running in full screen mode i.e. commented the following code:
This seems to solve my problem but have introduced some Mouse problems; the Torque mouse is now able to go below the Caption Title, which should not happen and also in the lower end of window the mouse movements are not smooth.
Any pointes why this is happening though I haven't touched any code related to Mouse but yes the windows boundary has increased!
03/10/2005 (10:42 pm)
Thanks Daniel. I tried out the following in the engine and recompiled it:1. Changed the code for selecting the next lower resolution to current desktop resolution in OpenGLDevice::setScreenMode (in winOGLVideo.cc and other respective cc file for D3D) and
2. also commented the code that used to handle the positioning of window when it was not running in full screen mode i.e. commented the following code:
// Move the window:
if ( !newFullScreen )
{
// Adjust the window rect to compensate for the window style:
/* RECT windowRect;
windowRect.left = windowRect.top = 0;
windowRect.right = newRes.w;
windowRect.bottom = newRes.h;
AdjustWindowRect( &windowRect, GetWindowLong( winState.appWindow, GWL_STYLE ), false );
U32 adjWidth = windowRect.right - windowRect.left;
U32 adjHeight = windowRect.bottom - windowRect.top;
// Center the window on the desktop:
U32 xPos = ( winState.desktopWidth - adjWidth ) / 2;
U32 yPos = ( winState.desktopHeight - adjHeight ) / 2;
test = SetWindowPos( winState.appWindow, 0, xPos, yPos, adjWidth, adjHeight, SWP_NOZORDER );
if ( !test )
{
dSprintf( errorMessage, 255, "OpenGLDevice::setScreenMode\nSetWindowPos failed trying to move the window to (%d,%d) and size it to %dx%d.", xPos, yPos, newRes.w, newRes.h );
AssertFatal( false, errorMessage );
return false;
}
*/
}
This seems to solve my problem but have introduced some Mouse problems; the Torque mouse is now able to go below the Caption Title, which should not happen and also in the lower end of window the mouse movements are not smooth.
Any pointes why this is happening though I haven't touched any code related to Mouse but yes the windows boundary has increased!
#8
03/11/2005 (11:47 am)
Try this... if ( !newFullScreen && ( newRes.w >= winState.desktopWidth || newRes.h >= winState.desktopHeight ) )
{
/*Con::warnf( ConsoleLogEntry::General, "OpenGLDevice::setScreenMode -- can't switch to resolution larger than desktop in windowed mode!" );
// Find the largest standard resolution that will fit on the desktop:
U32 resIndex;
for ( resIndex = mResolutionList.size() - 1; resIndex > 0; resIndex-- )
{
if ( mResolutionList[resIndex].w < winState.desktopWidth
&& mResolutionList[resIndex].h < winState.desktopHeight )
break;
}*/
[B] // Match the new resolution to one in the list:
U32 resIndex = 0;
U32 bestScore = 0, thisScore = 0;
for ( int i = 0; i < mResolutionList.size(); i++ )
{
if ( newRes == mResolutionList[i] )
{
resIndex = i;
break;
}
else
{
thisScore = abs( S32( newRes.w ) - S32( mResolutionList[i].w ) )
+ abs( S32( newRes.h ) - S32( mResolutionList[i].h ) )
+ ( newRes.bpp == mResolutionList[i].bpp ? 0 : 1 );
if ( !bestScore || ( thisScore < bestScore ) )
{
bestScore = thisScore;
resIndex = i;
}
}
}[/B]
newRes = mResolutionList[resIndex];
}U32 test = ChangeDisplaySettings( &devMode, 0 );
if ( test == DISP_CHANGE_SUCCESSFUL )
{
testWindow = CreateWindow(
"OGLTest",
"",
WS_OVERLAPPED | WS_CAPTION[B] | WS_MAXIMIZE[/B],
0, 0, 640, 480,
NULL,
NULL,
winState.appInstance,
NULL );
#9
03/11/2005 (11:47 am)
Worked great for me. :)
#10
Implemented this but unable to launch the TGE window; the Torque DOS window opens and TGE window is running in minimised mode & unable to respond and maximise.
Followed the following steps for Windowed version and not full-screen:
1. Run the exe in 1024X768 resolution; was able to successfully open 800X600 TGE window.
2. Closed the application and changed the desktop resolution to 800X600 and on running the exe it just launches Torque DOS window and un-able to launch TGE
03/14/2005 (9:40 pm)
Thanks Daniel. Sorry, couldn't try this earlier.Implemented this but unable to launch the TGE window; the Torque DOS window opens and TGE window is running in minimised mode & unable to respond and maximise.
Followed the following steps for Windowed version and not full-screen:
1. Run the exe in 1024X768 resolution; was able to successfully open 800X600 TGE window.
2. Closed the application and changed the desktop resolution to 800X600 and on running the exe it just launches Torque DOS window and un-able to launch TGE
#11
03/14/2005 (10:20 pm)
Odd. If you send me an e-mail (see profile) I will respond and send you my winOGLVideo.cc file. I have it working right now in an otherwise unmodified TGE starter.fps demo.
#12
03/14/2005 (10:44 pm)
Tried the same on another machine and it is working. Could be problem with available resolutions on a machine. Let me dig deep into it and figure out why its causing problem on my machine. Thanks
Torque 3D Owner Jacob