/*---------------------------------------------------------------------------* Project: NintendoWare File: demo_SimpleApp.h 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: 23844 $ *---------------------------------------------------------------------------*/ #ifndef NW_DEMO_SIMPLEAPP_H_ #define NW_DEMO_SIMPLEAPP_H_ #include #include #include #include namespace nw { namespace demo { //--------------------------------------------------------------------------- //! @brief シンプルアプリケーションです。 //--------------------------------------------------------------------------- class SimpleApp { public: //! @brief 描画する画面の定義です。 enum Display { DISPLAY0, //!< 画面0です。 DISPLAY1, //!< 画面1です。 DISPLAY_BOTH, //!< 画面0と画面1です。 DISPLAY_MAX //!< (列挙値の数です。) }; //! @brief 画面のサイズの定数です。 enum DisplaySize { DISPLAY0_WIDTH = 400, //!< 画面0の幅です。 DISPLAY0_HEIGHT = 240, //!< 画面0の高さです。 DISPLAY1_WIDTH = 320, //!< 画面1の幅です。 DISPLAY1_HEIGHT = 240 //!< 画面1の高さです。 }; //! @brief インスタンスを取得します。 //! //! @return シングルトンのインスタンスを返します。 static SimpleApp& GetInstance() { static SimpleApp s_Instance; return s_Instance; } //! //! @brief 初期化を行います。 //! void Initialize(); //---------------------------------------- //! @name 描画 //@{ //! //! @brief レンダーターゲットを設定します。 //! //! @details //! display には DISPLAY0 か DISPLAY1 が指定できます。 //! ( DISPLAY_BOTH は指定できません。) //! //! @param[in] display ターゲットにするディスプレイです。 //! void SetRenderingTarget(Display display); //! //! @brief 設定されているレンダーターゲットのフレームバッファオブジェクトを取得します。 //! //! @return フレームバッファオブジェクトへの参照を返します。 //! const gfx::FrameBufferObject& GetFrameBufferObject() const; //! //! @brief レンダーバッファからディスプレイバッファに表示します。 //! //! @param[in] display 表示するディスプレイです。 //! void SwapBuffer(Display display); //@} //! //! @brief 終了処理を行います。 //! void Finalize(); //---------------------------------------- //! @name メモリ確保/解放 //@{ //! //! @brief メインメモリからメモリを確保します //! //! @param[in] size 確保するサイズです。 //! @param[in] alignment 確保するメモリのアライメントです。 //! //! @return 確保したメモリへのアドレスを返します。 //! static void* Allocate(size_t size, u8 alignment = 4); //! //! @brief デバイスメモリからメモリを確保します //! //! @param[in] size 確保するサイズです。 //! @param[in] alignment 確保するメモリのアライメントです。 //! //! @return 確保したメモリへのアドレスを返します。 //! static void* AllocateDeviceMemory(size_t size, u8 alignment = 4); //! //! @brief メモリを解放します //! //! @param[in] ptr 解放するメモリへのアドレスです。 //! メインメモリとデバイスメモリは区別せずに解放できます。 //! static void Free(void* ptr); //! //! @brief メモリアロケータを取得します。 //! //! @return メモリアロケータを返します。 //! nw::os::IAllocator& GetAllocator() { return m_DeviceAllocator; } //! //! @brief デバイスメモリアロケータを取得します。 //! //! @return デバイスメモリアロケータを返します。 //! nw::os::IAllocator& GetDeviceAllocator() { return m_DeviceAllocator; } //@} Display m_CurrentDisplay; nw::demo::RenderSystem* m_pRenderSystem; nw::gfx::IRenderTarget* m_pRenderTargetUpper; nw::gfx::IRenderTarget* m_pRenderTargetLower; nw::demo::DemoAllocator m_DeviceAllocator; protected: //! //! @brief コンストラクタです。 //! //! 継承した場合はSimpleApp::GetInstance()は使えません。 //! SimpleApp() { if (s_pInstance != NULL) { NW_FATAL_ERROR("nw::demo::SimpleApp instance already exists."); } s_pInstance = this; } //! //! @brief 現在のバッファ内容を転送します。 //! void TransferBuffer(); //! シングルトンオブジェクトへのポインタです。 static SimpleApp* s_pInstance; }; } /* namespace demo */ } /* namespace nw */ #endif /* NW_DEMO_SIMPLEAPP_H_ */