Sign in to follow this  

Toggle full screen intermittent crash

This topic is 2573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

So I got my toggle full screen working and from what I could tell it was working just fine. A few days later after doing a lot of other work no my game engine it sorta does not work.

First off the problem is not going to full screen at all. Its coming back to windowed. I only have the problem when my laptop is NOT connected to my monitor. I do not have a clue why it works when using duel screens and does not work when I am solely using the laptop monitor.

here is the function for my toggle full screen.

void CBase::ToggleFullscreen()
{
if ( c_pGraphics == NULL)
{
return;
}
c_pGraphics->Windowed=!c_pGraphics->Windowed;

if(c_pGraphics->Windowed)
{
SetWindowLongPtr(hWindowHandle,GWL_STYLE,WS_OVERLAPPEDWINDOW);
}
else
{
//save current location/size
ZeroMemory(&m_wp,sizeof(WINDOWPLACEMENT));
m_wp.length=sizeof(WINDOWPLACEMENT);
GetWindowPlacement(hWindowHandle,&m_wp);

//go to fullscreen
SetWindowLongPtr(hWindowHandle,GWL_STYLE,WS_EX_TOPMOST);

ShowWindow(hWindowHandle,SW_HIDE);
}
//reset the device
c_pGraphics->ResetGraphics();
if(c_pGraphics->Windowed)
{
SetWindowPlacement(hWindowHandle,&m_wp);
}
if (!IsWindowVisible(hWindowHandle))
{
ShowWindow(hWindowHandle,SW_SHOW);
}

}



Here is the code I use to rebuld my presentation paramates and reset the device.



bool CGraphics::BuildPresentParameters()
{
ZeroMemory( &d3dParam, sizeof(d3dParam) );
d3dParam.BackBufferWidth = (Windowed) ? 0: g_displayMode.Width;
d3dParam.BackBufferHeight = (Windowed) ? 0: g_displayMode.Height;
d3dParam.BackBufferFormat = fmtBackBuffer;
d3dParam.BackBufferCount = 1;
d3dParam.MultiSampleType = D3DMULTISAMPLE_NONE;
d3dParam.MultiSampleQuality = 0;
d3dParam.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dParam.hDeviceWindow = m_hWnd;
d3dParam.Windowed = Windowed;
d3dParam.AutoDepthStencilFormat = fmtDepthSelected;
d3dParam.FullScreen_RefreshRateInHz =(Windowed) ? 0 : g_displayMode.RefreshRate;
d3dParam.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
return true;
}

bool CGraphics::ResetGraphics()
{
if ( p3DDevice )
{
if ( !BuildPresentParameters() )
{
return FALSE;
}
p3DDevice->Reset( &d3dParam );
}

return TRUE;
}




When I go from full screen to windowed it does rebuild the presentation paramaters and then calls the device reset. When that happens it breaks at the "ZeroMemory(..." line of my build presentation function.

Thanks for any help you may have. I have spent hours trying to get this fixed.

Share this post


Link to post
Share on other sites
I check for acceptable display mode when I initialize the program but not when I go back and forth from full screen to windowed or vise versa. Should this be something I am doing? I did not think it would matter coming from full screen to windowed as your more or less just setting the size of the window?

Here is my debug runtime. Sorry I always forget to check this.



'new.exe': Loaded 'F:\My Documents\Visual Studio 2010\Projects\new\Debug\new.exe', Symbols loaded.
'new.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\D3dx9d_43.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\d3d9.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\version.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\d3d8thk.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'new.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\BtMmHook.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\cryptbase.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\clbcatq.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\d3d9d.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
Direct3D9: :====> ENTER: DLLMAIN(5ca9d9a0): Process Attach: 00002780, tid=00002590
Direct3D9: :====> EXIT: DLLMAIN(5ca9d9a0): Process Attach: 00002780
Direct3D9: (INFO) :Direct3D9 Debug Runtime selected.
'new.exe': Loaded 'C:\Windows\System32\nvd3dum.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\powrprof.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\setupapi.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll', Cannot find or open the PDB file
'new.exe': Loaded 'C:\Windows\System32\devobj.dll', Cannot find or open the PDB file
Direct3D9: (INFO) :======================= Hal HWVP device selected

Direct3D9: (INFO) :HalDevice Driver Style b

Direct3D9: :DoneExclusiveMode
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

Direct3D9: (INFO) :Enabling multi-processor optimizations
Direct3D9: (INFO) :DDI threading started

D3DX: (INFO) Using AMD optimizations
Direct3D9: (WARN) :Ignoring redundant SetRenderState - 9

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137

Direct3D9: (INFO) :DDI threading stopped

Direct3D9: :Subclassing window 019605cc
Direct3D9: :StartExclusiveMode
Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: :Window 00080bfc is on top of us!!
Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: :Window 00080bfc is on top of us!!
Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

