1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_Viewport.h 4 5 Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain proprietary 8 information of Nintendo and/or its licensed developers and are protected by 9 national and international copyright laws. They may not be disclosed to third 10 parties or copied or duplicated in any form, in whole or in part, without the 11 prior written consent of Nintendo. 12 13 The content herein is highly confidential and should be handled accordingly. 14 15 $Revision: $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_GFX_VIEWPORT_H_ 19 #define NW_GFX_VIEWPORT_H_ 20 21 #include <nw/ut/ut_Rect.h> 22 #include <nw/gfx/gfx_IRenderTarget.h> 23 24 namespace nw 25 { 26 namespace gfx 27 { 28 29 30 //--------------------------------------------------------------------------- 31 //! @brief ビューポートを表すクラスです。 32 //--------------------------------------------------------------------------- 33 class Viewport 34 { 35 public: 36 //---------------------------------------- 37 //! @name コンストラクタ/デストラクタ 38 //@{ 39 40 //-------------------------------------------------------------------------- 41 //! @brief デフォルトコンストラクタです。 42 //--------------------------------------------------------------------------- Viewport()43 Viewport() 44 : m_DepthNear(0.f), 45 m_DepthFar(1.f) {} 46 47 //! @brief コンストラクタです。 48 //! 49 //! @param[in] x 設定するビューポートのX座標です。 50 //! @param[in] y 設定するビューポートのY座標です。 51 //! @param[in] width 設定するビューポートの幅サイズです。 52 //! @param[in] height 設定するビューポートの縦サイズです。 53 //! @param[in] near 設定するnear値です。 54 //! @param[in] far 設定するfar値です。 Viewport(float x,float y,float width,float height,float near,float far)55 Viewport( 56 float x, 57 float y, 58 float width, 59 float height, 60 float near, 61 float far ) 62 : m_Rect( x, y, x + width, y + height ), 63 m_DepthNear(near), 64 m_DepthFar(far) {} 65 66 //! @brief コンストラクタです。 67 //! 68 //! @param[in] rect 設定するビューポートの矩形です。 69 //! @param[in] near 設定するnear値です。 70 //! @param[in] far 設定するfar値です。 Viewport(ut::Rect rect,float near,float far)71 Viewport( 72 ut::Rect rect, 73 float near, 74 float far ) 75 : m_Rect( rect ), 76 m_DepthNear(near), 77 m_DepthFar(far) {} 78 79 //! @brief コンストラクタです。 80 //! 81 //! @param[in] renderTarget 設定するビューの矩形を保持する IRenderTarget です。 82 //! @param[in] near 設定するnear値です。 83 //! @param[in] far 設定するfar値です。 Viewport(IRenderTarget * renderTarget,float near,float far)84 Viewport( 85 IRenderTarget* renderTarget, 86 float near, 87 float far) 88 : m_DepthNear(near), 89 m_DepthFar(far) 90 { 91 NW_NULL_ASSERT(renderTarget); 92 93 f32 width = static_cast<f32>(renderTarget->GetDescription().width); 94 f32 height = static_cast<f32>(renderTarget->GetDescription().height); 95 96 m_Rect.SetOriginAndSize(0.f, 0.f, width, height); 97 } 98 99 //! コピーコンストラクタです。 Viewport(const Viewport & v)100 Viewport( const Viewport& v ) 101 : m_Rect(v.m_Rect), 102 m_DepthNear(v.m_DepthNear), 103 m_DepthFar(v.m_DepthFar) {} 104 105 //! デストラクタです。 ~Viewport()106 ~Viewport() {} 107 108 //---------------------------------------- 109 //! @name 取得/設定 110 //@{ 111 112 //! @brief 深度範囲を設定します。 113 //! 114 //! @param[in] near 設定するnear値です。 115 //! @param[in] far 設定するfar値です。 SetDepthRange(f32 near,f32 far)116 void SetDepthRange(f32 near, f32 far) 117 { 118 m_DepthNear = near; 119 m_DepthFar = far; 120 } 121 122 //! @brief ビューポートの矩形を設定します。 123 //! 124 //! @param[in] bound 設定するビューポートの矩形です。 SetBound(const ut::Rect & bound)125 void SetBound(const ut::Rect& bound) 126 { 127 m_Rect = bound; 128 } 129 130 //! @brief ビューの矩形を設定します。 131 //! 132 //! @param[in] x 設定するビューポートのX座標です。 133 //! @param[in] y 設定するビューポートのY座標です。 134 //! @param[in] width 設定するビューポートの幅サイズです。 135 //! @param[in] height 設定するビューポートの縦サイズです。 SetBound(float x,float y,float width,float height)136 void SetBound(float x, float y, float width, float height) 137 { 138 m_Rect.SetOriginAndSize( x, 139 y, 140 width, 141 height ); 142 } 143 144 //! @brief ビューの矩形を設定します。 145 //! 146 //! @param[in] renderTarget 設定するビューの矩形を保持するIRenderTargetです。 SetBound(IRenderTarget * renderTarget)147 void SetBound(IRenderTarget* renderTarget) 148 { 149 NW_NULL_ASSERT(renderTarget); 150 151 m_Rect.SetOriginAndSize( 0.f, 152 0.f, 153 static_cast<f32>(renderTarget->GetDescription().width), 154 static_cast<f32>(renderTarget->GetDescription().height) ); 155 } 156 157 //! @brief ビューの矩形を取得します。 GetBound()158 const ut::Rect& GetBound() const { return m_Rect; } 159 160 //! @brief 深度nearを取得します。 GetDepthNear()161 f32 GetDepthNear() const { return m_DepthNear; } 162 163 //! @brief 深度farを取得します。 GetDepthFar()164 f32 GetDepthFar() const { return m_DepthFar; } 165 166 //@} 167 168 private: 169 ut::Rect m_Rect; 170 f32 m_DepthNear; 171 f32 m_DepthFar; 172 }; 173 174 } // namespace gfx 175 } // namespace nw 176 177 #endif // NW_GFX_VIEWPORT_H_ 178