Archived

This topic is now archived and is closed to further replies.

necreia

DirectX + MFC 'auto filter'

Recommended Posts

Well I am working on a level editor, and the DX 8.1 + MFC combination went flawlessly. Now it is a 4 pane window and 1 window is a DX (while the other are tree and two rich text). The problem I am comming into is the game is 2D, so I am using Surfaces and going that method. Now the issue is.. when I resize the window the surface does too.. for example if I init() it with a 300x200 window to begin with, that''s how big the surface is... however I can''t seem to either 1) resize the back buffer on a WM_SIZE or 2) make a larger off-screen buffer and just present a rect from it the size of the window. I also don''t like how it ''blends'' when you resize the window to make it look ''clean''. Anyone have any idea''s?

Share this post


Link to post
Share on other sites
I found this in Direct3D examples and it seems to work for me:


RECT rcClientOld = m_rcWindowClient;

if( m_pd3dDevice != NULL && GetSafeHwnd() != NULL )
{
GetClientRect( &m_rcWindowClient );
if( rcClientOld.right - rcClientOld.left !=
m_rcWindowClient.right - m_rcWindowClient.left ||
rcClientOld.bottom - rcClientOld.top !=
m_rcWindowClient.bottom - m_rcWindowClient.top)
{
// If client is too small, don''t try to Reset until it gets bigger
if( m_rcWindowClient.right - m_rcWindowClient.left > 4 &&
m_rcWindowClient.bottom - m_rcWindowClient.top > 4 )
{
// A new window size will require a new backbuffer
// size, so the 3D structures must be changed accordingly.
Pause( true );
m_d3dpp.BackBufferWidth = m_rcWindowClient.right -
m_rcWindowClient.left;
m_d3dpp.BackBufferHeight = m_rcWindowClient.bottom -
m_rcWindowClient.top;

// Reset the 3D environment
if( FAILED( Reset3DEnvironment() ) )
{
DisplayErrorMsg( D3DAPPERR_RESETFAILED,
MSGERR_APPMUSTEXIT );
}
Pause( false );
Invalidate(FALSE);
}
}
}

do this when the window resizes

Share this post


Link to post
Share on other sites