/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_IRenderTarget.h 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: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_IRENDERTARGET_H_ #define NW_GFX_IRENDERTARGET_H_ #include #include #include #include #include #include #include #include namespace nw { namespace gfx { namespace res { class ResTexture; } //--------------------------------------------------------------------------- //! @brief バッファのフォーマットの定義です。 //--------------------------------------------------------------------------- enum RenderColorFormat { RENDER_COLOR_FORMAT_NONE, RENDER_COLOR_FORMAT_RGBA8 = GL_RGBA8_OES, RENDER_COLOR_FORMAT_RGB8 = GL_RGB8_OES, RENDER_COLOR_FORMAT_RGBA4 = GL_RGBA4, RENDER_COLOR_FORMAT_RGB5_A1 = GL_RGB5_A1, RENDER_COLOR_FORMAT_RGB565 = GL_RGB565, RENDER_COLOR_FORMAT_COUNT }; enum RenderDepthFormat { RENDER_DEPTH_FORMAT_NONE, RENDER_DEPTH_FORMAT_16 = GL_DEPTH_COMPONENT16, RENDER_DEPTH_FORMAT_24 = GL_DEPTH_COMPONENT24_OES, RENDER_DEPTH_FORMAT_24_STENCIL8 = GL_DEPTH24_STENCIL8_EXT, RENDER_DEPTH_FORMAT_COUNT }; namespace internal { enum { MEMORY_AREA_FCRAM_INTERNAL = NN_GX_MEM_FCRAM, MEMORY_AREA_VRAMA_INTERNAL = NN_GX_MEM_VRAMA, MEMORY_AREA_VRAMB_INTERNAL = NN_GX_MEM_VRAMB }; } //--------------------------------------------------------------------------- //! @brief グラフィックスメモリ領域を表す定義です。 //--------------------------------------------------------------------------- enum GraphicsMemoryArea { MEMORY_AREA_NONE, MEMORY_AREA_FCRAM = internal::MEMORY_AREA_FCRAM_INTERNAL, //!< FCRAMの領域を表します。 MEMORY_AREA_VRAMA = internal::MEMORY_AREA_VRAMA_INTERNAL, //!< VRAMのAチャンネルの領域を表します。 MEMORY_AREA_VRAMB = internal::MEMORY_AREA_VRAMB_INTERNAL, //!< VRAMのBチャンネルの領域を表します。 GRAPHICS_MEMORY_AREA_COUNT //!< メモリ領域の種類の数を表します。 }; //! シャドウの種別です。 enum ShadowKind { SHADOW_KIND_NONE, SHADOW_KIND_TEXTURE, SHADOW_KIND_CUBE }; //--------------------------------------------------------------------------- //! @brief 描画対象を表すインターフェースです。 //--------------------------------------------------------------------------- class IRenderTarget : public GfxObject { public: NW_UT_RUNTIME_TYPEINFO; //---------------------------------------- //! @name 作成 //@{ //! 描画対象の設定内容です。 struct Description { s32 width; //!< 描画対象の幅です。 s32 height; //!< 描画対象の高さです。 RenderColorFormat colorFormat; //!< 描画対象のカラーフォーマットです。 RenderDepthFormat depthFormat; //!< 描画対象の深度フォーマットです。 GraphicsMemoryArea colorArea; //!< 描画対象のカラーバッファの配置場所です。 GraphicsMemoryArea depthArea; //!< 描画対象のデプスバッファの配置場所です。 u32 colorAddress; //!< 描画対象のカラーバッファのアドレスを直接指定します。 u32 depthAddress; //!< 描画対象のデプスバッファのアドレスを直接指定します。 ShadowKind shadowKind; //!< シャドウの種別です。 //! コンストラクタです。 Description() : width(400), height(240), colorFormat(RENDER_COLOR_FORMAT_RGBA8), depthFormat(RENDER_DEPTH_FORMAT_24_STENCIL8), colorArea(MEMORY_AREA_VRAMA), depthArea(MEMORY_AREA_VRAMB), colorAddress(NULL), depthAddress(NULL), shadowKind(SHADOW_KIND_NONE) {} }; //! 描画対象を生成するためのクラスです。 class Builder { public: //! @brief 設定内容を設定します。 //! //! @param[in] description 設定内容です。 //! Builder& Described(const Description& description) { m_Description = description; return *this; } //! @brief 描画バッファのサイズを設定します。 //! //! @param[in] width 描画幅です。 //! @param[in] height 描画高さです。 //! Builder& BufferSize(s32 width, s32 height) { m_Description.width = width; m_Description.height = height; return *this; } //! 描画バッファの幅を設定します。 Builder& Width(s32 width) { m_Description.width = width; return *this; } //! 描画バッファの高さを設定します。 Builder& Height(s32 height) { m_Description.height = height; return *this; } //! 描画バッファの色の形式を設定します。 Builder& ColorFormat(RenderColorFormat format) { m_Description.colorFormat = format; return *this; } //! 描画バッファの深度の形式を設定します。 Builder& DepthFormat(RenderDepthFormat format) { m_Description.depthFormat = format; return *this; } //! @brief カラーバッファのメモリ配置場所を設定します。 //! //! MEMORY_AREA_VRAMA か MEMORY_AREA_VRAMB を設定する必要があります。 Builder& ColorArea(GraphicsMemoryArea memory) { m_Description.colorArea = memory; return *this; } //! @brief デプスバッファのメモリ配置場所を設定します。 //! //! MEMORY_AREA_VRAMA か MEMORY_AREA_VRAMB を設定する必要があります。 Builder& DepthArea(GraphicsMemoryArea memory) { m_Description.depthArea = memory; return *this; } //! @brief カラーバッファのアドレスを直接設定します。 //! //! この値を NULL 以外に設定した場合には、ColorArea の設定は無視します。 Builder& ColorAddress(u32 colorAddress) { m_Description.colorAddress = colorAddress; return *this; } //! @brief デプスバッファのアドレスを直接設定します。 //! //! この値を NULL 以外に設定した場合には、DepthArea の設定は無視します。 Builder& DepthAddress(u32 depthAddress) { m_Description.depthAddress = depthAddress; return *this; } //! @brief レンダーターゲットを生成します。 //! //! @param[in] allocator アロケータです。 //! //! @return 生成したレンダーターゲットを返します。 //! IRenderTarget* Create(os::IAllocator* allocator); private: Description m_Description; }; //! @brief オフスクリーンレンダリング用のレンダーターゲットを生成します。 //! //! @param[in] allocator アロケータです。 //! @param[in] resTexture 描画対象のテクスチャです。 //! //! @return 生成したレンダーターゲットを返します。 static IRenderTarget* CreateOffScreenBuffer(os::IAllocator* allocator, ResTexture resTexture); //@} //---------------------------------------- //! @name 取得/設定 //@{ //! 設定内容を取得します。 virtual const Description& GetDescription() const = 0; //! バッファオブジェクトを取得します。 virtual const FrameBufferObject& GetBufferObject() const = 0; //@} protected: //---------------------------------------- //! @name コンストラクタ/デストラクタ //@{ //! コンストラクタです。 IRenderTarget(os::IAllocator* allocator) : GfxObject(allocator) {} //! デストラクタです。 virtual ~IRenderTarget() {} //@} }; } // namespace gfx } // namespace nw #endif // NW_GFX_IRENDERTARGET_H_