DirectX9 2Dgame - Fullscreen/Window switching problem

Started by
2 comments, last by eldhose 16 years, 8 months ago
Hi, I am facing a problem with switching my DirectX9 2D game from Fullscreen to Windowed mode. By switching my app is changed to windowed mode but my desktop resolution won't change. That causes my window to display in fullscreen itself. Finaly I guess, I can solve this issue by adjusting the desktop resolution without destroying the window. How can I solve this? Any suggestion is really appreciable, Thanks in advance Eldhose Mathew
Advertisement
How are you switching to fullscreen?

You should be calling IDirect3DDevice9::Reset() with new D3DPRESENT_PARAMETERS with the new resolution, mode and the Windowed member set to FALSE.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Thanks for the suggestion, Let me try it

I am currently using the following code to switch between window/fullscreen modes. This code is writtten before the CreateDevice function


if( bWindowed == TRUE )
{

d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;


}
else
{
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.BackBufferFormat = d3ddm.Format;//D3DFMT_X8R8G8B8;

}

Thanks again for your advice,

regards,
Eldhose
Following is my current function to switch between windowed mode and fullscreen. But my computer gets hangs on this. Please help me find out the error with this code.

Thanks you very much,
Eldhose

//-----------------------------------------------------------------------------
// Name: SwitchWindowMode()
// Desc: Switch between window modes
//-----------------------------------------------------------------------------
void DX9_APP::SwitchWindowMode()
{
m_bWindowed = !m_bWindowed;

D3DDISPLAYMODE d3ddm;
m_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );

if( m_bWindowed == TRUE )
{
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
}
else
{
d3dpp.Windowed = FALSE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferWidth = SCREEN_WIDTH;
d3dpp.BackBufferHeight = SCREEN_HEIGHT;
d3dpp.BackBufferFormat = d3ddm.Format;//D3DFMT_X8R8G8B8;
}

d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Do NOT sync to vertical retrace
//d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT; // Sync to vertical retrace
d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;


/********** I HAVE TRIED Reset() here, but its causes my computer to hang *************/
//m_pd3dDevice->Reset(&d3dpp);

}

This topic is closed to new replies.

Advertisement