[1.10] Alt tab not working in fullscreen. [SOLVED] Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

[1.10] Alt tab not working in fullscreen. [SOLVED]

Post by mkultra333 »

Alt tab works fine when in windowed mode.

But in fullscreen mode, I get varied and unreliable results, and it never works completely properly.

Most typical situation is that I get a large black region on the desktop the same size as my game screen. It's always on top, the mouse, desktop and other programs are obscured by it.
Image

Any ideas on how I can fix this?

My mainloop message pump code looks like this:

Code: Select all

	while(!m_bShutdown && !OgreFramework::getSingletonPtr()->isOgreToBeShutDown()) 
	{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
			Ogre::WindowEventUtilities::messagePump() ;
#endif	
		// update ogre
		if(OgreFramework::getSingletonPtr()->m_pRenderWnd->isActive()) 
		{		
			if(bActive==false)
			{
				while(ShowCursor(false)>0); // if coming back to the program, sometimes have the desktop cursor, get rid of it.
				OgreFramework::getSingletonPtr()->m_pRoot->clearEventTimes() ;
				bActive=true ;
			}		
			OgreFramework::getSingletonPtr()->updateOgreB(); // update graphics, sound and physics	
			if(OgreFramework::getSingletonPtr()->m_pRenderWnd->isClosed()) m_bShutdown = true;	
		}
		else
		{
			bActive=false ;
			Sleep(10);	
		}
	}
Last edited by mkultra333 on Tue Feb 20, 2018 5:19 am, edited 1 time in total.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10] Alt tab not working in fullscreen.

Post by paroj »

what are you using for windowing/ input?
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: [1.10] Alt tab not working in fullscreen.

Post by mkultra333 »

I'm on Windows 7, game windows are just standard Ogre 1.10 stuff. OIS for input.

I have a customized loop for drawing my frames, so I go through control each surface as I render, don't know if that matters. In other words, I'm not using RenderOneFrame or whatever it's called.

I've tried various things like trying to position my app offscreen or resizing the render window to 1 pixel, when not active, but they made no difference.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: [1.10] Alt tab not working in fullscreen.

Post by mkultra333 »

Also, this is DX11.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10] Alt tab not working in fullscreen.

Post by paroj »

did it work with Ogre 1.9? Does it also happen with DX9?

Windowing on Windows is not my field, so I would suggest just not to use the Ogre windowing code, but rather SDL2, as the Sample Browser does.
But lets see if Eugene can help.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: [1.10] Alt tab not working in fullscreen.

Post by mkultra333 »

Just did a test, DX9 works fine. Also, I'm not using the very latest 1.10, mines probably 6 months or so old.

I know zero about using SDL2. I wouldn't even know where to start.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.10] Alt tab not working in fullscreen.

Post by paroj »

without any real knowledge, I would guess this line is problematic:
https://github.com/OGRECave/ogre/blob/m ... w.cpp#L813
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: [1.10] Alt tab not working in fullscreen.

Post by mkultra333 »

I will look into that, thanks.
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
User avatar
mkultra333
Gold Sponsor
Gold Sponsor
Posts: 1894
Joined: Sun Mar 08, 2009 5:25 am
x 114

Re: [1.10] Alt tab not working in fullscreen.

Post by mkultra333 »

Did some experiments that indicated WS_EX_TOPMOST is the culprit, like you suggested.

After a lot of experiments, found a simple fix. If in fullscreen and DX11, I minimize the window when it goes from active to not active. So far it seems to work fine.

Thanks for the help.

Code: Select all

	// this is to get the hWnd and bools for fullscreen and DX11

	HWND HWnd=0 ;
	OgreFramework::getSingletonPtr()->m_pRenderWnd->getCustomAttribute("WINDOW", &HWnd) ;
	bool bIsFullscreen=OgreFramework::getSingletonPtr()->m_pRenderWnd->isFullScreen() ;
	bool bIsDX11=false ;
	if(OgreFramework::getSingletonPtr()->m_pRoot->getRenderSystem()->getName().compare("Direct3D11 Rendering Subsystem") == 0)
		bIsDX11=true ;

// skipped some code here, see first post if you need it.

else
		{
			if(bActive)
			{
				if(bIsFullscreen && bIsDX11)  ShowWindow( HWnd, SW_MINIMIZE );
				OgreFramework::getSingletonPtr()->StopAllSounds() ;
				bActive=false ;
			}
			Sleep(10);	
		}
"In theory there is no difference between practice and theory. In practice, there is." - Psychology Textbook.
Post Reply