1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: font_TextWriterResource.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: 27535 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_FONT_CTR_FONT_TEXT_WRITER_RESOURCE_H_ 17 #define NN_FONT_CTR_FONT_TEXT_WRITER_RESOURCE_H_ 18 19 #include <nn/types.h> 20 #include <nn/math.h> 21 #include <nn/util.h> 22 #include <nn/font/font_Types.h> 23 24 namespace nn { 25 namespace font { 26 namespace CTR { 27 28 struct DispStringBuffer; 29 class CharWriter; 30 31 class TextWriterResource : private nn::util::NonCopyable<TextWriterResource> 32 { 33 friend class CharWriter; 34 35 public: 36 37 //! @name コンストラクタ/デストラクタ 38 //@{ 39 40 //! コンストラクタです。 41 TextWriterResource(); 42 43 //! デストラクタです。 44 ~TextWriterResource(); 45 46 //@} 47 48 49 //! @name リソースの初期化/破棄 50 //@{ 51 52 //! @brief DMPGLを使用した描画用のリソースを確保し初期化します。(非推奨) 53 //! 54 //! @param[in] shaderBinary シェーダバイナリ(nwfont_TextWriterShader.shbin) 55 //! @param[in] size シェーダバイナリのサイズ 56 //! 57 void InitResource( 58 const void* shaderBinary, 59 u32 size); 60 61 //! 後処理を行います。 62 void Finalize(); 63 64 //! DMPGLを使用した描画用のリソースを破棄します。(非推奨) DeleteResource()65 void DeleteResource() { Finalize(); } 66 67 //! 描画設定の後処理を行います。 68 static void FinalizeGX(); 69 70 //@} 71 72 73 //! @name 行列の設定 74 //@{ 75 76 //! @brief 射影行列を設定します。 77 //! 78 //! @param[in] mtx 射影行列 79 //! 80 void SetProjectionMtx(const nn::math::MTX44& mtx) const; 81 82 //! @brief ビュー行列を設定します。 83 //! 84 //! @param[in] mtx ビュー行列 85 //! 86 void SetViewMtx(const nn::math::MTX34& mtx) const; 87 88 //@} 89 90 91 //! @name シェーダープログラム関連 92 //@{ 93 94 //! 文字描画用のGLプログラムを有効にします。 ActiveGlProgram()95 void ActiveGlProgram() const 96 { 97 glUseProgram(m_ProgramId); 98 } 99 100 //! @brief プログラムハンドルを取得します。 101 //! 102 //! @return プログラムハンドルを返します。 103 //! GetGlProgram()104 u32 GetGlProgram() const { return m_ProgramId; } 105 106 //@} 107 108 private: 109 enum 110 { 111 VBO_ARRAY, 112 VBO_ELEMENT_ARRAY, 113 114 VBO_NUM 115 }; 116 117 typedef const int (*TexEnvUniformLocationSquareArray)[internal::TCLOC_MAX]; 118 GetTextureID()119 GLuint GetTextureID() const { return m_TextureId; } 120 121 internal::VertexAttribute* GetVertexAttributeArray()122 GetVertexAttributeArray() { return m_VtxAttrs; } 123 124 //! @brief UniformLocation変数配列を取得します。 125 //! 126 //! @return UniformLocation変数配列のポインタを返します。 127 //! GetUniformLocations()128 const int* GetUniformLocations() const { return m_UniformLocations; } 129 130 //! @brief テクスチャコンバイナ用UniformLocation変数配列を取得します。 131 //! 132 //! @return テクスチャコンバイナ用UniformLocation変数配列のポインタを返します。 133 //! 134 TexEnvUniformLocationSquareArray GetTexEnvUniformLocations()135 GetTexEnvUniformLocations() const { return m_TexEnvUniformLocations; } 136 137 //! 読み込み済みテクスチャをリセットします。 ResetLoadingTexture()138 void ResetLoadingTexture() { m_LoadingTexture = NULL; } 139 140 //! @brief 読み込むテクスチャをセットします。 141 //! 142 //! @return テクスチャが変更された場合は真を返します。 143 //! SetLoadingTexture(const void * pTexture)144 bool SetLoadingTexture(const void* pTexture) 145 { 146 const bool isChanged = m_LoadingTexture != pTexture; 147 m_LoadingTexture = pTexture; 148 return isChanged; 149 } 150 151 void SetPosZ(f32 posZ); 152 UpdatePosZ(f32 posZ)153 void UpdatePosZ(f32 posZ) 154 { 155 if (m_PosZ != posZ) 156 { 157 SetPosZ(posZ); 158 } 159 } 160 161 u32 m_ProgramId; //!< プログラムID 162 GLuint m_TextureId; //!< テクスチャオブジェクトのID 163 internal::VertexAttribute 164 m_VtxAttrs[internal::TRIFAN_VTX_MAX]; 165 int m_UniformLocations[internal::LOC_MAX]; 166 int m_TexEnvUniformLocations[internal::TEXENV_MAX][internal::TCLOC_MAX]; 167 const void* m_LoadingTexture; //!< ロード済みテクスチャ 168 f32 m_PosZ; //!< Zの位置 169 170 bool m_IsInitialized; //!< 初期化したかどうか 171 NN_PADDING3; 172 }; 173 174 } // namespace CTR 175 } // namespace font 176 } // namespace nn 177 178 #endif // NN_FONT_TEXT_WRITER_RESOURCE_H_ 179