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

LampGraphics.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  * Lampグラフィックスヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef LAMP_GRAPHICS_H_
00026 #define LAMP_GRAPHICS_H_
00027 
00028 #include <Core/Container/ArrayList.h>
00029 #include <Core/Container/HashMap.h>
00030 #include <Graphics/Scene/Scene.h>
00031 
00032 namespace Lamp{
00033 
00034 class GraphicsDeviceEnumeration;
00035 class GraphicsDeviceSelector;
00036 class GraphicsDeviceSettings;
00037 class GraphicsDevice;
00038 class GraphicsDeviceCapacity;
00039 class RenderingDevice;
00040 class ShaderManager;
00041 class GraphicsDeviceObjectHolder;
00042 class Scene;
00043 
00044 //------------------------------------------------------------------------------
00045 /**
00046  * Lampグラフィックス
00047  */
00048 class LampGraphics{
00049 friend class LampCore;
00050 friend class GraphicsDevice;
00051 public:
00052     /**
00053      * 初期化
00054      */
00055     static void initialize();
00056 
00057     /**
00058      * デバイスの初期化
00059      *
00060      * 列挙の条件設定はデバイス初期化前に行う必要がある。
00061      * デバイスセレクタの設定はデバイス初期化前に行う必要がある。
00062      * @param windowHandle ウィンドウハンドル
00063      * @param startFullscreen フルスクリーンを優先して初期化するならtrue
00064      * @return デバイスの初期化に成功すればtrue
00065      */
00066     static bool initializeDevice(HWND windowHandle, bool startFullscreen);
00067 
00068     /**
00069      * 後始末
00070      */
00071     static void finalize();
00072 
00073     //--------------------------------------------------------------------------
00074     /**
00075      * グラフィックスデバイスセレクタの設定
00076      *
00077      * 設定したセレクタはLampGraphicsによりdeleteされます
00078      * @param selector グラフィックスデバイスセレクタ
00079      */
00080     static void setDeviceSelector(GraphicsDeviceSelector* selector);
00081 
00082     /**
00083      * グラフィックスデバイスセレクタの取得
00084      * @return グラフィックスデバイスセレクタ
00085      */
00086     static GraphicsDeviceSelector* getDeviceSelector(){ return selector_; }
00087 
00088     //--------------------------------------------------------------------------
00089     /**
00090      * ウィンドウハンドルの取得
00091      * @return ウィンドウハンドル
00092      */
00093     static HWND getWindowHandle(){ return windowHandle_; }
00094 
00095     /**
00096      * Direct3Dの取得
00097      * @return Direct3D
00098      */
00099     static Direct3D* getDirect3D(){ return direct3D_; }
00100 
00101     /**
00102      * Direct3Dデバイスの取得
00103      * @return Direct3Dデバイス
00104      */
00105     static Direct3DDevice* getDirect3DDevice(){ return direct3DDevice_; }
00106 
00107     //--------------------------------------------------------------------------
00108     // デバイスオブジェクトホルダ
00109     //--------------------------------------------------------------------------
00110     /**
00111      * デバイスオブジェクトホルダの追加
00112      * @param objectHolder 追加するデバイスオブジェクトホルダ
00113      */
00114     static void addDeviceObjectHolder(GraphicsDeviceObjectHolder* objectHolder){
00115         deviceObjectHolders_.add(objectHolder);
00116     }
00117 
00118     /**
00119      * デバイスオブジェクトホルダの削除
00120      * @param objectHolder 削除するデバイスオブジェクトホルダ
00121      */
00122     static void removeDeviceObjectHolder(
00123         GraphicsDeviceObjectHolder* objectHolder){
00124         deviceObjectHolders_.removeByValue(objectHolder);
00125     }
00126 
00127     /**
00128      * デバイスオブジェクトホルダ数の取得
00129      * @return デバイスオブジェクトホルダ数
00130      */
00131     static int getDeviceObjectHolderCount(){
00132         return deviceObjectHolders_.getCount();
00133     }
00134 
00135     /**
00136      * デバイスオブジェクトホルダの取得
00137      * @param index デバイスオブジェクトホルダのインデクス
00138      * @return デバイスオブジェクトホルダ
00139      */
00140     static GraphicsDeviceObjectHolder* getDeviceObjectHolder(int index){
00141         return deviceObjectHolders_.get(index);
00142     }
00143 
00144     //--------------------------------------------------------------------------
00145     // シーン関係、初期化無しでアクセス可能
00146     //--------------------------------------------------------------------------
00147     /**
00148      * シーンの作成
00149      * @param name 名前
00150      * @return 作成されたシーン
00151      */
00152     static Scene* createScene(const String& name);
00153 
00154     /**
00155      * シーンの破棄
00156      * @param scene 破棄するシーン
00157      */
00158     static void destroyScene(Scene* scene);
00159 
00160     /**
00161      * シーン数の取得
00162      * @return シーン数
00163      */
00164     static int getSceneCount(){ return sceneArray_.getCount(); }
00165 
00166     /**
00167      * シーンの取得
00168      * @param index シーンのインデクス
00169      * @return シーン
00170      */
00171     static Scene* getScene(int index){ return sceneArray_.get(index); }
00172 
00173     /**
00174      * シーンの検索
00175      * @param name 検索するシーン名
00176      * @return シーン
00177      */
00178     static Scene* search(String name){ return sceneDatabase_.get(name); }
00179 
00180     //--------------------------------------------------------------------------
00181 protected:
00182     /**
00183      * ウィンドウプロシージャ
00184      * @param windowHandle ウィンドウハンドル
00185      * @param message メッセージ
00186      * @param wParam wメッセージパラメータ
00187      * @param lParam lメッセージパラメータ
00188      * @return メッセージを処理し、それ以上の処理が必要無いならば0以外を返す。
00189      */
00190     static LRESULT windowProcedure(
00191         HWND windowHandle, u_int message, WPARAM wParam, LPARAM lParam);
00192 
00193     //--------------------------------------------------------------------------
00194     /**
00195      * デバイスがリセットされた
00196      */
00197     static void deviceReset();
00198 
00199     /**
00200      * デバイスオブジェクトの初期化
00201      * @return 成功したらtrueを返す
00202      */
00203     static bool initializeDeviceObjects();
00204 
00205     /**
00206      * デバイスオブジェクトの削除
00207      */
00208     static void deleteDeviceObjects();
00209 
00210     /**
00211      * デバイスオブジェクトのリストア
00212      * @return 成功したらtrueを返す
00213      */
00214     static bool restoreDeviceObjects();
00215 
00216     /**
00217      * デバイスオブジェクトの無効化
00218      */
00219     static void invalidateDeviceObjects();
00220 
00221     //--------------------------------------------------------------------------
00222 private:
00223     // コンストラクタの隠蔽
00224     LampGraphics();
00225 
00226     // ウィンドウハンドル
00227     static HWND windowHandle_;
00228     // グラフィックスデバイスの列挙
00229     static GraphicsDeviceEnumeration* enumeration_;
00230     // グラフィックスデバイスセレクタ
00231     static GraphicsDeviceSelector* selector_;
00232     // グラフィックスデバイス設定
00233     static GraphicsDeviceSettings* settings_;
00234     // グラフィックスデバイス
00235     static GraphicsDevice* device_;
00236     // Direct3Dデバイス
00237     static Direct3DDevice* direct3DDevice_;
00238     // グラフィックスデバイス能力
00239     static GraphicsDeviceCapacity* deviceCapacity_;
00240     // レンダリングデバイス
00241     static RenderingDevice* renderingDevice_;
00242     // シェーダマネージャ
00243     static ShaderManager* shaderManager_;
00244     // Direct3D
00245     static Direct3D* direct3D_;
00246     // デバイスオブジェクトホルダ
00247     static ArrayList<GraphicsDeviceObjectHolder*> deviceObjectHolders_;
00248 
00249     // シーン配列
00250     static ArrayList<Scene*> sceneArray_;
00251     // シーンデータベース
00252     static HashMap<String, Scene*> sceneDatabase_;
00253     // シーンキャパシティ
00254     static const int scenesCapacity_ = 16;
00255 
00256     // 初期化フラグ
00257     static bool isInitialized_;
00258     // デバイス初期化フラグ
00259     static bool deviceInitialized_;
00260 };
00261 
00262 //------------------------------------------------------------------------------
00263 } // End of namespace Lamp
00264 #endif // End of LAMP_GRAPHICS_H_
00265 //------------------------------------------------------------------------------
00266 

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