/*---------------------------------------------------------------------------* Project: NintendoWare File: lyt_ResourceAccessor.cpp Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. 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. $Revision: 19854 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include #include #include namespace nw { namespace lyt { ResourceAccessor::~ResourceAccessor() { } ResourceAccessor::ResourceAccessor() { } const TextureInfo ResourceAccessor::LoadTexture(const char *name) { u32 size = 0; void* pTexRes = this->GetResource(res::RESOURCETYPE_TEXTURE, name, &size); if (!pTexRes || size == 0) { NW_WARNING(false, "texture resource not found. - %s", name); return TextureInfo(); } TextureInfo texInfo = lyt::LoadTexture(pTexRes, size); if (!texInfo.IsValid()) { NW_WARNING(false, "texture object unavailable. - %s", name); return TextureInfo(); } return texInfo; } font::Font* ResourceAccessor::LoadFont(const char *name) { u32 size = 0; void* pFontRes = this->GetResource(res::RESOURCETYPE_FONT, name, &size); if (!pFontRes || size == 0) { NW_WARNING(false, "font resource not found. - %s", name); return NULL; } font::ResFont* pResFont = Layout::NewObj(); if (pResFont == NULL) { NW_WARNING(false, "font object creation failed."); return NULL; } bool bSuccess = pResFont->SetResource(pFontRes); if (!bSuccess) { NW_WARNING(false, "Fail to load ResFont."); Layout::DeleteObj(pResFont); return NULL; } #if !defined(NW_FONT_TEXTURENAMES_BINARY_ALLOCATED) { const u32 drawBufferSize = font::ResFont::GetDrawBufferSize(pFontRes); void* drawBuffer = Layout::AllocMemory(drawBufferSize, 4); pResFont->SetDrawBuffer(drawBuffer); } #endif return pResFont; } } // namespace nw::lyt } // namespace nw