fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Action / Base / OSGRenderActionBase.h
blob688c123d5ae13c30010c9579e6c8724c2e0e4f4e
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGRENDERACTIONBASE_H_
40 #define _OSGRENDERACTIONBASE_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGBaseTypes.h"
46 #include "OSGAction.h"
47 #include "OSGStatElemTypes.h"
48 #include "OSGFrustumVolume.h"
50 #include "OSGMixinHead.h"
51 #include "OSGDataSlotMixin.h"
52 #include "OSGDataSlotPool.h"
54 #include "OSGRenderPartitionBase.h"
55 #include "OSGRenderPropertiesPool.h"
57 OSG_BEGIN_NAMESPACE
59 class DrawEnv;
60 class Viewarea;
61 class Camera;
62 class Background;
63 class Window;
64 class StatCollector;
65 class Material;
66 class TraversalValidator;
68 template <class ParentT>
69 class StageHandlerMixin;
71 /*! \ingroup GrpSystemActionBase
72 \ingroup GrpLibOSGSystem
73 \nohierarchy
76 struct RenderDataSlotDesc
78 typedef Action ParentT;
79 typedef MFUnrecFieldContainerPtr DataStore;
81 typedef ActionDataSlotPool DataSlotIdPool;
84 static void dumpElement(const FieldContainer *pVal)
86 fprintf(stderr, "%p", static_cast<const void *>(pVal));
88 if(pVal != NULL)
90 fprintf(stderr, " (%s)", pVal->getType().getCName());
95 /*! \ingroup GrpSystemActionBase
98 typedef DataSlotMixin<
99 MixinHead <
100 RenderDataSlotDesc > > RenderActionBaseParent;
104 /*! \brief Base class using the render action interface of window
105 \ingroup GrpSystemActionBase
106 \ingroup GrpLibOSGSystem
109 class OSG_SYSTEM_DLLMAPPING RenderActionBase : public RenderActionBaseParent
111 /*========================== PUBLIC =================================*/
113 public:
115 typedef RenderActionBaseParent Inherited;
116 typedef RenderPropertiesPool::Singleton::ValueType RenderPropType;
118 static StatElemDesc<StatTimeElem> statTravTime;
119 // static StatElemDesc<StatIntElem> statCullTestedNodes;
120 // static StatElemDesc<StatIntElem> statCulledNodes;
123 /*---------------------------------------------------------------------*/
124 /*! \name Rendering Environment */
125 /*! \{ */
127 Viewarea *getViewarea (void ) const;
128 void setViewarea (Viewarea *pViewarea );
130 Node *getTraversalRoot (void ) const;
131 void setTraversalRoot (Node *pTravRoot );
133 Camera *getCamera (void ) const;
134 void setCamera (Camera *pCamera );
136 Background *getBackground (void ) const;
137 void setBackground (Background *pBackground);
139 Window *getWindow (void ) const;
140 void setWindow (Window *pWindow );
142 Material *getGlobalOverride(void ) const;
143 void setGlobalOverride(Material *pMat );
145 /*! \} */
146 /*---------------------------------------------------------------------*/
147 /*! \name Statistics */
148 /*! \{ */
150 StatCollector *getStatCollector (void ) const;
151 void setStatCollector (StatCollector *pStat);
153 bool getResetStatistics(void ) const;
154 void setResetStatistics(bool value);
156 /*! \} */
157 /*---------------------------------------------------------------------*/
158 /*! \name Culling */
159 /*! \{ */
161 // control activation of frustum culling
162 virtual bool getFrustumCulling (void ) const;
163 virtual void setFrustumCulling (bool val = true );
165 virtual bool getCorrectTwoSidedLighting(void ) const;
166 virtual void setCorrectTwoSidedLighting(bool val = true );
168 // control drawing of checked volumes
169 virtual bool getVolumeDrawing (void ) const;
170 virtual void setVolumeDrawing (bool val = false);
172 virtual bool getZWriteTrans (void ) const;
173 virtual void setZWriteTrans (bool val = false);
175 // control automatic frustum calculation
176 bool getAutoFrustum (void ) const;
177 void setAutoFrustum (bool val = true );
179 // control frustum
180 virtual const FrustumVolume &getFrustum (void ) const;
181 virtual void setFrustum (FrustumVolume &frust);
184 /*----------- multi-frame buffering / split cull/draw -------------------*/
186 void setUseGLFinish(bool bVal);
187 bool getUseGLFinish(void );
189 /*! \} */
190 /*---------------------------------------------------------------------*/
191 /*! \name Lights */
192 /*! \{ */
194 virtual Action::ResultE start (void );
195 virtual Action::ResultE stop (Action::ResultE res);
197 virtual void frameInit(void );
199 /*! \} */
200 /*---------------------------------------------------------------------*/
201 /*! \name Lights */
202 /*! \{ */
204 TraversalValidator *getTravValidator (void );
205 UInt16 getFrameTravCount(void );
207 void setDrawerId (Int32 iId);
208 void setDrawableId (Int32 iId);
210 /*! \} */
211 /*---------------------------------------------------------------------*/
212 /*! \name Lights */
213 /*! \{ */
215 RenderPropType getRenderProperties (void );
216 void setRenderProperties (RenderPropType oProp);
217 void resetRenderProperties(void );
219 void addRenderProperties (RenderPropType oProp);
220 void subRenderProperties (RenderPropType oProp);
223 void setDrawPartPar (bool bVal );
224 bool getDrawPartPar (void );
226 /*! \} */
227 /*---------------------------------------------------------------------*/
228 /*! \name Lights */
229 /*! \{ */
231 // tmp for testing
232 virtual Int32 getActivePartitionIdx(void )= 0;
233 virtual Int32 getLastPartitionIdx (void )= 0;
235 virtual void readdPartitionByIndex(UInt32 uiPartIdx )= 0;
237 /*! \} */
238 /*========================= PROTECTED ===============================*/
240 protected:
242 template <class ParentT>
243 friend class StageHandlerMixin;
245 friend class Viewport;
247 /*---------------------------------------------------------------------*/
248 /*! \name Constructors */
249 /*! \{ */
251 RenderActionBase(void);
252 RenderActionBase(const RenderActionBase &source);
254 /*! \} */
255 /*---------------------------------------------------------------------*/
256 /*! \name Destructor */
257 /*! \{ */
259 virtual ~RenderActionBase(void);
261 /*! \} */
262 /*---------------------------------------------------------------------*/
263 /*! \name Internal updates */
264 /*! \{ */
266 // tmp for testing
267 virtual void pushPartition (UInt32 uiCopyOnPush,
268 RenderPartitionBase::Mode eMode )= 0;
270 virtual void popPartition (void )= 0;
272 virtual void beginPartitionGroup (void )= 0;
273 virtual void endPartitionGroup (void )= 0;
275 /*! \} */
276 /*---------------------------------------------------------------------*/
277 /*! \name Internal updates */
278 /*! \{ */
280 Int32 getDrawerId (void);
281 Int32 getDrawableId(void);
283 /*! \} */
284 //-----------------------------------------------------------------------
285 // instance variables
286 //-----------------------------------------------------------------------
288 Camera *_pCamera;
289 Background *_pBackground;
290 Window *_pWindow;
291 Viewarea *_pViewarea;
292 Node *_pTraversalRoot;
293 Material *_pGlobalOverride;
295 StatCollector *_pStatistics;
296 TraversalValidator *_pTravValidator;
298 bool _bResetStatistics;
299 bool _bUseGLFinish;
301 // frustum culling attributes
303 bool _bFrustumCulling;
304 bool _bVolumeDrawing;
305 bool _bZWriteTrans;
306 bool _bAutoFrustum;
307 bool _bCorrectTwoSidedLighting;
309 FrustumVolume _oFrustum;
311 UInt16 _uiFrameTravCount;
313 Int32 _iDrawerId;
314 Int32 _iDrawableId;
316 RenderPropType _oCurrentRenderProp;
317 bool _bDrawPartPar;
319 /*========================== PRIVATE ================================*/
321 private:
323 /*!\brief prohibit default function (move to 'public' if needed) */
324 void operator =(const RenderActionBase &source);
328 OSG_END_NAMESPACE
330 #include "OSGRenderActionBase.inl"
332 #endif /* _OSGRENDERACTIONBASE_H_ */