Resizing a DirectX application

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

Recommended Posts

my question has to do with both windowed and full screen application... in most games you can change your resolution and such durring play. 1.Do you just call d3dDevice->Reset(presentParam) where the presentation params have the option you want? 2.do you have to tell windows you are changing the size?.. 3.when switching from full screen to window or vice-versa how do you tell windows, do you just kill your current window and recreate it?

Share on other sites
1. If you are not fullscreen this will work. Otherwise, you have to release any textures (and possibly meshes) that you have, resize, then re-create all textures (and/or meshes).

2. If fullscreen, you shouldn't have to, but it might be good practice to. If windowed, Windows will usually tell you that your window resized (WM_SIZE message).

3. You don't have to kill the window itself. Refer to answer 1 as it's the same situation.

Share on other sites
Quote:
 Original post by MTclipmy question has to do with both windowed and full screen application...in most games you can change your resolution and such durring play. 1.Do you just call d3dDevice->Reset(presentParam) where the presentation params have the option you want?

Yes. Along with the other things you need to do when you Reset() such as releasing all resources in the default pool and re-creating them after the reset, calling the OnReset() method of D3DX objects which require it, and not assuming render states will be set to the same values they were at before the reset.

Quote:
 2.do you have to tell windows you are changing the size?..

Fullscreen, it's not strictly necessary (D3D hooks your window); windowed, you should change the size of the window.

Quote:
 3.when switching from full screen to window or vice-versa how do you tell windows, do you just kill your current window and recreate it?

You can use GetWindowLong() to retrieve the current window style, and then SetWindowLong() to restore it when you toggle between the two. Other than setting appropriate window styles (i.e. borders and title bar for windowed), and how you handle messages (i.e. things like disabling screensavers and non-client mouse clicks are ok in fullscreen, but less so in windowed mode where your primary focus should be "playing nice" with everything else that's running on the desktop), D3D will do the rest.

The sample framework that comes with the DirectX SDK does "the right thing" in all these cases and more (such as Fast User Switching in XP etc), so if you're ever in doubt about how to handle something, use that as reference.

bah, beaten by a whisker [wink][/edit]

Share on other sites
Im not doing something right..

I should say this, my app recovers from a lost device..

every time i try to resize the backbuffer ( in windowed mode ) it fails..
here is what should be the relevant code.. what else do i need to do.. the app has no resources I am just clearing the backbuffer and presenting...

 // here is where i catch  // the resize message case WM_EXITSIZEMOVE:	m_isBeeingSized = false;	OnChangeSettings();        return true;      // OnChangeSettings()void SFGraphics::OnChangeSettings(){		// find the width & height	if( m_windowed )	{		// determine the width and height of the window		RECT rc;		GetClientRect(m_hWnd,&rc);		m_width = rc.right - rc.left;		m_height = rc.bottom - rc.top;	}	else	{		}	// change the backbuffer size 	m_d3dpp.BackBufferWidth	= m_width;	m_d3dpp.BackBufferHeight = m_height;	// reset the device	HRESULT hr =  m_pDevice->Reset( &m_d3dpp );	 	// did it work?	if( hr == D3DERR_INVALIDCALL )	{		MessageBox( m_hWnd, " CRAP!!! ","ERROR", MB_OK );	}   }

<EDIT>:: well if I call my OnDeviceLost() it seems to work ;P

[Edited by - MTclip on March 11, 2006 11:29:54 PM]

• 18
• 11
• 20
• 9
• 52
• Forum Statistics

• Total Topics
631397
• Total Posts
2999812
×