Game Development Community

Window not resizing properly on fullscreen toggle

by Skylar Kelty · in Torque Game Engine Advanced · 11/24/2007 (7:03 am) · 3 replies

When I go into fullscreen, and then back again, the window looks like this:
image

If I click apply once more, it fixes it all.

Any ideas?

Thanks
--James

#1
11/24/2007 (7:48 am)
And here I was thinking that was something *I'd* screwed up recently... what version of tgea is that?
#2
11/24/2007 (9:06 am)
1.0.3
I've made a hack fix until someone can post the solution? *hopes*

function optionsDlg::applyGraphics( %this )
{
	%newDriver = OptGraphicsDriverMenu.getText();
	%newRes = OptGraphicsResolutionMenu.getText();
	%newBpp = OptGraphicsBPPMenu.getText();
	%newFullScreen = OptGraphicsFullscreenToggle.getValue();
	$pref::Video::screenShotFormat = OptScreenshotMenu.getText();

	if(isFullScreen() && (%newFullScreen == 0))
		%resetAll = true;
	else
		%resetAll = false;
	
   setVideoMode( firstWord( %newRes ), getWord( %newRes, 1 ), %newBpp, %newFullScreen );
	
	if(%resetAll)
	{
  		setVideoMode( firstWord( %newRes ), getWord( %newRes, 1 ), %newBpp, false );
	}
}

As you can see, it calls setVideoMode twice if its going from full screen too windowed.
#3
11/24/2007 (9:43 am)
The proper fix is something like this:

void GFXD3DDevice::setVideoMode( const GFXVideoMode &mode, bool updatePlatformWindow )
{
   if(updatePlatformWindow && mode.fullScreen)
        Platform::setWindowSize( mode.resolution.x, mode.resolution.y, mode.fullScreen );

   // set this before the reset - some modules like the GlowBuffer need to 
   // resize screen buffers to the new video mode ( during reset() )
   mVideoMode = mode;

   D3DPRESENT_PARAMETERS d3dpp = setupPresentParams( mode );
   reset( d3dpp );

   if(updatePlatformWindow && !mVideoMode.fullScreen)
        Platform::setWindowSize( mVideoMode.resolution.x, mVideoMode.resolution.y, mVideoMode.fullScreen );
   
   // Setup default states
   initStates();

   GFX->updateStates(true);
}