1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: gfx_ResLight.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: 16154 $
14 *---------------------------------------------------------------------------*/
15
16 #include "../precompiled.h"
17
18 #include <nw/gfx/res/gfx_ResUtil.h>
19 #include <nw/gfx/res/gfx_ResLight.h>
20 #include <nw/gfx/res/gfx_ResGraphicsFile.h>
21
22 namespace nw {
23 namespace gfx {
24 namespace res {
25
26 //----------------------------------------
27 Result
Setup(os::IAllocator * allocator,ResGraphicsFile graphicsFile)28 ResLight::Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile)
29 {
30 NW_UNUSED_VARIABLE(allocator);
31
32 Result result = RESOURCE_RESULT_OK;
33
34 ResFragmentLight fragment = ResDynamicCast<ResFragmentLight>(*this);
35
36 if (fragment.IsValid())
37 {
38 ResReferenceLookupTable referenceDistanceSampler =
39 ResDynamicCast<ResReferenceLookupTable>(fragment.GetDistanceSampler());
40
41 Result distanceResult = SetupReferenceLut(referenceDistanceSampler, graphicsFile);
42
43 if ( fragment.GetDistanceSampler().IsValid() )
44 {
45 if ((distanceResult.GetDescription() & nw::gfx::RESOURCE_RESULT_NOT_FOUND_LUT) == 0)
46 {
47 result |= fragment.GetDistanceSampler().Setup();
48 }
49 }
50
51 result |= distanceResult;
52
53 if (fragment.GetAngleSampler().IsValid())
54 {
55 ResLookupTable resLut = fragment.GetAngleSampler().GetSampler();
56
57 if (resLut.IsValid())
58 {
59 ResReferenceLookupTable referenceAngleSampler =
60 ResDynamicCast<ResReferenceLookupTable>(resLut);
61
62 Result angleResult = SetupReferenceLut(referenceAngleSampler, graphicsFile);
63
64 if ((angleResult.GetDescription() & nw::gfx::RESOURCE_RESULT_NOT_FOUND_LUT) == 0)
65 {
66 result |= resLut.Setup();
67 }
68
69 result |= angleResult;
70 }
71 else
72 {
73 result |= RESOURCE_RESULT_IRRELEVANT_LOCATION_LUT;
74 }
75 }
76 }
77
78 return result;
79 }
80
81 //----------------------------------------
82 void
Cleanup()83 ResLight::Cleanup()
84 {
85 ResFragmentLight fragment = ResDynamicCast<ResFragmentLight>(*this);
86
87 if (fragment.IsValid())
88 {
89 ut::SafeCleanup(fragment.GetDistanceSampler());
90 ut::SafeCleanup(fragment.GetAngleSampler());
91 }
92 }
93
94 } /* namespace res */
95 } /* namespace gfx */
96 } /* namespace nw */
97
98