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