Direct3D9: (INFO) :DDI threading started

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 9

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137

Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: :Window 00010060 is on top of us!!
Direct3D9: :Window 0001005a is on top of us!!
Direct3D9: :Window 000c03e2 is on top of us!!
Direct3D9: :Window 007804cc is on top of us!!
Direct3D9: :Window 000100ea is on top of us!!
Direct3D9: (ERROR) :Lost due to display uniqueness change
new.exe has triggered a breakpoint




I am not sure why it can't find the PDB file, is this important? :)

I think maybe the errors "window .... is on top of us!!" is happening because of me ctrl+alt+del in order to see the IDE.

Thanks for the help.

Share this post


Link to post
Share on other sites
When setting WS_EX_TOPMOST you need to use GWL_EXstyle, as it is an extended style and not a normal window-style (a window has both, and they are separate). Also, you don't actually need to change the window style at all, as Reset will do it for you.
It's usually easier to do it something like this:

if(going to fullscreen) {
GetWindowPlacement(...);
pp = FullscreenPresentParams();
}
else {
SetWindowPlacement(...);
pp = WindowedPresentParams();
}
device->Reset(&pp);


Share this post


Link to post
Share on other sites
Quote:
Sorry I always forget to check this.

That should be the first thing to check. You'll save yourself hours of debugging time.

WRT the PDB file, I got 70,000 hits by googling "Cannot find or open the PDB file." Your program is just trying to find debug symbols for DLLs it's loading.

WRT to the "uniqueness change," I got 394,000 hits googling "Lost due to display uniqueness change."

The first hit was here on gamedev (which can be searched using the search box in the upper right-hand corner of this page). That post states: "The issue disappears when using Direct3D 9 Extensions for Vista (IDirect3DDevice9Ex), but at the expense of backward compatibility with XP."

Is that applicable?

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Quote:
Sorry I always forget to check this.

That should be the first thing to check. You'll save yourself hours of debugging time.

WRT the PDB file, I got 70,000 hits by googling "Cannot find or open the PDB file." Your program is just trying to find debug symbols for DLLs it's loading.

WRT to the "uniqueness change," I got 394,000 hits googling "Lost due to display uniqueness change."

The first hit was here on gamedev (which can be searched using the search box in the upper right-hand corner of this page). That post states: "The issue disappears when using Direct3D 9 Extensions for Vista (IDirect3DDevice9Ex), but at the expense of backward compatibility with XP."

Is that applicable?



I am sorry, please excuse my ignorance. I do try my best in solving the problems myself. However I thought this was a bit of a strange situation to work in dual displays and not with a single monitor.

For some reason it is now working. I noticed the tutorial I was following was also doing the same thing so I restarted my computer. Both programs are now working again. The only thing I am getting in my debug runtime now is regarding the pdb files and the following.



Direct3D9: :Subclassing window 0004068e
Direct3D9: :StartExclusiveMode
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

Direct3D9: (INFO) :DDI threading started

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 9

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137

Direct3D9: (INFO) :DDI threading stopped

Direct3D9: :DoneExclusiveMode
Direct3D9: :INACTIVE: 000009e4: Restoring original mode (1440x900x22x60) at adapter index 0
Direct3D9: :Unsubclassing window 0004068e
Direct3D9: (INFO) :Using FF to VS converter

Direct3D9: (INFO) :Using FF to PS converter

Direct3D9: (INFO) :DDI threading started

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 9

Direct3D9: (WARN) :Ignoring redundant SetRenderState - 137




The "Ignoring redundant.." from what I have read are from the program setting the render state more than once. Not sure how I have done this but should be able to figure this out easily enough.

I am not sure I understand that thread correctly. Is it saying that IDirect3DDevice9Ex works for vista but not xp?

Quote:
Original post by Erik Rufelt
When setting WS_EX_TOPMOST you need to use GWL_EXstyle, as it is an extended style and not a normal window-style (a window has both, and they are separate). Also, you don't actually need to change the window style at all, as Reset will do it for you.
It's usually easier to do it something like this:


I did not know that. Thanks for the tip. I also like the idea of having two different parameters for full screen and windowed.

Thank you both for your help once again.


Share this post


Link to post
Share on other sites
Quote:
that thread ... Is it saying that IDirect3DDevice9Ex works for vista but not xp?

I didn't see that. I understood that he set some parameters that prevented backward compatibility. Take a look at the docs for IDirect3DDevice9Ex. There is at least one parameter that mentions "for Windows Vista only."

With regard to the redundant render states, it's not saying it's being set more than once (well, sort of). It's being set when it's already set. That's just a bit different. E.g., you may turn blending on and off several times during a render cycle and not get that message, provided the new setting is different than the current. You can look at the docs for SetRenderState to interpret the states (the numbers given) that are being set redundantly. Then look at where those render states are set in your code. For some render states, it's quicker to do a dev->GetRenderState(...) and compare it to the value you want to set. If it's already set, don't set it. Or, bump down the warning level in the Dx control panel and ignore it.

Share this post


Link to post
Share on other sites

This topic is 2573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this