1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_MaterialActivator.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_MATERIALACTIVATOR_H_
19 #define NW_GFX_MATERIALACTIVATOR_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 MaterialActivator : public IMaterialActivator
44 {
45 private:
46     NW_DISALLOW_COPY_AND_ASSIGN(MaterialActivator);
47 
48 public:
49     NW_UT_RUNTIME_TYPEINFO;
50 
51     //---------------------------------------------------------------------------
52     //! @brief        マテリアルアクティベータを生成します。
53     //!
54     //! @param[in]    allocator アロケータです。
55     //!
56     //! @return       生成したマテリアルアクティベータを返します。
57     //---------------------------------------------------------------------------
58     static MaterialActivator* 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 
75     //! @details :private
GetMemorySizeInternal(os::MemorySizeCalculator * pSize)76     static void GetMemorySizeInternal(
77         os::MemorySizeCalculator* pSize)
78     {
79         os::MemorySizeCalculator& size = *pSize;
80 
81         size += sizeof(MaterialActivator);
82     }
83 
84     //---------------------------------------------------------------------------
85     //! @brief        マテリアルを有効化します。
86     //!
87     //! @param[in]    renderContext レンダーコンテキストです。
88     //! @param[in]    material 有効化するマテリアルです。
89     //---------------------------------------------------------------------------
90     virtual void Activate(RenderContext* renderContext, const Material* material);
91 
92 private:
93     //! コンストラクタです。
94     MaterialActivator(os::IAllocator* allocator);
95 
96     //! デストラクタです。
97     virtual ~MaterialActivator();
98 };
99 
100 } // namespace gfx
101 } // namespace nw
102 
103 #endif // NW_GFX_MATERIALACTIVATOR_H_
104