ScummVM API documentation
RenderList.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_RENDER_LIST_H
29 #define HPL_RENDER_LIST_H
30 
31 #include "hpl1/engine/graphics/GraphicsTypes.h"
32 #include "hpl1/engine/graphics/Material.h"
33 #include "hpl1/engine/graphics/OcclusionQuery.h"
34 #include "hpl1/engine/graphics/VertexBuffer.h"
35 #include "hpl1/engine/math/MathTypes.h"
36 #include "hpl1/engine/scene/Light3D.h"
37 #include "hpl1/engine/system/SystemTypes.h"
38 #include "hpl1/std/multiset.h"
39 #include "hpl1/std/set.h"
40 
41 namespace hpl {
42 
43 class iRenderable;
44 class cCamera3D;
45 class cGraphics;
46 
47 class iRenderState;
48 class cRenderSettings;
49 
50 //-------------------------------------------------------------
51 
52 enum eRenderListDrawType {
53  eRenderListDrawType_Normal,
54  eRenderListDrawType_Trans,
55  eRenderListDrawType_LastEnum
56 };
57 
58 //-------------------------------------------------------------
59 
60 class cRenderNode;
61 
63 public:
64  bool operator()(cRenderNode *apNodeA, cRenderNode *apNodeB) const;
65 };
66 
68 typedef tRenderNodeSet::iterator tRenderNodeSetIt;
69 
70 class cRenderNode {
71 public:
72  cRenderNode() : mpState(NULL) {}
73 
74  iRenderState *mpState;
75 
76  tRenderNodeSet m_setNodes;
77 
78  void DeleteChildren();
79  void Render(cRenderSettings *apSettings);
80 };
81 
82 //-------------------------------------------------------------
83 
85 public:
86  bool operator()(iRenderable *pObjectA, iRenderable *pObjectB) const;
87 };
88 
90 typedef tMotionBlurObjectSet::iterator tMotionBlurObjectSetIt;
91 
92 typedef cSTLIterator<iRenderable *, tMotionBlurObjectSet,
93  tMotionBlurObjectSetIt>
95 
96 //-------------------------------------------------------------
97 
99 public:
100  bool operator()(iRenderable *pObjectA, iRenderable *pObjectB) const;
101 };
102 
104 typedef tTransperantObjectSet::iterator tTransperantObjectSetIt;
105 
107 
108 //-------------------------------------------------------------
109 
111 public:
112  cOcclusionQueryObject() : mpQuery(NULL), mpVtxBuffer(NULL), mpMatrix(NULL) {}
113 
114  iOcclusionQuery *mpQuery;
115  iVertexBuffer *mpVtxBuffer;
116  cMatrixf *mpMatrix;
117  bool mbDepthTest;
118 };
119 
121 public:
122  bool operator()(const cOcclusionQueryObject *pObjectA, const cOcclusionQueryObject *pObjectB) const;
123 };
124 
126 typedef tOcclusionQueryObjectSet::iterator tOcclusionQueryObjectSetIt;
127 
128 typedef cSTLIterator<cOcclusionQueryObject *, tOcclusionQueryObjectSet,
129  tOcclusionQueryObjectSetIt>
131 
132 //-------------------------------------------------------------
133 
135 typedef tRenderableSet::iterator tRenderableSetIt;
136 
138 typedef tLight3DSet::iterator tLight3DSetIt;
139 
142 
143 //-------------------------------------------------------------
144 
145 class cRenderList {
146 public:
147  cRenderList(cGraphics *apGraphics);
148  ~cRenderList();
149 
150  void SetCamera(cCamera3D *apCamera) { mpCamera = apCamera; }
151  cCamera3D *GetCamera() { return mpCamera; }
152 
153  bool Add(iRenderable *apObject);
154  void Clear();
155 
156  void AddOcclusionQuery(cOcclusionQueryObject *apObject);
157 
158  cOcclusionQueryObjectIterator GetQueryIterator();
159 
160  cMotionBlurObjectIterator GetMotionBlurIterator();
161 
162  cTransperantObjectIterator GetTransperantIterator();
163 
164  cLight3DIterator GetLightIt();
165  cRenderableIterator GetObjectIt();
166 
167  int GetLightNum();
168  int GetObjectNum();
169 
170  void Compile();
171 
172  int GetRenderCount() { return mlRenderCount; }
173  int GetLastRenderCount() { return mlLastRenderCount; }
174 
175  int GetLightObjects(int alLightIdx) { return mvObjectsPerLight[alLightIdx]; }
176 
177  void SetFrameTime(float afTime) { mfFrameTime = afTime; }
178 
179  cRenderNode *GetRootNode(eRenderListDrawType aObjectType, eMaterialRenderType aPassType, int alLightNum);
180 
181  static inline int GetGlobalRenderCount() { return mlGlobalRenderCount; }
182 
183 private:
184  cRenderNode *InsertNode(cRenderNode *apListNode, cRenderNode *apTempNode);
185 
186  void AddToTree(iRenderable *apObject, eRenderListDrawType aObjectType,
187  eMaterialRenderType mPassType, int alLightNum, iLight3D *apLight,
188  bool abUseDepth, int alPass);
189 
190  static int mlGlobalRenderCount;
191 
192  tLight3DSet m_setLights;
193  int mvObjectsPerLight[MAX_NUM_OF_LIGHTS];
194 
195  tRenderableSet m_setObjects;
196 
197  tOcclusionQueryObjectSet m_setQueries;
198 
199  tMotionBlurObjectSet m_setMotionBlurObjects;
200  tTransperantObjectSet m_setTransperantObjects;
201 
202  cRenderNode mRootNodeDepth;
203  cRenderNode mRootNodeDiffuse;
204  cRenderNode mRootNodeLight[MAX_NUM_OF_LIGHTS];
205  cRenderNode mRootNodeTrans;
206 
207  cRenderNode mTempNode;
208 
209  int mlRenderCount;
210  int mlLastRenderCount;
211 
212  float mfFrameTime;
213 
214  cMemoryPool<iRenderState> *m_poolRenderState;
215  cMemoryPool<cRenderNode> *m_poolRenderNode;
216 
217  cCamera3D *mpCamera;
218 
219  cGraphics *mpGraphics;
220 };
221 
222 } // namespace hpl
223 
224 #endif // HPL_RENDER_LIST_H
Definition: AI.h:36
Definition: RenderList.h:120
Definition: Renderer3D.h:77
Definition: SystemTypes.h:262
Definition: RenderState.h:62
Definition: VertexBuffer.h:90
Definition: Light3D.h:117
Definition: RenderList.h:84
Definition: RenderList.h:70
Definition: Renderable.h:70
Definition: RenderList.h:62
Definition: SystemTypes.h:411
Definition: RenderList.h:145
Definition: OcclusionQuery.h:33
Definition: RenderList.h:98
Definition: RenderList.h:110
Definition: Graphics.h:46
Definition: Camera3D.h:53