/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_SimpleMaterialActivator.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: 28677 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_SIMPLEMATERIALACTIVATOR_H_ #define NW_GFX_SIMPLEMATERIALACTIVATOR_H_ #include #include namespace nw { namespace os { class IAllocator; } // namesapce os namespace gfx { class RenderContext; class Material; //--------------------------------------------------------------------------- //! @brief マテリアルを更新するためのクラスです。 //! //! バッファを用いる場合に MaterialActivator が選択されます。 //! バッファを用いない場合は SimpleMaterialActivator が選択されます。 //--------------------------------------------------------------------------- class SimpleMaterialActivator : public IMaterialActivator { private: NW_DISALLOW_COPY_AND_ASSIGN(SimpleMaterialActivator); public: NW_UT_RUNTIME_TYPEINFO; //--------------------------------------------------------------------------- //! @brief マテリアルアクティベータを生成します。 //! //! @param[in] allocator アロケータです。 //! //! @return 生成したマテリアルアクティベータを返します。 //--------------------------------------------------------------------------- static SimpleMaterialActivator* Create(os::IAllocator* allocator); //--------------------------------------------------------------------------- //! @brief 生成時に必要なメモリサイズを取得します。 //! //! @param[in] alignment 計算に用いるアライメントです。2 のべき乗である必要があります。 //--------------------------------------------------------------------------- static size_t GetMemorySize(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) { os::MemorySizeCalculator size(alignment); GetMemorySizeInternal(&size); return size.GetSizeWithPadding(alignment); } //! @details :private static void GetMemorySizeInternal(os::MemorySizeCalculator* pSize) { os::MemorySizeCalculator& size = *pSize; size += sizeof(SimpleMaterialActivator); } //--------------------------------------------------------------------------- //! @brief マテリアルを有効化します。 //! //! @param[in] renderContext レンダーコンテキストです。 //! @param[in] material 有効化するマテリアルです。 //--------------------------------------------------------------------------- virtual void Activate(RenderContext* renderContext, const Material* material); private: //--------------------------------------------------------------------------- //! @brief 指定したクラスが持つハッシュが同値であるかどうか調べます。 //! //! @tparam lhs チェックを行うリソースです。 //! @tparam rhs チェックを行うリソースです。 //--------------------------------------------------------------------------- template NW_INLINE bool EqualHash(const TRes lhs, const URes rhs) { return (lhs.GetHash() == rhs.GetHash()); } //! コンストラクタです。 SimpleMaterialActivator(os::IAllocator* allocator); //! デストラクタです。 virtual ~SimpleMaterialActivator(); }; } // namespace gfx } // namespace nw #endif // NW_GFX_SIMPLEMATERIALACTIVATOR_H_