1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     gfx_ResGraphicsFile.cpp
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: 19456 $
14  *---------------------------------------------------------------------------*/
15 
16 #include "../precompiled.h"
17 
18 #include <nw/ut/ut_ResUtil.h>
19 #include <nw/ut/ut_ResDictionary.h>
20 #include <nw/gfx/gfx_SceneObject.h>
21 #include <nw/gfx/res/gfx_ResShape.h>
22 #include <nw/gfx/res/gfx_ResModel.h>
23 #include <nw/gfx/res/gfx_ResMaterial.h>
24 #include <nw/gfx/res/gfx_ResGraphicsFile.h>
25 #include <nw/gfx/gfx_Common.h>
26 #include <GLES2/gl2.h>
27 #include <GLES2/gl2ext.h>
28 
29 namespace nw {
30 namespace gfx {
31 namespace res {
32 
33 //----------------------------------------------------------------------------
34 Result
Setup(os::IAllocator * allocator,ResGraphicsFile graphicsFile)35 ResGraphicsFile::Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile)
36 {
37     Result result = RESOURCE_RESULT_OK;
38     NW_ASSERT( this->IsValid() );
39     NW_ASSERT( internal::ResCheckRevision( *this ) );
40     NW_ASSERT( internal::ResCheckRevision( graphicsFile ) );
41 
42     s32 lutSetsNum = this->GetLutSetsCount();
43     for ( int i = 0; i < lutSetsNum; ++i )
44     {
45         result |= this->GetLutSets( i ).Setup(allocator, graphicsFile);
46     }
47 
48     s32 lightNum = this->GetLightsCount();
49     for ( int i = 0; i < lightNum; ++i )
50     {
51         result |= this->GetLights( i ).Setup(allocator, graphicsFile);
52     }
53 
54     s32 fogNum = this->GetFogsCount();
55     for ( int i = 0; i < fogNum; ++i )
56     {
57         result |= this->GetFogs( i ).Setup(allocator, graphicsFile);
58     }
59 
60     s32 shaderNum = this->GetShadersCount();
61     for ( int i = 0; i < shaderNum; ++i )
62     {
63         result |= this->GetShaders( i ).Setup(allocator, graphicsFile);
64     }
65 
66     s32 textureNum = this->GetTexturesCount();
67     for ( int i = 0; i < textureNum; ++i )
68     {
69         result |= this->GetTextures( i ).Setup(allocator, graphicsFile);
70     }
71 
72     s32 skeletalAnimNum = this->GetSkeletalAnimsCount();
73     for ( int i = 0; i < skeletalAnimNum; ++i )
74     {
75         result |= this->GetSkeletalAnims( i ).Setup(allocator, graphicsFile);
76     }
77 
78     s32 materialAnimNum = this->GetMaterialAnimsCount();
79     for ( int i = 0; i < materialAnimNum; ++i )
80     {
81         result |= this->GetMaterialAnims( i ).Setup(allocator, graphicsFile);
82     }
83 
84     s32 visibilityAnimNum = this->GetVisibilityAnimsCount();
85     for ( int i = 0; i < visibilityAnimNum; ++i )
86     {
87         result |= this->GetVisibilityAnims( i ).Setup(allocator, graphicsFile);
88     }
89 
90     s32 cameraAnimNum = this->GetCameraAnimsCount();
91     for ( int i = 0; i < cameraAnimNum; ++i )
92     {
93         result |= this->GetCameraAnims( i ).Setup(allocator, graphicsFile);
94     }
95 
96     s32 lightAnimNum = this->GetLightAnimsCount();
97     for ( int i = 0; i < lightAnimNum; ++i )
98     {
99         result |= this->GetLightAnims( i ).Setup(allocator, graphicsFile);
100     }
101 
102     s32 modelNum = this->GetModelsCount();
103     for ( int i = 0; i < modelNum; ++i )
104     {
105         result |= this->GetModels( i ).Setup(allocator, graphicsFile);
106     }
107 
108     return result;
109 }
110 
111 //----------------------------------------------------------------------------
112 void
Cleanup()113 ResGraphicsFile::Cleanup()
114 {
115     NW_ASSERT( this->IsValid() );
116 
117     ut::SafeCleanupAll(this->GetModels());
118 
119     ut::SafeCleanupAll(this->GetLightAnims());
120 
121     ut::SafeCleanupAll(this->GetCameraAnims());
122 
123     ut::SafeCleanupAll(this->GetVisibilityAnims());
124 
125     ut::SafeCleanupAll(this->GetMaterialAnims());
126 
127     ut::SafeCleanupAll(this->GetSkeletalAnims());
128 
129     ut::SafeCleanupAll(this->GetTextures());
130 
131     ut::SafeCleanupAll(this->GetShaders());
132 
133     ut::SafeCleanupAll(this->GetFogs());
134 
135     ut::SafeCleanupAll(this->GetLights());
136 
137     ut::SafeCleanupAll(this->GetLutSets());
138 }
139 
140 } /* namespace res */
141 } /* namespace gfx */
142 } /* namespace nw */
143 
144