Sign in to follow this  

Resizing display to window size

This topic is 4226 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 think this is quite a common problem but I couldn't find my exact problem answered via searching. I'm making an application which uses DirectX to draw 2D graphics to a window. However, when I resize the window DirectX does the usual stretch to window size as described by the docs in Present(). Instead, I want resizing the window to expose more or less of the backbuffer. How can I do this? I could either have a really large backbuffer and work out a way of exposing more or less of it, or I could use Reset() every time the window is resized. I'd rather not reset because all my textures would be lost; recreating them is potentially slow and seems overkill for a simple window resize. Also I'd like to show the window correctly during the user's drag and resetting every frame for that is surely a bad idea. Any help appreciated.

Share this post


Link to post
Share on other sites
Have a look at how the SDK samples do this. From what I can see (guessing here, I'm at work and don't have the SDK to hand), it just stretches the backbuffer in WM_SIZING, and Reset()s when the resize is complete.

Your best bet is probably doing the same.

Share this post


Link to post
Share on other sites
Look into the 4 parameters you supply to Present(). By setting the source RECT to be the size of the window, you'd be "selecting" only a portion of the backbuffer.

From what you explained, I understood this was what you wanted to do - only use a part of the backbuffer when presenting, depending on the window size...

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Have a look at how the SDK samples do this. From what I can see (guessing here, I'm at work and don't have the SDK to hand), it just stretches the backbuffer in WM_SIZING, and Reset()s when the resize is complete.

Your best bet is probably doing the same.


Do you mean doing something like this?


case WM_SIZING:
{
//Reset Direct3D device
D3DPRESENT_PARAMETERS pre_param;
ZeroMemory( &pre_param, sizeof(pre_param) );
pre_param.Windowed = TRUE;
pre_param.SwapEffect = D3DSWAPEFFECT_DISCARD;
pre_param.BackBufferFormat = D3DFMT_UNKNOWN;
pre_param.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
pre_param.EnableAutoDepthStencil= TRUE;
pre_param.AutoDepthStencilFormat = D3DFMT_D24S8;

HRESULT hr = s_d3d_device->Reset(&pre_param);
if( FAILED(hr) )
{
DXTRACE_ERR_MSGBOX(L"Failed to reset device",hr);
}

}



When I do this I get: D3DERR_INVALIDCALL.

Should I do something else in the code before calling Reset?

Share this post


Link to post
Share on other sites
Yes, you have to release anything that was created in the default pool.

Additional you should activate the debug runtime. It will give you more details when a call failed.

Share this post


Link to post
Share on other sites

This topic is 4226 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