Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


#ActualBuckeye

Posted 05 June 2014 - 12:35 PM

As it appears that you're coding a windowed app, a better approach might be to size the backbuffer to the client area, rather than the other way 'round. Using a window means the user may move or resize the window for his/her own convenience, and you should respect that. So, when the window is resized:

RECT rect;
GetClientRect(hwnd, &rect);
params.BackBufferWidth = rect.right - rect.left;
params.BackBufferHeight = rect.bottom - rect.top;
OnDeviceLost(); // prepare objects for device reset
device->Reset( &params );
OnDeviceRestored(); // restore objects after the reset
ResetProjectionAspectRatio(); // account for change in the aspect ratio


Perhaps even better than setting the width/height yourself, unless you have some specific reason to size the backbuffer to a particular size, set the BackBufferWidth and BackBufferHeight to 0, and let D3DX set the buffer to the client area dimensions itself. You can do that when creating the device or when the window is resized (device reset). Just remember to check the aspect ratio of your projection matrix whenever the client/backbuffer is resized.


#3Buckeye

Posted 05 June 2014 - 12:35 PM

As it appears that you're coding a windowed app, a better approach might be to size the backbuffer to the client area, rather than the other way 'round. Using a window means the user may move or resize the window for his/her own convenience, and you should respect that. So, when the window is resized:

RECT rect;
GetClientRect(hwnd, &rect);
params.BackBufferWidth = rect.right - rect.left;
params.BackBufferHeight = rect.bottom - rect.top;
OnDeviceLost(); // prepare objects for device reset
device->Reset( &params );
OnDeviceRestored(); // restore objects after the reset
ResetProjectionAspectRatio(); // account for change in the aspect ratio

Perhaps even better than setting the width/height yourself, unless you have some specific reason to size the backbuffer to a particular size, set the BackBufferWidth and BackBufferHeight to 0, and let D3DX set the buffer to the client area dimensions itself. You can do that when creating the device or when the window is resized (device reset). Just remember to check the aspect ratio of your projection matrix whenever the client/backbuffer is resized.


#2Buckeye

Posted 05 June 2014 - 12:21 PM

As it appears that you're coding a windowed app, a better approach might be to size the backbuffer to the client area, rather than the other way 'round. Using a window means the user may move or resize the window for his/her own convenience, and you should respect that. So, when the window is resized:

RECT rect;
GetClientRect(hwnd, &rect);
params.BackBufferWidth = rect.right - rect.left;
params.BackBufferHeight = rect.bottom - rect.top;
OnDeviceLost(); // prepare objects for device reset
device->Reset( &params );
OnDeviceRestored(); // restore objects after the reset
ResetProjectionAspectRatio(); // account for change in the aspect ratio

#1Buckeye

Posted 05 June 2014 - 12:20 PM

As it appears that you're coding a windowed app, a better approach might be to size the backbuffer to the client area, rather than the other way 'round. Using a window means the user may move or resize the window for his/her own convenience, and you should respect that. So, when the window is resized:

RECT rect;
GetClientRect(hwnd, &rect);
params.BackBufferWidth = rect.right - rect.left;
params.BackBufferHeight = rect.bottom - rect.top;
OnDeviceLost(); // prepare objects for device reset
device->Reset( &params );
OnDeviceRestored(); // restore objects after the reset

PARTNERS