Skip to main content
GameDev.net gamedev.net
🔒 Locked

Aspect Ratio

Started by TheSLASH Apr 21, 2006 at 6:57 AM 1 replies 650+ views
Original Post
TheSLASH
TheSLASH
I have problem when I try to resize the window, the aspect ratio of the drawn content i wrong, it is streched. I do use a sprite (LPD3DXSPRITE) for the content, and some text (LPD3DXFONT), all in the window get's wrong aspect ratio. Here is the resize fuction: void ResizeScene(int width, int height) { D3DXMATRIXA16 matProjection; D3DXMatrixPerspectiveFovLH( &matProjection, 45.0f, (float)width/(float)height, 0.1f, 100.0f ); gpDevice->SetTransform( D3DTS_PROJECTION, &matProjection ); } I have used it from both WM_SIZE and WM_SIZING without positive result, nothing happends... The setup is DirectX 9.0c, and SDK from summer 2003.
circlesoft
circlesoft
Do you actually reset the device, updating the D3DPRESENT_PARAMETERS with the new window dimensions? Not doing this will generally result in a stretched out display, which you described.

In general, what you want to do:

- Detect a resize
- Release all of your default pool objects, call OnDeviceLoss() on D3DX interfaces
- Update presentation parameters
- IDirect3DDevice9::Reset()
- Recreate all of your default pool object, call OnDeviceReset() on D3DX interfaces.
TheSLASH
TheSLASH
Thanx, it helped with the Lost and Reset functions.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.