Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

BasicFramework.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Lamp : Open source game middleware
00003 // Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
00004 //
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //------------------------------------------------------------------------------
00019 
00020 /** @file
00021  * 基本フレームワークヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef BASIC_FRAMEWORK_H_
00026 #define BASIC_FRAMEWORK_H_
00027 
00028 #include <Framework/System/SimpleFramework.h>
00029 
00030 #include <Graphics/System/GraphicsDeviceObjectHolder.h>
00031 #include <Graphics/Enumeration/ConfirmGraphicsDevice.h>
00032 #include <Core/Utility/Timer.h>
00033 
00034 
00035 namespace Lamp{
00036 
00037 class FPSMeasurement;
00038 
00039 //------------------------------------------------------------------------------
00040 /**
00041  * 基本フレームワーク
00042  *
00043  * シンプルフレームワークにID3DXによるフォント描画とFPS計測と
00044  * グラフィックスデバイス選択を追加したフレームワーク。
00045  */
00046 class BasicFramework :
00047     public SimpleFramework, public GraphicsDeviceObjectHolder,
00048     public ConfirmGraphicsDevice{
00049 public:
00050     //--------------------------------------------------------------------------
00051     // 生成、破棄
00052     //--------------------------------------------------------------------------
00053     /**
00054      * コンストラクタ
00055      * @param name アプリケーション名
00056      */
00057     BasicFramework(const String& name);
00058 
00059     /**
00060      * デストラクタ
00061      */
00062     virtual ~BasicFramework();
00063 
00064     //--------------------------------------------------------------------------
00065     // オーバーライドメソッド
00066     //--------------------------------------------------------------------------
00067     /**
00068      * グラフィックスデバイスの確認
00069      *
00070      * デバイスの能力を確認して、使用するならtrue、使用しないならfalseを返す。
00071      * @param deviceCapability デバイス能力
00072      * @param vertexProcessingType 頂点プロセスタイプ
00073      * @param adapterFormat アダプタのフォーマット
00074      * @param backBufferFormat バックバッファのフォーマット
00075      * @return デバイスの使用を許可するならばtrueを返す。
00076      */
00077     virtual bool confirmGraphicsDevice(
00078         const D3DCapacity& deviceCapability, u_int vertexProcessingType,
00079         D3DFORMAT adapterFormat, D3DFORMAT backBufferFormat){
00080         // 全てのデバイスを許可する
00081         return true;
00082     }
00083 
00084     //--------------------------------------------------------------------------
00085     // デバイスオブジェクト関連
00086     //--------------------------------------------------------------------------
00087     /**
00088      * デバイスオブジェクトの初期化
00089      *
00090      * デバイスオブジェクトの初期化はinitializeDeviceObjectsをオーバライドする
00091      * @return 成功したらtrueを返す
00092      */
00093     virtual bool initializeGraphicsDeviceObjects();
00094 
00095     /**
00096      * デバイスオブジェクトの削除
00097      *
00098      * デバイスオブジェクトの削除はdeleteDeviceObjectsをオーバライドする
00099      */
00100     virtual void deleteGraphicsDeviceObjects();
00101 
00102     /**
00103      * デバイスオブジェクトのリストア
00104      *
00105      * デバイスオブジェクトのリストアはrestoreDeviceObjectsをオーバライドする
00106      * このメソッド内ででデバイスステートを変更すると、デフォルトステートとなり、
00107      * レンダラセットアップ時にそのステートが復元されます。
00108      * @return 成功したらtrueを返す
00109      */
00110     virtual bool restoreGraphicsDeviceObjects();
00111 
00112     /**
00113      * デバイスオブジェクトの無効化
00114      *
00115      * デバイスオブジェクトの無効化はinvalidateDeviceObjectsをオーバライドする
00116      */
00117     virtual void invalidateGraphicsDeviceObjects();
00118 
00119 protected:
00120     //--------------------------------------------------------------------------
00121     // オーバーライドメソッド
00122     //--------------------------------------------------------------------------
00123     /**
00124      * メインループ
00125      */
00126     virtual void mainLoop();
00127 
00128     /**
00129      * 情報描画
00130      */
00131     virtual void drawInformation();
00132 
00133     //--------------------------------------------------------------------------
00134     // ユーティリティメソッド
00135     //--------------------------------------------------------------------------
00136     /**
00137      * 情報文字列描画
00138      * @param message 描画するメッセージ
00139      * @param color 文字の描画色
00140      * @param alignRight trueなら右に寄せて描画する
00141      * @param alignBottom trueなら下に寄せて描画する
00142      */
00143     virtual void drawInformationString(const String& message,
00144         Color4c color = Color4c::white,
00145         bool alignRight = false, bool alignBottom = false);
00146 
00147     /**
00148      * FPS文字列の取得
00149      * @return FPS文字列
00150      */
00151     virtual String getFPSString() const;
00152 
00153     //--------------------------------------------------------------------------
00154     // フレームワークメソッド
00155     //--------------------------------------------------------------------------
00156     /**
00157      * フレームワーク実行
00158      */
00159     virtual void frameworkRun();
00160 
00161     /**
00162      * フレームワーク情報表示
00163      */
00164     virtual void frameworkDrawInformation();
00165 
00166     //--------------------------------------------------------------------------
00167     /// 情報描画矩形
00168     RECT informationDrawRect_;
00169     /// フォント
00170     ID3DXFont* font_;
00171     /// フォント記述
00172     D3DXFONT_DESC fontDescription_;
00173 
00174     /// 描画FPS計測
00175     FPSMeasurement* drawFPSMeasurement_;
00176     /// 描画FPS
00177     float drawFPS_;
00178     /// ゲームFPS計測
00179     FPSMeasurement* gameFPSMeasurement_;
00180     /// ゲームFPS
00181     float gameFPS_;
00182 };
00183 
00184 //------------------------------------------------------------------------------
00185 } // End of namespace Lamp
00186 #endif // End of BASIC_FRAMEWORK_H_
00187 //------------------------------------------------------------------------------
00188 

Generated on Wed Mar 16 10:29:27 2005 for Lamp by doxygen 1.3.2