Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualBuckeye

Posted 22 February 2014 - 09:04 AM


without manually setting them, my aspect ratio will be hard to estimate

As long as the backbuffer width/height is larger than the child window's client width/height you'll be fine. Just don't render to the entire backbuffer.

 

They are a couple approaches but the simplest would be:

Get the child's client rect.

 

RECT cRect;

GetClientRect(hChildWnd,&cRect);

 

Set the viewport to the child's rect size. // sets the portion of the backbuffer to render to.

 

Set the view to whatever you want.

 

Set the projection with the aspect ratio of the child. aspect = (float)cRect.width/(float)cRect.height.

 

Draw the scene

 

device->Present( &cRect, &cRect, hChildWnd, 0 ); // present the cRect area of the backbuffer to the cRect area of the child window

 

EDIT: Yes, setting the viewport properly is the key.


#4Buckeye

Posted 22 February 2014 - 09:01 AM


without manually setting them, my aspect ratio will be hard to estimate

As long as the backbuffer width/height is larger than the child window's client width/height you'll be fine. Just don't render to the entire backbuffer.

 

They are a couple approaches but the simplest would be:

Get the child's client rect.

 

RECT cRect;

GetClientRect(hChildWnd,&cRect);

 

Set the viewport to the child's rect size. // sets the portion of the backbuffer to render to.

 

Set the view to whatever you want.

 

Set the projection with the aspect ratio of the child. aspect = (float)cRect.width/(float)cRect.height.

 

Draw the scene

 

device->Present( &cRect, &cRect, hChildWnd, 0 ); // present the cRect area of the backbuffer to the cRect area of the child window


#3Buckeye

Posted 22 February 2014 - 09:00 AM


without manually setting them, my aspect ratio will be hard to estimate

As long as the backbuffer width/height is larger than the child window's client width/height you'll be fine.

 

They are a couple approaches but the simplest would be:

Get the child's client rect.

 

RECT cRect;

GetClientRect(hChildWnd,&cRect);

 

Set the viewport to the child's rect size. // sets the portion of the backbuffer to render to.

 

Set the view to whatever you want.

 

Set the projection with the aspect ratio of the child. aspect = (float)cRect.width/(float)cRect.height.

 

Draw the scene

 

device->Present( &cRect, &cRect, hChildWnd, 0 ); // present the cRect area of the backbuffer to the cRect area of the child window


#2Buckeye

Posted 22 February 2014 - 08:59 AM


without manually setting them, my aspect ratio will be hard to estimate

As long as the backbuffer width/height is larger than the child window's client width/height you'll be fine.

 

They are a couple approaches but the simplest would be:

Get the child's client rect.

 

RECT cRect;

GetClientRect(hChildWnd,&cRect);

 

Set the viewport to the child's rect size.

 

Set the view to whatever you want.

 

Set the projection with the aspect ratio of the child. aspect = (float)cRect.width/(float)cRect.height.

 

Draw the scene

 

device->Present( &cRect, &cRect, hChildWnd, 0 );


#1Buckeye

Posted 22 February 2014 - 08:58 AM


without manually setting them, my aspect ratio will be hard to estimate

As long as the backbuffer width/height is larger than the child window's client width/height you'll be fine.

 

They are a couple approaches but the simplest would be:

Get the child's client rect.

 

RECT cRect;

GetClientRect(hChildWnd,&cRect.

 

Set the viewport to the child's rect size.

 

Set the view to whatever you want.

 

Set the projection with the aspect ratio of the child. aspect = (float)cRect.width/(float)cRect.height.

 

Draw the scene

 

device->Present( &cRect, &cRect, hChildWnd, 0 );


PARTNERS