/*---------------------------------------------------------------------------* Project: Horizon File: font_TextWriterResource.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 27535 $ *---------------------------------------------------------------------------*/ #ifndef NN_FONT_CTR_FONT_TEXT_WRITER_RESOURCE_H_ #define NN_FONT_CTR_FONT_TEXT_WRITER_RESOURCE_H_ #include #include #include #include namespace nn { namespace font { namespace CTR { struct DispStringBuffer; class CharWriter; class TextWriterResource : private nn::util::NonCopyable { friend class CharWriter; public: //! @name コンストラクタ/デストラクタ //@{ //! コンストラクタです。 TextWriterResource(); //! デストラクタです。 ~TextWriterResource(); //@} //! @name リソースの初期化/破棄 //@{ //! @brief DMPGLを使用した描画用のリソースを確保し初期化します。(非推奨) //! //! @param[in] shaderBinary シェーダバイナリ(nwfont_TextWriterShader.shbin) //! @param[in] size シェーダバイナリのサイズ //! void InitResource( const void* shaderBinary, u32 size); //! 後処理を行います。 void Finalize(); //! DMPGLを使用した描画用のリソースを破棄します。(非推奨) void DeleteResource() { Finalize(); } //! 描画設定の後処理を行います。 static void FinalizeGX(); //@} //! @name 行列の設定 //@{ //! @brief 射影行列を設定します。 //! //! @param[in] mtx 射影行列 //! void SetProjectionMtx(const nn::math::MTX44& mtx) const; //! @brief ビュー行列を設定します。 //! //! @param[in] mtx ビュー行列 //! void SetViewMtx(const nn::math::MTX34& mtx) const; //@} //! @name シェーダープログラム関連 //@{ //! 文字描画用のGLプログラムを有効にします。 void ActiveGlProgram() const { glUseProgram(m_ProgramId); } //! @brief プログラムハンドルを取得します。 //! //! @return プログラムハンドルを返します。 //! u32 GetGlProgram() const { return m_ProgramId; } //@} private: enum { VBO_ARRAY, VBO_ELEMENT_ARRAY, VBO_NUM }; typedef const int (*TexEnvUniformLocationSquareArray)[internal::TCLOC_MAX]; GLuint GetTextureID() const { return m_TextureId; } internal::VertexAttribute* GetVertexAttributeArray() { return m_VtxAttrs; } //! @brief UniformLocation変数配列を取得します。 //! //! @return UniformLocation変数配列のポインタを返します。 //! const int* GetUniformLocations() const { return m_UniformLocations; } //! @brief テクスチャコンバイナ用UniformLocation変数配列を取得します。 //! //! @return テクスチャコンバイナ用UniformLocation変数配列のポインタを返します。 //! TexEnvUniformLocationSquareArray GetTexEnvUniformLocations() const { return m_TexEnvUniformLocations; } //! 読み込み済みテクスチャをリセットします。 void ResetLoadingTexture() { m_LoadingTexture = NULL; } //! @brief 読み込むテクスチャをセットします。 //! //! @return テクスチャが変更された場合は真を返します。 //! bool SetLoadingTexture(const void* pTexture) { const bool isChanged = m_LoadingTexture != pTexture; m_LoadingTexture = pTexture; return isChanged; } void SetPosZ(f32 posZ); void UpdatePosZ(f32 posZ) { if (m_PosZ != posZ) { SetPosZ(posZ); } } u32 m_ProgramId; //!< プログラムID GLuint m_TextureId; //!< テクスチャオブジェクトのID internal::VertexAttribute m_VtxAttrs[internal::TRIFAN_VTX_MAX]; int m_UniformLocations[internal::LOC_MAX]; int m_TexEnvUniformLocations[internal::TEXENV_MAX][internal::TCLOC_MAX]; const void* m_LoadingTexture; //!< ロード済みテクスチャ f32 m_PosZ; //!< Zの位置 bool m_IsInitialized; //!< 初期化したかどうか NN_PADDING3; }; } // namespace CTR } // namespace font } // namespace nn #endif // NN_FONT_TEXT_WRITER_RESOURCE_H_