/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResUtil.cpp Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. The content herein is highly confidential and should be handled accordingly. $Revision: $ *---------------------------------------------------------------------------*/ #include "../precompiled.h" #include #include namespace nw { namespace gfx { namespace res { //---------------------------------------- Result SetupReferenceLut(ResReferenceLookupTable resReferenceLut, ResGraphicsFile graphicsFile) { Result result = RESOURCE_RESULT_OK; if (resReferenceLut.IsValid()) { ResImageLookupTable resImageLut = ResDynamicCast(resReferenceLut.GetTargetLut()); if (!resImageLut.IsValid()) { ::std::pair referenceResult; referenceResult = GetReferenceLutTarget(resReferenceLut, graphicsFile); if (!referenceResult.second) { result |= Result::MASK_FAIL_BIT; result |= RESOURCE_RESULT_NOT_FOUND_LUT; } } } return result; } //---------------------------------------- ::std::pair GetReferenceLutTarget(ResReferenceLookupTable referenceLut, ResGraphicsFile graphicsFile) { bool isExisted = false; const char* path = referenceLut.GetPath(); const char* tableName = referenceLut.GetTableName(); int lutSetNum = graphicsFile.GetLutSetsCount(); ResLookupTableSet resLutSet = graphicsFile.GetLutSets(path); if (resLutSet.IsValid()) { ResImageLookupTable resLut = ResDynamicCast(resLutSet.GetSamplers(tableName)); if (resLut.IsValid()) { referenceLut.ref().toTargetLut.set_ptr(resLut.ptr()); isExisted = true; } } return ::std::make_pair(referenceLut.GetTargetLut(), isExisted); } //---------------------------------------------------------------------------- ::std::pair GetReferenceTextureTarget(ResReferenceTexture referenceTexture, ResGraphicsFile graphicsFile) { bool isExisted = false; const char* path = referenceTexture.GetPath(); ResTexture resTexture = graphicsFile.GetTextures(path); if (resTexture.IsValid()) { ResReferenceTexture refer = ResDynamicCast(resTexture); // 再帰呼び出しによって参照解決する if (refer.IsValid()) { ::std::pair referenceResult; referenceResult = GetReferenceTextureTarget(refer, graphicsFile); if (referenceResult.second) { referenceTexture.ref().toTargetTexture.set_ptr(referenceResult.first.ptr()); isExisted = true; } } else { referenceTexture.ref().toTargetTexture.set_ptr(resTexture.ptr()); isExisted = true; } } return ::std::make_pair(referenceTexture.GetTargetTexture(), isExisted); } //---------------------------------------- ::std::pair GetReferenceShaderTarget(ResReferenceShader referenceShader, ResGraphicsFile graphicsFile) { bool isExisted = false; const char* path = referenceShader.GetPath(); ResShader resShader = graphicsFile.GetShaders(path); if (resShader.IsValid()) { ResReferenceShader refer = ResDynamicCast(resShader); // 再帰呼び出しによって参照解決する if (refer.IsValid()) { ::std::pair referenceResult; referenceResult = GetReferenceShaderTarget(refer, graphicsFile); if (referenceResult.second) { referenceShader.ref().toTargetShader.set_ptr(referenceResult.first.ptr()); isExisted = true; } } else { referenceShader.ref().toTargetShader.set_ptr(resShader.ptr()); isExisted = true; } } return ::std::make_pair(referenceShader.GetTargetShader(),isExisted); } } /* namespace res */ } /* namespace gfx */ } /* namespace nw */