/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_FrameBuffer.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: $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_FRAME_BUFFER_H_ #define NW_GFX_FRAME_BUFFER_H_ #include #include namespace nw { namespace gfx { //--------------------------------------------------------------------------- //! @brief フレームバッファの設定です。 //--------------------------------------------------------------------------- class FrameBufferObject { public: //! @brief 設定内容です。 struct Description { GLuint fboID; //!< フレームバッファオブジェクトのIDを指定します。 u32 height; //!< バッファの高さ情報です。 u32 width; //!< バッファの幅情報です。 u32 colorFormat; //!< カラーバッファのフォーマットです。 u32 depthFormat; //!< デプスバッファのフォーマットです。 u32 colorAddress; //!< カラーバッファのアドレスを指定します。 u32 depthAddress; //!< デプスバッファのアドレスを指定します。 bool useBlock32; //!< ブロック32モードを使用するかどうかを指定します。EarlyDepthTest を使用しない場合は通常 false を設定します。 //! @brief デフォルトコンストラクタです。 Description() { fboID = 0; useBlock32 = false; colorAddress = NULL; depthAddress = NULL; } }; //--------------------------------------------------------------------------- //! @brief 過去互換のための、フレームバッファオブジェクトID へのキャスト演算子です。 //! //! @return gl の FBO を使用している場合は fbo のIDを返します。使用していない場合は 0 を返します。 //--------------------------------------------------------------------------- operator GLuint() const { return m_Description.fboID; } //--------------------------------------------------------------------------- //! @brief フレームバッファ設定を取得します。 //! //! @return フレームバッファの設定情報です。 //--------------------------------------------------------------------------- const Description& GetDescription() const { return m_Description; } Description& GetDescription() { return m_Description; } //--------------------------------------------------------------------------- //! @brief フレームバッファ設定をセットします。 //! //! @param[in] description フレームバッファ設定です。 //--------------------------------------------------------------------------- void SetDescription(const Description& description); //--------------------------------------------------------------------------- //! @brief gl のフレームバッファオブジェクトのIDを取得します。 //! //! @return gl のフレームバッファオブジェクトのIDです。 //--------------------------------------------------------------------------- GLuint GetFboID() const { return m_Description.fboID; } //--------------------------------------------------------------------------- //! @brief gl のフレームバッファオブジェクトのIDを設定します。 //! //! @param[in] fboID gl のフレームバッファオブジェクトのIDです。 //--------------------------------------------------------------------------- void SetFboID(GLuint fboID); //--------------------------------------------------------------------------- //! @brief フレームバッファの高さを取得します。 //! //! @return フーレムバッファの高さです。 //--------------------------------------------------------------------------- u32 GetHeight() const { return m_Description.height; } //--------------------------------------------------------------------------- //! @brief フレームバッファの高さを設定します。 //! //! @param[in] height フレームバッファの高さです。 //--------------------------------------------------------------------------- void SetHeight(u32 height) { m_Description.height = height; } //--------------------------------------------------------------------------- //! @brief フレームバッファの幅を取得します。 //! //! @return フレームバッファの幅です。 //--------------------------------------------------------------------------- u32 GetWidth() const { return m_Description.width; } //--------------------------------------------------------------------------- //! @brief フレームバッファの幅を設定します。 //! //! @param[in] width フレームバッファの幅です。 //--------------------------------------------------------------------------- void SetWidth(u32 width) { m_Description.width = width; } //--------------------------------------------------------------------------- //! @brief カラーバッファのフォーマットを取得します。 //! //! @return カラーバッファのフォーマットです。 //--------------------------------------------------------------------------- u32 GetColorFormat() const { return m_Description.colorFormat; } //--------------------------------------------------------------------------- //! @brief カラーバッファのフォーマットを設定します。 //! //! @param[in] colorFormat カラーバッファのフォーマットです。 //--------------------------------------------------------------------------- void SetColorFormat(u32 colorFormat) { m_Description.colorFormat = colorFormat; } //--------------------------------------------------------------------------- //! @brief デプスバッファのフォーマットを取得します。 //! //! @return デプスバッファのフォーマットです。 //--------------------------------------------------------------------------- u32 GetDepthFormat() const { return m_Description.depthFormat; } //--------------------------------------------------------------------------- //! @brief デプスバッファのフォーマットを設定します。 //! //! @param[in] depthFormat デプスバッファのフォーマットです。 //--------------------------------------------------------------------------- void SetDepthFormat(u32 depthFormat) { m_Description.depthFormat = depthFormat; } //--------------------------------------------------------------------------- //! @brief カラーバッファのアドレスを取得します。 //! //! @return カラーバッファのアドレスです。 //--------------------------------------------------------------------------- u32 GetColorAddress() const { return m_Description.colorAddress; } //--------------------------------------------------------------------------- //! @brief カラーバッファのアドレスを設定します。 //! //! @param[in] colorAddress カラーバッファのアドレスです。 //--------------------------------------------------------------------------- void SetColorAddress(u32 colorAddress) { m_Description.colorAddress = colorAddress; } //--------------------------------------------------------------------------- //! @brief デプスバッファのアドレスを取得します。 //! //! @return デプスバッファのアドレスです。 //--------------------------------------------------------------------------- u32 GetDepthAddress() const { return m_Description.depthAddress; } //--------------------------------------------------------------------------- //! @brief デプスバッファのアドレスを設定します。 //! //! @param[in] depthAddress デプスバッファのアドレスです。 //--------------------------------------------------------------------------- void SetDepthAddress(u32 depthAddress) { m_Description.depthAddress = depthAddress; } //--------------------------------------------------------------------------- //! @brief フレームバッファの設定用コマンドを設定します。 //--------------------------------------------------------------------------- void ActivateBuffer() const; //--------------------------------------------------------------------------- //! @brief フレームバッファからディスプレイバッファへの転送コマンドを設定します。 //! //! @param[in] dstAddress 転送先アドレスです。 //! @param[in] dstFormat 転送先のフォーマットです。 //! @param[in] antiAliasMode アンチエイリアスフィルタのモードです。 //! @param[in] yFlip Yフリップをおこなうかどうかのフラグです。 //--------------------------------------------------------------------------- void TransferRenderImage(u32 dstAddress, GLenum dstFormat, GLenum antiAliasMode, bool yFlip) const { const void* srcAddress = reinterpret_cast(this->GetColorAddress()); const u32 width = this->GetWidth(); const u32 height = this->GetHeight(); const u32 srcFormat = this->GetColorFormat(); nngxAddB2LTransferCommand( srcAddress, width, height, srcFormat, reinterpret_cast(dstAddress), width, height, dstFormat, antiAliasMode, yFlip, 8); } enum { //! カラーバッファをクリアするフラグです。 CLEAR_MASK_COLOR = GL_COLOR_BUFFER_BIT, //! デプスバッファとステンシルバッファをクリアするフラグです。 //! ステンシルバッファ単体でのクリアはできません。 CLEAR_MASK_DEPTH = GL_DEPTH_BUFFER_BIT, //! カラーバッファ、デプスバッファの両方をクリアするフラグです。 CLEAR_MASK_ALL = CLEAR_MASK_COLOR | CLEAR_MASK_DEPTH }; //--------------------------------------------------------------------------- //! @brief フレームバッファのクリアを実行します。 //! //! @details AcitvateFrameBuffer で有効化されているフレームバッファに対して、 //! glClear 相当のクリア処理を実行します。 //! //! @param[in] mask クリアするバッファを指定するマスク値です。 //! @param[in] clearColor クリアカラーです。 //! @param[in] clearDepth クリアデプスです。 //! @param[in] clearStencil クリアステンシル値です。 //--------------------------------------------------------------------------- void ClearBuffer( u32 mask, const ut::FloatColor& clearColor, f32 clearDepth, u8 clearStencil = 0 ) const; void ClearBuffer( const ut::FloatColor& clearColor, f32 clearDepth, u8 clearStencil = 0 ) const { this->ClearBuffer( CLEAR_MASK_ALL, clearColor, clearDepth, clearStencil ); } private: Description m_Description; }; } // namespace gfx } // namespace nw #endif // NW_GFX_ACTIVATE_COMMAND_H_