Sign in to follow this  

Window sizing stretches mesh

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

Does anybody know how to get the mesh to render correctly after the window has been resized? So you load a .x file, in a Windowed style; and when you resize the window the object will be stretched (it should re-render it self so that it is correctly proportionally rendered). Thank you very much,

Share this post


Link to post
Share on other sites
Call IDirect3DDevice9::Reset( ) when processing WM_SIZE in your window procedure. Specify 0 for both BackBufferWidth and BackBufferHeight in the D3DPRESENT_PARAMETERS structure. This will cause Reset( ) to use the window's client area.

Note that every time the device is reset it's swap chain is destroyed and created anew, which will slow down your app if done often.

Also note that you may have to take a look at your scene transformations and make sure they work when the resolution of the device is altered.

Stay sharp.

Share this post


Link to post
Share on other sites
Also note that all the resources loaded without the D3DPOOL_MANAGED flag will be lost.
according to the SDK docs it is also recomended that you first release any resources created with the D3DPOOL_DEFAULT flag before reseting the device.
After reseting the device, resources loaded without the D3DPOOL_MANAGED need to be reloaded as these have been lost during the reset.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kamikaze15
Also note that all the resources loaded without the D3DPOOL_MANAGED flag will be lost.
according to the SDK docs it is also recomended that you first release any resources created with the D3DPOOL_DEFAULT flag before reseting the device.
After reseting the device, resources loaded without the D3DPOOL_MANAGED need to be reloaded as these have been lost during the reset.


Yes, exactly. Thanks for the note, Kamikaze15. Should have mentioned that.

Share this post


Link to post
Share on other sites
You probably will need to reset your projection matrix when resizing the window. If you use the sample framework you'll see the reset method gets called which is then calculating the field of view using something like this:

float fAspect = pBackBufferSurfaceDesc->Width / (FLOAT)pBackBufferSurfaceDesc->Height;
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, gHOWCLOSE, gHOWFAR );
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );


If you don't have this running after a window resize, things wont look right.

Share this post


Link to post
Share on other sites

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