Jump to content
  • Advertisement
Sign in to follow this  
calidev234

Window sizing stretches mesh

This topic is 4768 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!