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

Renderer.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 RENDERER_H_
00026 #define RENDERER_H_
00027 
00028 #include <Graphics/System/GraphicsDeviceObjectHolder.h>
00029 #include <Core/Container/ArrayList.h>
00030 
00031 namespace Lamp{
00032 
00033 class DrawRequest;
00034 class Scene;
00035 class Mesh;
00036 
00037 //------------------------------------------------------------------------------
00038 /**
00039  * レンダラ
00040  */
00041 class Renderer : public GraphicsDeviceObjectHolder{
00042 public:
00043     //--------------------------------------------------------------------------
00044     // 定数
00045     //--------------------------------------------------------------------------
00046     /// アルファテストの閾値
00047     static const int alphaTestBorder_ = 127;
00048 
00049     /// ブレンディングアルファテストの閾値
00050     static const int blendingAlphaTestBorder_ = 4;
00051 
00052     /// メッシュリストサイズ初期値
00053     static const int initialMeshListSize = 4096;
00054 
00055     /// 最大アクティブライト数
00056     static const int maxActiveLightCount_ = 8;
00057 
00058     //--------------------------------------------------------------------------
00059     // 生成、破棄
00060     //--------------------------------------------------------------------------
00061     /**
00062      * コンストラクタ
00063      */
00064     Renderer();
00065 
00066     /**
00067      * デストラクタ
00068      */
00069     virtual ~Renderer();
00070 
00071     //--------------------------------------------------------------------------
00072     // レンダリング
00073     //--------------------------------------------------------------------------
00074     /**
00075      * レンダリング準備を行う
00076      * @param scene レンダリングを行うシーン
00077      */
00078     virtual void renderingSetup(Scene* scene);
00079 
00080     /**
00081      * レンダリングを行う
00082      */
00083     virtual void rendering();
00084 
00085     //--------------------------------------------------------------------------
00086     // ソート用コールバック
00087     //--------------------------------------------------------------------------
00088     /**
00089      * メッシュリストのソート
00090      * @param left 左辺値
00091      * @param right 右辺値
00092      * @return 左辺値が右辺値より大きいときは1以上
00093      */
00094     static int sortMeshList(Mesh* const* left, Mesh* const* right);
00095 
00096     //--------------------------------------------------------------------------
00097     // デバイスオブジェクト
00098     //--------------------------------------------------------------------------
00099     /**
00100      * デバイスオブジェクトの初期化
00101      * @return 成功したらtrueを返す
00102      */
00103     virtual bool initializeGraphicsDeviceObjects(){ return true; }
00104 
00105     /**
00106      * デバイスオブジェクトの削除
00107      */
00108     virtual void deleteGraphicsDeviceObjects(){}
00109 
00110     /**
00111      * デバイスオブジェクトのリストア
00112      * @return 成功したらtrueを返す
00113      */
00114     virtual bool restoreGraphicsDeviceObjects(){
00115         buildRendererStateBlock();
00116         return true;
00117     }
00118 
00119     /**
00120      * デバイスオブジェクトの無効化
00121      */
00122     virtual void invalidateGraphicsDeviceObjects(){
00123         SafeRelease(rendererStateBlock_);
00124     }
00125 
00126 protected:
00127     //--------------------------------------------------------------------------
00128     /**
00129      * レンダラステートブロックの構築
00130      */
00131     virtual void buildRendererStateBlock();
00132 
00133     /**
00134      * メッシュリストの構築
00135      */
00136     virtual void buildMeshList();
00137 
00138     /**
00139      * 描画リクエストの初期化
00140      */
00141     virtual void initializeDrawRequest();
00142 
00143     /**
00144      * グローバル設定の初期化
00145      */
00146     virtual void initializeGlobalSettings();
00147 
00148     /// レンダラステートブロック
00149     Direct3DStateBlock* rendererStateBlock_;
00150     /// 描画リクエスト
00151     DrawRequest* drawRequest_;
00152     /// シーン
00153     Scene* scene_;
00154     /// メッシュリスト
00155     ArrayList<Mesh*> meshList_;
00156 
00157 private:
00158     // コピーコンストラクタの隠蔽
00159     Renderer(const Renderer& copy);
00160 
00161     // 代入コピーの隠蔽
00162     void operator =(const Renderer& copy);
00163 
00164 };
00165 
00166 //------------------------------------------------------------------------------
00167 } // End of namespace Lamp
00168 #endif // End of RENDERER_H_
00169 //------------------------------------------------------------------------------

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