1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_SimpleMaterialActivator.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_GFX_SIMPLEMATERIALACTIVATOR_H_ 19 #define NW_GFX_SIMPLEMATERIALACTIVATOR_H_ 20 21 #include <nw/gfx/gfx_GfxObject.h> 22 #include <nw/gfx/gfx_IMaterialActivator.h> 23 24 namespace nw 25 { 26 namespace os 27 { 28 class IAllocator; 29 } // namesapce os 30 31 namespace gfx 32 { 33 34 class RenderContext; 35 class Material; 36 37 //--------------------------------------------------------------------------- 38 //! @brief マテリアルを更新するためのクラスです。 39 //! 40 //! バッファを用いる場合に MaterialActivator が選択されます。 41 //! バッファを用いない場合は SimpleMaterialActivator が選択されます。 42 //--------------------------------------------------------------------------- 43 class SimpleMaterialActivator : public IMaterialActivator 44 { 45 private: 46 NW_DISALLOW_COPY_AND_ASSIGN(SimpleMaterialActivator); 47 48 public: 49 NW_UT_RUNTIME_TYPEINFO; 50 51 //--------------------------------------------------------------------------- 52 //! @brief マテリアルアクティベータを生成します。 53 //! 54 //! @param[in] allocator アロケータです。 55 //! 56 //! @return 生成したマテリアルアクティベータを返します。 57 //--------------------------------------------------------------------------- 58 static SimpleMaterialActivator* Create(os::IAllocator* allocator); 59 60 //--------------------------------------------------------------------------- 61 //! @brief 生成時に必要なメモリサイズを取得します。 62 //! 63 //! @param[in] alignment 計算に用いるアライメントです。2 のべき乗である必要があります。 64 //--------------------------------------------------------------------------- 65 static size_t GetMemorySize(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) 66 { 67 os::MemorySizeCalculator size(alignment); 68 69 GetMemorySizeInternal(&size); 70 71 return size.GetSizeWithPadding(alignment); 72 } 73 74 //! @details :private GetMemorySizeInternal(os::MemorySizeCalculator * pSize)75 static void GetMemorySizeInternal(os::MemorySizeCalculator* pSize) 76 { 77 os::MemorySizeCalculator& size = *pSize; 78 79 size += sizeof(SimpleMaterialActivator); 80 } 81 82 //--------------------------------------------------------------------------- 83 //! @brief マテリアルを有効化します。 84 //! 85 //! @param[in] renderContext レンダーコンテキストです。 86 //! @param[in] material 有効化するマテリアルです。 87 //--------------------------------------------------------------------------- 88 virtual void Activate(RenderContext* renderContext, const Material* material); 89 90 private: 91 92 //--------------------------------------------------------------------------- 93 //! @brief 指定したクラスが持つハッシュが同値であるかどうか調べます。 94 //! 95 //! @tparam lhs チェックを行うリソースです。 96 //! @tparam rhs チェックを行うリソースです。 97 //--------------------------------------------------------------------------- 98 template<typename TRes, typename URes> 99 NW_INLINE bool EqualHash(const TRes lhs,const URes rhs)100 EqualHash(const TRes lhs, const URes rhs) 101 { 102 return (lhs.GetHash() == rhs.GetHash()); 103 } 104 105 //! コンストラクタです。 106 SimpleMaterialActivator(os::IAllocator* allocator); 107 108 //! デストラクタです。 109 virtual ~SimpleMaterialActivator(); 110 }; 111 112 } // namespace gfx 113 } // namespace nw 114 115 #endif // NW_GFX_SIMPLEMATERIALACTIVATOR_H_ 116