void RAS_FramingManager:: ComputeViewport( const RAS_FrameSettings &settings, const RAS_Rect &availableViewport, RAS_Rect &viewport ){ RAS_FrameSettings::RAS_FrameType type = settings.FrameType(); const int winx = availableViewport.GetWidth(); const int winy = availableViewport.GetHeight(); const float design_width = float(settings.DesignAspectWidth()); const float design_height = float(settings.DesignAspectHeight()); float design_aspect_ratio = float(1); if (design_height == float(0)) { // well this is ill defined // lets just scale the thing type = RAS_FrameSettings::e_frame_scale; } else { design_aspect_ratio = design_width/design_height; } switch (type) { case RAS_FrameSettings::e_frame_scale : case RAS_FrameSettings::e_frame_extend: { viewport.SetLeft(availableViewport.GetLeft()); viewport.SetBottom(availableViewport.GetBottom()); viewport.SetRight(availableViewport.GetLeft() + int(winx)); viewport.SetTop(availableViewport.GetBottom() + int(winy)); break; } case RAS_FrameSettings::e_frame_bars: { ComputeBestFitViewRect( availableViewport, design_aspect_ratio, viewport ); break; } default : break; } }
void RAS_FramingManager:: ComputeOrtho( const RAS_FrameSettings &settings, const RAS_Rect &availableViewport, const RAS_Rect &viewport, const float scale, const float camnear, const float camfar, RAS_FrameFrustum &frustum ) { RAS_FrameSettings::RAS_FrameType type = settings.FrameType(); const float design_width = float(settings.DesignAspectWidth()); const float design_height = float(settings.DesignAspectHeight()); float design_aspect_ratio = float(1); if (design_height == float(0)) { // well this is ill defined // lets just scale the thing type = RAS_FrameSettings::e_frame_scale; } else { design_aspect_ratio = design_width/design_height; } ComputeDefaultOrtho( camnear, camfar, scale, design_aspect_ratio, frustum ); switch (type) { case RAS_FrameSettings::e_frame_extend: { RAS_Rect vt; ComputeBestFitViewRect( availableViewport, design_aspect_ratio, vt ); // now scale the calculated frustum by the difference // between vt and the viewport in each axis. // These are always > 1 float x_scale = float(viewport.GetWidth())/float(vt.GetWidth()); float y_scale = float(viewport.GetHeight())/float(vt.GetHeight()); frustum.x1 *= x_scale; frustum.x2 *= x_scale; frustum.y1 *= y_scale; frustum.y2 *= y_scale; break; } case RAS_FrameSettings::e_frame_scale : case RAS_FrameSettings::e_frame_bars: default : break; } }