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