1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: gfx_MaterialActivator.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 28677 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_GFX_MATERIALACTIVATOR_H_ 17 #define NW_GFX_MATERIALACTIVATOR_H_ 18 19 #include <nw/gfx/gfx_GfxObject.h> 20 #include <nw/gfx/gfx_IMaterialActivator.h> 21 22 namespace nw 23 { 24 namespace os 25 { 26 class IAllocator; 27 } // namesapce os 28 29 namespace gfx 30 { 31 32 class RenderContext; 33 class Material; 34 35 //--------------------------------------------------------------------------- 36 //! @brief マテリアルを更新するためのクラスです。 37 //! 38 //! バッファを用いる場合に MaterialActivator が選択されます。 39 //! バッファを用いない場合は SimpleMaterialActivator が選択されます。 40 //--------------------------------------------------------------------------- 41 class MaterialActivator : public IMaterialActivator 42 { 43 private: 44 NW_DISALLOW_COPY_AND_ASSIGN(MaterialActivator); 45 46 public: 47 NW_UT_RUNTIME_TYPEINFO; 48 49 //--------------------------------------------------------------------------- 50 //! @brief マテリアルアクティベータを生成します。 51 //! 52 //! @param[in] allocator アロケータです。 53 //! 54 //! @return 生成したマテリアルアクティベータを返します。 55 //--------------------------------------------------------------------------- 56 static MaterialActivator* Create(os::IAllocator* allocator); 57 58 //--------------------------------------------------------------------------- 59 //! @brief 生成時に必要なメモリサイズを取得します。 60 //! 61 //! @param[in] alignment 計算に用いるアライメントです。2 のべき乗である必要があります。 62 //--------------------------------------------------------------------------- 63 static size_t GetMemorySize(size_t alignment = os::IAllocator::DEFAULT_ALIGNMENT) 64 { 65 os::MemorySizeCalculator size(alignment); 66 67 GetMemorySizeInternal(&size); 68 69 return size.GetSizeWithPadding(alignment); 70 } 71 72 73 //! @details :private GetMemorySizeInternal(os::MemorySizeCalculator * pSize)74 static void GetMemorySizeInternal( 75 os::MemorySizeCalculator* pSize) 76 { 77 os::MemorySizeCalculator& size = *pSize; 78 79 size += sizeof(MaterialActivator); 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 MaterialActivator(os::IAllocator* allocator); 93 94 //! デストラクタです。 95 virtual ~MaterialActivator(); 96 }; 97 98 } // namespace gfx 99 } // namespace nw 100 101 #endif // NW_GFX_MATERIALACTIVATOR_H_ 102