1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: lyt_TextureContainer.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: 31311 $ 16 *---------------------------------------------------------------------------*/ 17 18 #ifndef NW_LYT_TEXTURECONTAINER_H_ 19 #define NW_LYT_TEXTURECONTAINER_H_ 20 21 #include <nw/ut/ut_LinkList.h> 22 23 #include <nw/lyt/lyt_Types.h> 24 25 namespace nw 26 { 27 namespace lyt 28 { 29 30 //--------------------------------------------------------------------------- 31 //! :private 32 //! 33 //! @brief テクスチャを保持するクラスです。 34 //! 35 //! @sa TextureContainer 36 //! 37 //! @since 2009/09/18 初版。 38 //--------------------------------------------------------------------------- 39 class TextureRefLink 40 { 41 public: 42 //! テクスチャリソース名の最大です。 43 static const int TEXIMAGE_FILENAME_MAX = 127; 44 45 //---------------------------------------- 46 //! @name コンストラクタ/デストラクタ 47 //@{ 48 49 //! @brief コンストラクタです。 50 TextureRefLink(); 51 52 53 //! @brief デストラクタです。 54 //! 55 //! @details 56 //! OpenGL のテクスチャオブジェクトを破棄します。 57 //! 58 //! @since 2009/09/18 初版。 59 //! 60 ~TextureRefLink(); 61 62 // @} 63 64 //---------------------------------------- 65 //! @name 設定/取得 66 //@{ 67 68 //! @brief テクスチャ情報を設定します。 69 //! 70 //! @param resourceName テクスチャを特定する名前です。 71 //! @param texInfo テクスチャ情報です。 72 //! 73 //! @since 2009/09/18 初版。 74 //! 75 void Set( 76 const char* resourceName, 77 const TextureInfo& texInfo); 78 79 //! @brief テクスチャのリソース名を取得します。 80 //! 81 //! @return テクスチャのリソース名を返します。 82 //! 83 //! @since 2009/09/18 初版。 84 //! GetResourceName()85 const char* GetResourceName() const 86 { 87 return m_Name; 88 } 89 90 //! @brief テクスチャ情報を取得します。 91 //! 92 //! @return テクスチャ情報を返します。 93 //! 94 //! @since 2009/09/18 初版。 95 //! GetTextureInfo()96 const TextureInfo GetTextureInfo() 97 { 98 return m_TexInfo; 99 } 100 101 // @} 102 103 //! :private 104 //! @brief リンク情報です。 105 ut::LinkListNode m_Link; 106 107 protected: 108 //! @details :private 109 char m_Name[TEXIMAGE_FILENAME_MAX + 1]; 110 111 //! @details :private 112 TextureInfo m_TexInfo; 113 }; 114 115 //--------------------------------------------------------------------------- 116 //! :category リソースアクセサ 117 //! 118 //! @brief テクスチャを保持するクラスです。 119 //! 120 //! @details 121 //! ResourceAccessor の実装で OpenGL のテクスチャオブジェクトを保持するのに 122 //! 利用されます。 123 //! 124 //! @sa ResourceAccessor 125 //! 126 //! @since 2010/01/26 初版。 127 //--------------------------------------------------------------------------- 128 class TextureContainer : public ut::LinkList<TextureRefLink, offsetof(TextureRefLink, m_Link)> 129 { 130 public: 131 //---------------------------------------- 132 //! @name コンストラクタ/デストラクタ 133 //@{ 134 135 //! @brief デストラクタです。 136 //! 137 //! @details 138 //! 登録されているすべてのテクスチャを破棄します。 139 //! 140 //! @since 2010/01/26 初版。 141 //! 142 ~TextureContainer(); 143 144 //@} 145 146 //---------------------------------------- 147 //! @name 登録/破棄 148 //@{ 149 150 //! @brief 登録を抹消します。 151 //! 152 //! @details 153 //! 登録されているすべてのテクスチャを破棄します。 154 //! 155 //! @since 2010/01/26 初版。 156 //! 157 void Finalize(); 158 159 //! @brief テクスチャ情報を登録します。 160 //! 161 //! @param name テクスチャの名前です。 162 //! @param textureInfo テクスチャ情報です。 163 //! 164 //! @return 登録キーを返します。キーは登録の抹消に使用します。 165 //! 166 //! @since 2010/01/26 初版。 167 //! 168 TextureKey RegistTexture(const char* name, const TextureInfo& textureInfo); 169 170 //! @brief テクスチャの登録を抹消します。 171 //! 172 //! @param key 登録時に取得した登録キーを指定します。 173 //! 174 //! @since 2010/01/26 初版。 175 //! 176 void UnregistTexture(TextureKey key); 177 178 //@} 179 180 //---------------------------------------- 181 //! @name 検索 182 //@{ 183 184 //! @brief テクスチャ情報を検索します。 185 //! 186 //! @param name テクスチャのリソース名です。 187 //! 188 //! @return 189 //! テクスチャ情報を返します。 190 //! 191 //! @since 2010/01/26 初版。 192 //! 193 const TextureInfo FindTextureByName(const char* name); 194 195 //! @brief テクスチャ情報を検索します。 196 //! 197 //! @param key テクスチャの登録キーです。 198 //! 199 //! @return 200 //! テクスチャ情報を返します。 201 //! 202 //! @since 2010/11/30 初版。 203 //! 204 const TextureInfo FindTextureByKey(TextureKey key); 205 206 //@} 207 }; 208 209 } // namespace nw::lyt 210 } // namespace nw 211 212 #endif // NW_LYT_TEXTURECONTAINER_H_ 213