Window sizing stretches mesh

Started by
3 comments, last by QuadMV 18 years, 9 months ago
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,
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.

Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
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.
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.
Hack my projects! Oh Yeah! Use an SVN client to check them out.BlockStacker
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.

3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.

This topic is closed to new replies.

Advertisement