Starting in Fullscreen mode - advice please
by Colin Richardson · in Torque Game Builder · 10/06/2009 (5:27 pm) · 14 replies
Hello,
Been working on our splash screens to our game today and been looking into making the game full screen upon startup.
Now there seems to be a number of ways to make the game run in full screen, everything from simply adding (all these examples in the initializeProject() function):
And both of these work.
However they're messy.
When i start my game (i'm using Torsion and testing the Build) it starts full screen, flickers down to a window, then resizes back to full screen.
I've used Torsion to find me where the various scripts are that set the video etc, but i'm not one for touching then as they may cause my untold grief later on.
So can anyone point me towards a nicer more tidier of starting up in fullscreen please.
Thanks in advance
Colin
Been working on our splash screens to our game today and been looking into making the game full screen upon startup.
Now there seems to be a number of ways to make the game run in full screen, everything from simply adding (all these examples in the initializeProject() function):
ToggleFullScreen();or the more advanced
$pref::Video::fullScreen = 1; setscreenmode(1024, 768, getWord($pref::Video::resolution, 2), $pref::Video::fullScreen);
And both of these work.
However they're messy.
When i start my game (i'm using Torsion and testing the Build) it starts full screen, flickers down to a window, then resizes back to full screen.
I've used Torsion to find me where the various scripts are that set the video etc, but i'm not one for touching then as they may cause my untold grief later on.
So can anyone point me towards a nicer more tidier of starting up in fullscreen please.
Thanks in advance
Colin
#2
I'd try that and see if that get your game to start in fullscreen mode and stay there. I'm not sure what's causing your game to go to windowed mode after it starts in full screen but I suspect that one of the methods above is the cause. The game I just finished needed to start in full screen mode and all the change I had to make was to change the value in the commonConfig. I never experienced the flicker that you or the above poster are talking about so I'm not sure what's causing that.
10/06/2009 (6:11 pm)
Trying adding <FullScreen>true</FullScreen> to your commonConfig.xml yet?I'd try that and see if that get your game to start in fullscreen mode and stay there. I'm not sure what's causing your game to go to windowed mode after it starts in full screen but I suspect that one of the methods above is the cause. The game I just finished needed to start in full screen mode and all the change I had to make was to change the value in the commonConfig. I never experienced the flicker that you or the above poster are talking about so I'm not sure what's causing that.
#3
Thanks for the reply. I did indeed try this a bit earlier but didn't want to touch that script just in case...
So i've updated it, made the fullscreen = true etc, and you are correct, it's a lot less messy than before which is nice, but not perfect.
I will continue to look when i find some more time in the week, this will do for now, cheers!
@Nate, cheers for your reply, i've already tried that and it didn't do a thing, silly thing, can't see any use of it really, and from my searching of the forum earlier others have tried and failed with this, it could be my card in this laptop, so i'll try on another PC tomorrow.
But thanks to you both for a quick reply.
Have fun :)
10/06/2009 (6:26 pm)
@William, Thanks for the reply. I did indeed try this a bit earlier but didn't want to touch that script just in case...
So i've updated it, made the fullscreen = true etc, and you are correct, it's a lot less messy than before which is nice, but not perfect.
I will continue to look when i find some more time in the week, this will do for now, cheers!
@Nate, cheers for your reply, i've already tried that and it didn't do a thing, silly thing, can't see any use of it really, and from my searching of the forum earlier others have tried and failed with this, it could be my card in this laptop, so i'll try on another PC tomorrow.
But thanks to you both for a quick reply.
Have fun :)
#4
Find the place where the Canvas is created and immediately set the video mode. This will make it fullscreen as soon as the platform window is created.
10/06/2009 (6:53 pm)
Quote:If somebody else has a clean way for the game to come up as a fullscreen window immediately, I'd love to learn it, too.
Find the place where the Canvas is created and immediately set the video mode. This will make it fullscreen as soon as the platform window is created.
#5
I thought I would post this here for others as I believe I have a clean solution if you have source access.
I had been searching for a fix for this myself, but didn't come across any on the forums to load the engine directly into the fullscreen resolution I wanted to set in my startup script. It always switched briefly to a low resolution window first before adopting my resolution and going fullscreen.
I located the points in the source where the initial low resolution is set during start up and disabled it by commenting it out. Then I created a new build and copied the TGBGame.exe file over to my project folder and tested it. The game now starts smoothly going directly into the fullscreen resolution that I set in script. I verified in the log that it only sets the screenmode once during startup.
The files and line numbers you need to comment out "//" are:
winOGLVideo.cc -- lines 489 and 490
winD3DVideo.cc -- lines 118 and 119
winV2Video.cc -- lines 173 and 174
The engine might set the screenmode from any of these files during startup depending on what display device is being used.
I don't think there is any negative consequence to doing this as it is only setting the screenmode, which most developers are going to want to handle themselves anyways.
02/04/2012 (12:01 am)
**edit: this solution was discovered to cause an ALT-Tab crash so not recommended, check alternate solution below - Evan**I thought I would post this here for others as I believe I have a clean solution if you have source access.
I had been searching for a fix for this myself, but didn't come across any on the forums to load the engine directly into the fullscreen resolution I wanted to set in my startup script. It always switched briefly to a low resolution window first before adopting my resolution and going fullscreen.
I located the points in the source where the initial low resolution is set during start up and disabled it by commenting it out. Then I created a new build and copied the TGBGame.exe file over to my project folder and tested it. The game now starts smoothly going directly into the fullscreen resolution that I set in script. I verified in the log that it only sets the screenmode once during startup.
The files and line numbers you need to comment out "//" are:
winOGLVideo.cc -- lines 489 and 490
winD3DVideo.cc -- lines 118 and 119
winV2Video.cc -- lines 173 and 174
The engine might set the screenmode from any of these files during startup depending on what display device is being used.
I don't think there is any negative consequence to doing this as it is only setting the screenmode, which most developers are going to want to handle themselves anyways.
#6
02/04/2012 (5:21 pm)
Thanks for tracking this down!
#7
One word of caution though I forgot to mention. When creating the new build, you'll want to be sure to apply this change only to the TGBGame project within the solution explorer. If this change is applied to the TorqueGameBuilder project the editor won't start and comes up with an error when you try to launch it.
This can be done by right clicking the TGBGame project in the solution explorer and choosing "Project Only> Build Only TGBGame"
You'll have to remember to uncomment the lines if you at some point after that need to build the TorqueGameBuilder.exe file to avoid the error.
02/05/2012 (7:15 pm)
No Problem :)One word of caution though I forgot to mention. When creating the new build, you'll want to be sure to apply this change only to the TGBGame project within the solution explorer. If this change is applied to the TorqueGameBuilder project the editor won't start and comes up with an error when you try to launch it.
This can be done by right clicking the TGBGame project in the solution explorer and choosing "Project Only> Build Only TGBGame"
You'll have to remember to uncomment the lines if you at some point after that need to build the TorqueGameBuilder.exe file to avoid the error.
#8
Further investingations though led me to examine the contents of the $pref::video::resolution variable before the line:
if (!createCanvas(%windowName))
in canvas.cs This is the line that starts the initial canvas and passes it off to the engine to handle loading the display device etc.
I had the log report the value of $pref::video::resolution just before createCanvas is called and discovered it was empty.
Following the course createCanvas takes through the source I can see where it tries to get the value of $pref::video::resolution to use in setting up the display device. When it can't find anything it uses the default minimum resolution settings set elsewhere in the source. This is why it goes to a small res first.
I assumed it was suppose to pass in the user defined $game::resolution (set in properties.cs) to $pref::video::resolution at some point before createCanvas is called so I added the line:
$pref::Video::resolution = $Game::Resolution;
before createCanvas is called. checking the log I can see that the correct resolution gets used when setting up the display device now and it doesn't switch to low res first anymore going straight into fullscreen with the correct resolution. This should fix the problem.
02/15/2012 (12:50 am)
Another update on this, although the game starts perfectly going smoothly right into fullscreen after commenting out the mentioned lines above, I've discovered it causes an ALT-Tab crash so it isn't the optimal solution I had hoped for.Further investingations though led me to examine the contents of the $pref::video::resolution variable before the line:
if (!createCanvas(%windowName))
in canvas.cs This is the line that starts the initial canvas and passes it off to the engine to handle loading the display device etc.
I had the log report the value of $pref::video::resolution just before createCanvas is called and discovered it was empty.
Following the course createCanvas takes through the source I can see where it tries to get the value of $pref::video::resolution to use in setting up the display device. When it can't find anything it uses the default minimum resolution settings set elsewhere in the source. This is why it goes to a small res first.
I assumed it was suppose to pass in the user defined $game::resolution (set in properties.cs) to $pref::video::resolution at some point before createCanvas is called so I added the line:
$pref::Video::resolution = $Game::Resolution;
before createCanvas is called. checking the log I can see that the correct resolution gets used when setting up the display device now and it doesn't switch to low res first anymore going straight into fullscreen with the correct resolution. This should fix the problem.
#9
02/15/2012 (4:44 am)
Thanks for the research :) I was thinking of trying to dig into this since it is kind of annoying that it always starts with a weird default size.
#10
02/15/2012 (7:36 am)
no prob, It was bugging me as well :) It always seemed like a clunky way for the program to startup.
#11
I dug up createCanvas in the C++ code (whic is in guiCanvas.cs), and found the line:
Platform::initWindow(Point2I(MIN_RESOLUTION_X, MIN_RESOLUTION_Y), argv[1]);
These two values are defaults from platformWin23/platformGL.h... and can be changed to force the very, very first screen to come up at a bigger size. It's noted as being defaulted as 320X320 for use on phone screens.
02/15/2012 (8:48 pm)
I actually ended up looking into this a bit more myself. I noticed on slower computers, that it still pops up with a tiny window for a half-second or so before going to the correct size. It seemed to be at the same point in canvas.cs, even though $pref::Video::resolution had proper values. I dug up createCanvas in the C++ code (whic is in guiCanvas.cs), and found the line:
Platform::initWindow(Point2I(MIN_RESOLUTION_X, MIN_RESOLUTION_Y), argv[1]);
These two values are defaults from platformWin23/platformGL.h... and can be changed to force the very, very first screen to come up at a bigger size. It's noted as being defaulted as 320X320 for use on phone screens.
#12
In common/gamescripts/options.cs and in common/gamescripts/canvas.cs there are lines calling setScreenMode - this is why you go full-window-full - besides the one you added, screenmode is changed twice.
On options.cs the last parameter is a variable (%newFullScreen) and on canvas.cs the last parameter is false.
remove the false and make it $Game::FullScreen on the canvas.cs - that way it will use whatever you set in commonConfig.xml.
as for the one in common/gamescripts/options.cs, i'm not sure where %newFullScreen is set but in defaultPrefs.cs look for $pref::Video::fullScreen = 0; and make the 0 a 1 - then replace %newFullScreen with $pref::Video::fullScreen - but this step is not required as the value in commonConfig.xml will be the one that stays.
Don't forget to remove what you added
02/16/2012 (3:58 am)
if you check this thread, you will see i went through the same problem as you - here's my solution, that starts cleanly in full never showing window mode:In common/gamescripts/options.cs and in common/gamescripts/canvas.cs there are lines calling setScreenMode - this is why you go full-window-full - besides the one you added, screenmode is changed twice.
On options.cs the last parameter is a variable (%newFullScreen) and on canvas.cs the last parameter is false.
remove the false and make it $Game::FullScreen on the canvas.cs - that way it will use whatever you set in commonConfig.xml.
as for the one in common/gamescripts/options.cs, i'm not sure where %newFullScreen is set but in defaultPrefs.cs look for $pref::Video::fullScreen = 0; and make the 0 a 1 - then replace %newFullScreen with $pref::Video::fullScreen - but this step is not required as the value in commonConfig.xml will be the one that stays.
Don't forget to remove what you added
#13
$pref::Video::fullScreen = %xml.readField( "FullScreen" );
$Game::FullScreen = $pref::Video::fullScreen;
Try this if you are having problems not getting any fullscreen at all.
05/06/2014 (6:33 pm)
One thing to add, I found that to properly work with fullscreen mode, I had to set two variables:$pref::Video::fullScreen = %xml.readField( "FullScreen" );
$Game::FullScreen = $pref::Video::fullScreen;
Try this if you are having problems not getting any fullscreen at all.
#14
05/07/2014 (8:00 am)
Thanks for the contribution Jeff. Something worth nothing, though, is that this is a pretty old post. Because the content of this necro actually contains a solution, we can let it slide. Be sure to check the date next time. It might be worth you creating a new thread with the solution so it's at the top of someone's search.
Associate William Lee Sims
Machine Code Games
Inside common/gameScripts/canvas.cs, there is a function called initializeCanvas. I put this right before the "$canvasCreated = true;" line:
if( $pref::Video::fullScreen ) { %goodres = $pref::Video::Resolution; setScreenMode( GetWord( %goodres, 0), GetWord( %goodres,1), GetWord( %goodres,2), true ); } else { %goodres = $pref::Video::windowedRes; setScreenMode( GetWord( %goodres, 0), GetWord( %goodres,1), GetWord( %goodres,2), false ); }You probably just want the fullscreen version only.
I'll warn you, it starts up with a little screen first and then changes to full screen. But I don't get the full-small-full flicker anymore!
If somebody else has a clean way for the game to come up as a fullscreen window immediately, I'd love to learn it, too.