/*---------------------------------------------------------------------------* Project: NintendoWare File: lyt_TexMap.h Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. 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. The content herein is highly confidential and should be handled accordingly. $Revision: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_LYT_TEXMAP_H_ #define NW_LYT_TEXMAP_H_ #include #include #include namespace nw { namespace lyt { namespace res { struct Image; } class TextureInfo; //--------------------------------------------------------------------------- //! :category 描画 //! //! @brief テクスチャマップを制御するクラスです。 //! //! @since 2009/09/18 初版。 //--------------------------------------------------------------------------- class TexMap { public: //---------------------------------------- //! @name コンストラクタ/デストラクタ //@{ //! @brief コンストラクタです。 //! //! @since 2009/09/18 初版。 //! TexMap(); //! @brief コンストラクタです。 //! //! @details //! 指定のテクスチャ情報で初期化します。 //! //! @param textureInfo テクスチャ情報です。 //! //! @since 2009/09/18 初版。 //! TexMap(const TextureInfo& textureInfo); //@} //---------------------------------------- //! @name 設定/取得 //@{ //! @brief テクスチャオブジェクトを取得します。 //! //! @return テクスチャ名ブジェクトのハンドルを返します。 //! //! @since 2009/09/18 初版。 //! u32 GetTextureObject() const { return m_TexObject; } //! @brief テクスチャオブジェクトを設定します。 //! //! @param texObject テクスチャオブジェクトのハンドルです。 //! //! @since 2009/09/18 初版。 //! void SetTextureObject(u32 texObject) { m_TexObject = texObject; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャの S 方向のラップモードを取得します。 //! //! @return S 方向のラップモードを返します。 //! //! @since 2009/09/18 初版。 //! TexWrap GetWrapModeS() const { return TexWrap(m_Bits.wrapS); } //! @brief テクスチャの T 方向のラップモードを取得します。 //! //! @return T 方向のラップモードを返します。 //! //! @since 2009/09/18 初版。 //! TexWrap GetWrapModeT() const { return TexWrap(m_Bits.wrapT); } //! @brief テクスチャのラップモードを設定します。 //! //! @param wrapS テクスチャの S 方向のラップモードです。 //! @param wrapT テクスチャの T 方向のラップモードです。 //! //! @since 2009/09/18 初版。 //! void SetWrapMode(TexWrap wrapS, TexWrap wrapT) { NW_ASSERT(wrapS < TEXWRAP_MAX); NW_ASSERT(wrapT < TEXWRAP_MAX); m_Bits.wrapS = wrapS; m_Bits.wrapT = wrapT; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャが縮小されるときに適用されるフィルタモードを取得します。 //! //! @return テクスチャが縮小されるときに適用されるフィルタモードを返します。 //! //! @since 2009/09/18 初版。 //! TexFilter GetMinFilter() const { return TexFilter(m_Bits.minFilter); } //! @brief テクスチャが拡大されるときに適用されるフィルタモードを取得します。 //! //! @return テクスチャが拡大されるときに適用されるフィルタモードを返します。 //! //! @since 2009/09/18 初版。 //! TexFilter GetMagFilter() const { return TexFilter(m_Bits.magFilter); } //! @brief テクスチャのフィルタモードを設定します。 //! //! @param minFlt テクスチャが縮小されるときに適用されるフィルタモードです。 //! @param magFlt テクスチャが拡大されるときに適用されるフィルタモードです。 //! //! @since 2009/09/18 初版。 //! void SetFilter(TexFilter minFlt, TexFilter magFlt) { NW_ASSERT(minFlt <= TEXFILTER_MAX); NW_ASSERT(magFlt <= TEXFILTER_MAX); m_Bits.minFilter = minFlt; m_Bits.magFilter = magFlt; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャの幅を取得します。 //! //! @return テクスチャの幅を返します。 //! //! @since 2009/09/18 初版。 //! u16 GetWidth() const { return m_Width; } //! @brief テクスチャの高さを取得します。 //! //! @return テクスチャの高さを取得します。 //! //! @since 2009/09/18 初版。 //! u16 GetHeight() const { return m_Height; } //! @brief テクスチャのサイズ(幅、高さ)を取得します。 //! //! @return テクスチャのサイズ(幅、高さ)を返します。 //! //! @since 2009/09/18 初版。 //! const TexSize GetSize() const { return TexSize(m_Width, m_Height); } //! @brief テクスチャのサイズ(幅、高さ)を設定します。 //! //! @param width テクスチャの幅です。 //! @param height テクスチャの高さです。 //! //! @since 2009/09/18 初版。 //! void SetSize(u16 width, u16 height) { m_Width = width; m_Height = height; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャのサイズ(幅、高さ)を設定します。 //! //! @param size テクスチャのサイズ(幅、高さ)です。 void SetSize(const TexSize& size) { SetSize(size.width, size.height); } //! @brief テクスチャの幅を取得します。 //! //! @return テクスチャの幅を返します。 //! //! @since 2009/09/18 初版。 //! u16 GetRealWidth() const { return m_RealWidth; } //! @brief テクスチャの高さを取得します。 //! //! @return テクスチャの高さを取得します。 //! //! @since 2009/09/18 初版。 //! u16 GetRealHeight() const { return m_RealHeight; } //! @brief テクスチャのサイズ(幅、高さ)を取得します。 //! //! @return テクスチャのサイズ(幅、高さ)を返します。 //! //! @since 2009/09/18 初版。 //! const TexSize GetRealSize() const { return TexSize(m_RealWidth, m_RealHeight); } //! @brief テクスチャのサイズ(幅、高さ)を設定します。 //! //! @param width テクスチャの幅です。 //! @param height テクスチャの高さです。 //! //! @since 2009/09/18 初版。 //! void SetRealSize(u16 width, u16 height) { m_RealWidth = width; m_RealHeight = height; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャのサイズ(幅、高さ)を設定します。 //! //! @param size テクスチャのサイズ(幅、高さ)です。 //! //! @since 2009/09/18 初版。 //! void SetRealSize(const TexSize& size) { SetRealSize(size.width, size.height); } //! @brief テクスチャの物理を設定します。 //! //! @details //! テクスチャの物理アドレスは Drawer の描画で使用されます。 //! //! @param physicalAddress テクスチャの物理アドレスです。 //! //! @sa GetPhysicalAddress //! //! @since 2010/05/14 初版。 //! void SetPhysicalAddress(uptr physicalAddress) { m_PhysicalAddress = physicalAddress; } //! @brief テクスチャの物理アドレスを取得します。 //! //! @return テクスチャの物理アドレスを返します。 //! //! @sa SetPhysicalAddress //! //! @since 2010/05/14 初版。 //! uptr GetPhysicalAddress() const { return m_PhysicalAddress; } //! @brief テクスチャのフォーマットを取得します。 //! //! @return テクスチャのフォーマットを返します。 //! //! @since 2010/04/23 初版。 //! TexFormat GetFormat() const { return TexFormat(m_Bits.format); } //! @brief テクスチャのフォーマットを設定します。 //! //! @param format テクスチャのフォーマットです。 //! //! @since 2010/04/23 初版。 //! void SetFormat(TexFormat format) { m_Bits.format = format; #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャの情報を設定します。 //! //! @details //! TextureInfo の値をコピーします。 //! //! @param src コピー元です。 //! //! @since 2009/09/18 初版。 //! void Set(const TextureInfo& src) { m_TexObject = src.GetTextureObject(); m_PhysicalAddress = src.GetPhysicalAddress(); m_Width = src.GetSize().width; m_Height = src.GetSize().height; m_RealWidth = src.GetRealSize().width; m_RealHeight = src.GetRealSize().height; m_Bits.format = src.GetFormat(); #ifdef NW_LYT_DRAWER_ENABLE ResetU32Info(); #endif } //! @brief テクスチャの情報を設定します。 //! //! @details //! 内容全体をコピーします。 //! //! @param texMap TexMap オブジェクトへの参照です。 //! //! @since 2009/09/18 初版。 //! void Set(const TexMap& texMap) { *this = texMap; } //@} #ifdef NW_LYT_DRAWER_ENABLE public: //! @details :private inline u32 GetU32WrapFilter() const { return m_u32WrapFilter; } //! @details :private inline u32 GetU32WidthHeight() const { return m_u32WidthHeight; } //! @details :private inline u32 GetU32Format() const { return m_u32Format; } protected: //! @details :private void ResetU32Info(); #endif protected: //! @details :private u32 m_TexObject; //! @details :private uptr m_PhysicalAddress; //! @details :private u16 m_Width; //! @details :private u16 m_Height; //! @details :private u16 m_RealWidth; //! @details :private u16 m_RealHeight; //! @details :private struct Bits { u32 wrapS: 2; u32 wrapT: 2; u32 minFilter: 3; u32 magFilter: 1; u32 format: 4; }; //! @details :private Bits m_Bits; #ifdef NW_LYT_DRAWER_ENABLE //! @details :private u32 m_u32WrapFilter; //! @details :private u32 m_u32WidthHeight; //! @details :private u32 m_u32Format; #endif }; } // namespace nw::lyt } // namespace nw #endif // NW_LYT_TEXMAP_H_