1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGCSMDRAWER_H_
40 #define _OSGCSMDRAWER_H_
45 #include "OSGCSMDrawerBase.h"
46 #include "OSGRenderAction.h"
52 OSG_GEN_MEMOBJPTR(CSMDrawThread
);
54 /*! \brief CSMDrawer class. See \ref
55 PageContribCSMDrawer for a description.
58 class OSG_CONTRIBCSM_DLLMAPPING CSMDrawer
: public CSMDrawerBase
62 /*========================== PUBLIC =================================*/
66 typedef CSMDrawerBase Inherited
;
67 typedef CSMDrawer Self
;
69 /*---------------------------------------------------------------------*/
73 virtual void changed(ConstFieldMaskArg whichField
,
78 /*---------------------------------------------------------------------*/
83 void endDrawThread (void);
85 void joinDrawThread(void);
88 /*---------------------------------------------------------------------*/
92 void setSyncFromThread(Thread
*pThread
);
93 void setSyncBarrier (Barrier
*pSyncBarrier
);
94 void setSwapBarrier (Barrier
*pSwapBarrier
);
95 #ifdef OSG_GLOBAL_SYNC_LOCK
96 void setSyncLock (Lock
*pSyncLock
);
99 void setSyncCount (UInt32 uiSyncCount
);
100 void setSwapCount (UInt32 uiSwapCount
);
101 void setParallel (bool bParallel
);
103 void postSync (void );
106 /*---------------------------------------------------------------------*/
110 virtual void resolveLinks (void);
111 virtual void terminateGLContexts(void);
114 /*---------------------------------------------------------------------*/
118 void frame(Time oTime
, UInt32 uiFrame
);
121 /*---------------------------------------------------------------------*/
125 virtual FieldContainer
*findNamedComponent(const Char8
*szName
);
128 /*---------------------------------------------------------------------*/
132 virtual void dump( UInt32 uiIndent
= 0,
133 const BitVector bvFlags
= 0) const;
136 /*========================= PROTECTED ===============================*/
140 // Variables should all be in CSMDrawerBase.
142 RenderActionRefPtr _pAction
;
144 CSMDrawThreadRefPtr _pDrawThread
;
146 Thread
*_pSyncFromThread
;
147 Barrier
*_pSyncBarrier
;
148 Barrier
*_pSwapBarrier
;
149 #ifdef OSG_GLOBAL_SYNC_LOCK
158 /*---------------------------------------------------------------------*/
159 /*! \name Constructors */
163 CSMDrawer(const CSMDrawer
&source
);
166 /*---------------------------------------------------------------------*/
167 /*! \name Destructors */
170 virtual ~CSMDrawer(void);
173 /*---------------------------------------------------------------------*/
179 void runParallel (void );
181 void frameRenderNoFinish(void );
182 void frameFinish (void );
183 void frameExit (void );
185 void setRunning (bool bVal
);
188 /*---------------------------------------------------------------------*/
192 static void initMethod(InitPhase ePhase
);
195 /*========================== PRIVATE ================================*/
199 friend class FieldContainer
;
200 friend class CSMDrawerBase
;
201 friend class CSMDrawThread
;
203 // prohibit default functions (move to 'public' if you need one)
204 void operator =(const CSMDrawer
&source
);
207 typedef CSMDrawer
*CSMDrawerP
;
210 class OSG_CONTRIBCSM_DLLMAPPING CSMDrawThread
: public Thread
213 /*========================== PUBLIC =================================*/
217 OSG_GEN_INTERNAL_MEMOBJPTR(CSMDrawThread
);
219 /*---------------------------------------------------------------------*/
220 /*! \name Reference Counting */
223 static ObjTransitPtr
get (Char8
*szName
, bool bGlobal
);
224 static CSMDrawThread
*find(Char8
*szName
);
226 /*---------------------------------------------------------------------*/
227 /*! \name Reference Counting */
230 void setDrawer (CSMDrawer
*pDrawer
);
231 void setRunning(bool bVal
);
234 /*---------------------------------------------------------------------*/
235 /*! \name Constructors */
239 /*========================= PROTECTED ===============================*/
243 typedef Thread Inherited
;
245 static MPThreadType _type
;
249 /*---------------------------------------------------------------------*/
250 /*! \name Reference Counting */
253 static BaseThread
*create(const Char8
*szName
,
258 /*---------------------------------------------------------------------*/
259 /*! \name Constructors */
262 CSMDrawThread(const Char8
*szName
, UInt32 uiId
, bool bGlobal
);
265 /*---------------------------------------------------------------------*/
266 /*! \name Destructor */
269 virtual ~CSMDrawThread(void);
272 /*---------------------------------------------------------------------*/
273 /*! \name Destructor */
276 virtual void workProc(void);
279 /*---------------------------------------------------------------------*/
280 /*! \name Constructors */
284 /*========================== PRIVATE ================================*/
288 /*!\brief prohibit default function (move to 'public' if needed) */
289 CSMDrawThread(const CSMDrawThread
&source
);
290 void operator =(const CSMDrawThread
&source
);
295 #include "OSGCSMDrawerBase.inl"
296 #include "OSGCSMDrawer.inl"
298 #endif /* _OSGCSMDRAWER_H_ */