Jump to content
  • Advertisement
Sign in to follow this  
eldhose

DirectX9 2Dgame - Fullscreen/Window switching problem

This topic is 3985 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, 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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!