/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_OffScreenBuffer.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: 26052 $ *---------------------------------------------------------------------------*/ #include "precompiled.h" #include #include #include namespace nw { namespace gfx { NW_UT_RUNTIME_TYPEINFO_DEFINITION(OffScreenBuffer, IRenderTarget); //---------------------------------------- OffScreenBuffer::OffScreenBuffer(os::IAllocator* pAllocator, const Description& description, ResPixelBasedTexture resTexture) : IRenderTarget(pAllocator), m_ActivateCommand(NULL), m_Description(description), m_Texture(resTexture) { ResPixelBasedTexture resPixelBasedTexture = ResStaticCast(resTexture); NW_ASSERT(resPixelBasedTexture.GetTextureObject() != 0); m_BackBufferObject.SetHeight( resTexture.GetHeight() ); m_BackBufferObject.SetWidth( resTexture.GetWidth() ); GLuint format; switch ( resTexture.GetFormatHW() ) { case ResPixelBasedTexture::FORMAT_HW_RGBA8: format = GL_RGBA8_OES; break; case ResPixelBasedTexture::FORMAT_HW_RGBA5551: format = GL_RGB5_A1; break; case ResPixelBasedTexture::FORMAT_HW_RGBA4: format = GL_RGBA4; break; case ResPixelBasedTexture::FORMAT_HW_RGB565: format = GL_RGB565; break; default: NW_FATAL_ERROR("illegal texture format for OffScreenBuffer"); } m_BackBufferObject.SetColorFormat( format ); m_BackBufferObject.SetDepthFormat( 0 ); switch (resTexture.GetTypeInfo()) { case ResImageTexture::TYPE_INFO: { u32 address = ResStaticCast(resTexture).GetImage().GetImageAddress(); m_BackBufferObject.SetColorAddress( address ); } break; case ResCubeTexture::TYPE_INFO: { ResCubeTexture::CubeFace face = ResCubeTexture::CUBE_FACE_POSITIVE_X; u32 address = ResStaticCast(resTexture).GetImage( face ).GetImageAddress(); m_BackBufferObject.SetColorAddress( address ); } break; case ResShadowTexture::TYPE_INFO: { u32 address = ResStaticCast(resTexture).GetImage().GetImageAddress(); m_BackBufferObject.SetColorAddress( address ); } break; default: { NW_FATAL_ERROR("Unsupported texture type.\n"); } break; } } //---------------------------------------- OffScreenBuffer::~OffScreenBuffer() { } } // namespace gfx } // namespace nw