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