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

GraphicsDevice.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 GRAPHICS_DEVICE_H_
00026 #define GRAPHICS_DEVICE_H_
00027 
00028 namespace Lamp{
00029 
00030 class GraphicsDeviceSettings;
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * グラフィックスデバイス
00035  */
00036 class GraphicsDevice{
00037 friend class LampGraphics;
00038 public:
00039     //--------------------------------------------------------------------------
00040     /**
00041      * インスタンス取得
00042      * @return インスタンス
00043      */
00044     static GraphicsDevice* getInstance(){
00045         Assert(instance_ != NULL);
00046         return instance_;
00047     }
00048 
00049     //--------------------------------------------------------------------------
00050     // デバイス構築オプション
00051     //--------------------------------------------------------------------------
00052     /**
00053      * カーソルクリップの設定
00054      * @param clipFlag trueならカーソルをクリップする
00055      */
00056     void setClipCursor(bool clipFlag){ clipCursor_ = clipFlag; }
00057 
00058     /**
00059      * カーソルクリップの取得
00060      * @return trueならカーソルがクリップされる
00061      */
00062     bool getClipCursor(){ return clipCursor_; }
00063 
00064     //--------------------------------------------------------------------------
00065     // デバイス操作
00066     //--------------------------------------------------------------------------
00067     /**
00068      * クリア
00069      * @param color クリアカラー
00070      * @param zValue Zクリア値
00071      * @param stencilValue ステンシルクリア値
00072      */
00073     void clear(Color4c color = Color4c(0, 0, 0, 0),
00074         float zValue = 1.0f, u_int stencilValue = 0);
00075 
00076     /**
00077      * プレゼンテーション
00078      * @return デバイスがロストしていればtrueを返す
00079      */
00080     bool presentation();
00081 
00082     /**
00083      * フルスクリーンモードとウィンドウモードを切り替える
00084      */
00085     void toggleFullscreen();
00086 
00087     /**
00088      * 強制的にウィンドウモードにする
00089      */
00090     void forceWindowed();
00091 
00092     /**
00093      * デバイスを再構築します
00094      * @return 成功したらtrueを返す
00095      */
00096     bool rebuild();
00097 
00098 protected:
00099     //--------------------------------------------------------------------------
00100     // 初期化、デバイス管理
00101     //--------------------------------------------------------------------------
00102     /**
00103      * コンストラクタ
00104      */
00105     GraphicsDevice();
00106 
00107     /**
00108      * デストラクタ
00109      */
00110     virtual ~GraphicsDevice();
00111 
00112     /**
00113      * ウィンドウハンドルの初期化
00114      * @param windowHandle ウィンドウハンドル
00115      */
00116     void initializeWindowHandle(HWND windowHandle);
00117 
00118     /**
00119      * 初期化
00120      * @return 成功したらtrueを返す
00121      */
00122     bool initialize();
00123 
00124     /**
00125      * リセット
00126      * @return 成功したらtrueを返す
00127      */
00128     bool reset();
00129 
00130     /**
00131      * カーソルのクリップ
00132      */
00133     void clipCursor();
00134 
00135     /**
00136      * 後始末
00137      */
00138     void cleanup();
00139 
00140     /**
00141      * Direct3Dデバイスの取得
00142      * @return Direct3Dデバイス
00143      */
00144     Direct3DDevice* getDirect3DDevice(){ return direct3DDevice_; }
00145 
00146     //--------------------------------------------------------------------------
00147     // ウィンドウ関係
00148     //--------------------------------------------------------------------------
00149     /**
00150      * ウィンドウプロシージャ
00151      * @param windowHandle ウィンドウハンドル
00152      * @param message メッセージ
00153      * @param wParam wメッセージパラメータ
00154      * @param lParam lメッセージパラメータ
00155      */
00156     LRESULT windowProcedure(
00157         HWND windowHandle, u_int message, WPARAM wParam, LPARAM lParam);
00158 
00159     /**
00160      * ウィンドウの調整
00161      */
00162     void adjustWindowForChange();
00163 
00164     /**
00165      * ウィンドウサイズ変更
00166      */
00167     void handlePossibleSizeChange();
00168 
00169     //--------------------------------------------------------------------------
00170 private:
00171     // コピーコンストラクタの隠蔽
00172     GraphicsDevice(const GraphicsDevice& copy);
00173 
00174     // 代入コピーの隠蔽
00175     void operator =(const GraphicsDevice& copy);
00176 
00177     // Direct3Dデバイス
00178     Direct3DDevice* direct3DDevice_;
00179     // プレゼンテーションパラメータ
00180     D3DPRESENT_PARAMETERS presentationParameter_;
00181     // グラフィックスデバイス設定
00182     GraphicsDeviceSettings* settings_;
00183     // ウィンドウハンドル
00184     HWND windowHandle_;
00185     // ウィンドウスタイル
00186     u_int windowStyle_;
00187     // ウィンドウバウンズサイズ
00188     RECT windowBoundsSize_;
00189     // ウィンドウクライアントサイズ
00190     RECT windowClientSize_;
00191     // メニューハンドル
00192     HMENU menuHandle_;
00193 
00194     // デバイスがロストしていないか
00195     bool deviceLost_;
00196     // カーソルをクリップするか
00197     bool clipCursor_;
00198     // 最大化されているかどうか
00199     bool windowMaximized_;
00200     // 最小化されているかどうか
00201     bool windowMinimized_;
00202     // サイズ変更を無視する
00203     bool ignoreSizeChange_;
00204 
00205     // インスタンス
00206     static GraphicsDevice* instance_;
00207 
00208 };
00209 
00210 //------------------------------------------------------------------------------
00211 } // End of namespace Lamp
00212 #endif // End of GRAPHICS_DEVICE_H_
00213 //------------------------------------------------------------------------------
00214 

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