changed: gcc8 base update
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMDrawer.h
blob38d58382c46dc1e810137f17aaf5223ebdfe6dfd
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 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 _OSGCSMDRAWER_H_
40 #define _OSGCSMDRAWER_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGCSMDrawerBase.h"
46 #include "OSGRenderAction.h"
48 OSG_BEGIN_NAMESPACE
50 class CSMDrawThread;
52 OSG_GEN_MEMOBJPTR(CSMDrawThread);
54 /*! \brief CSMDrawer class. See \ref
55 PageContribCSMDrawer for a description.
58 class OSG_CONTRIBCSM_DLLMAPPING CSMDrawer : public CSMDrawerBase
60 protected:
62 /*========================== PUBLIC =================================*/
64 public:
66 typedef CSMDrawerBase Inherited;
67 typedef CSMDrawer Self;
69 /*---------------------------------------------------------------------*/
70 /*! \name Sync */
71 /*! \{ */
73 virtual void changed(ConstFieldMaskArg whichField,
74 UInt32 origin,
75 BitVector details );
77 /*! \} */
78 /*---------------------------------------------------------------------*/
79 /*! \name Output */
80 /*! \{ */
82 bool init (void);
83 void endDrawThread (void);
84 void shutdown (void);
85 void joinDrawThread(void);
87 /*! \} */
88 /*---------------------------------------------------------------------*/
89 /*! \name Output */
90 /*! \{ */
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 );
97 #endif
99 void setSyncCount (UInt32 uiSyncCount );
100 void setSwapCount (UInt32 uiSwapCount );
101 void setParallel (bool bParallel );
103 void postSync (void );
105 /*! \} */
106 /*---------------------------------------------------------------------*/
107 /*! \name Output */
108 /*! \{ */
110 virtual void resolveLinks (void);
111 virtual void terminateGLContexts(void);
113 /*! \} */
114 /*---------------------------------------------------------------------*/
115 /*! \name Output */
116 /*! \{ */
118 void frame(Time oTime, UInt32 uiFrame);
120 /*! \} */
121 /*---------------------------------------------------------------------*/
122 /*! \name Init */
123 /*! \{ */
125 virtual FieldContainer *findNamedComponent(const Char8 *szName);
127 /*! \} */
128 /*---------------------------------------------------------------------*/
129 /*! \name Output */
130 /*! \{ */
132 virtual void dump( UInt32 uiIndent = 0,
133 const BitVector bvFlags = 0) const;
135 /*! \} */
136 /*========================= PROTECTED ===============================*/
138 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
150 Lock *_pSyncLock;
151 #endif
153 UInt32 _uiSyncCount;
154 UInt32 _uiSwapCount;
155 bool _bParallel;
156 bool _bRun;
158 /*---------------------------------------------------------------------*/
159 /*! \name Constructors */
160 /*! \{ */
162 CSMDrawer(void);
163 CSMDrawer(const CSMDrawer &source);
165 /*! \} */
166 /*---------------------------------------------------------------------*/
167 /*! \name Destructors */
168 /*! \{ */
170 virtual ~CSMDrawer(void);
172 /*! \} */
173 /*---------------------------------------------------------------------*/
174 /*! \name Init */
175 /*! \{ */
177 void render (void );
179 void runParallel (void );
181 void frameRenderNoFinish(void );
182 void frameFinish (void );
183 void frameExit (void );
185 void setRunning (bool bVal );
187 /*! \} */
188 /*---------------------------------------------------------------------*/
189 /*! \name Init */
190 /*! \{ */
192 static void initMethod(InitPhase ePhase);
194 /*! \} */
195 /*========================== PRIVATE ================================*/
197 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 =================================*/
215 public:
217 OSG_GEN_INTERNAL_MEMOBJPTR(CSMDrawThread);
219 /*---------------------------------------------------------------------*/
220 /*! \name Reference Counting */
221 /*! \{ */
223 static ObjTransitPtr get (Char8 *szName, bool bGlobal);
224 static CSMDrawThread *find(Char8 *szName);
226 /*---------------------------------------------------------------------*/
227 /*! \name Reference Counting */
228 /*! \{ */
230 void setDrawer (CSMDrawer *pDrawer);
231 void setRunning(bool bVal );
233 /*! \} */
234 /*---------------------------------------------------------------------*/
235 /*! \name Constructors */
236 /*! \{ */
238 /*! \} */
239 /*========================= PROTECTED ===============================*/
241 protected:
243 typedef Thread Inherited;
245 static MPThreadType _type;
247 CSMDrawer *_pDrawer;
249 /*---------------------------------------------------------------------*/
250 /*! \name Reference Counting */
251 /*! \{ */
253 static BaseThread *create(const Char8 *szName,
254 UInt32 uiId,
255 bool bGlobal);
257 /*! \} */
258 /*---------------------------------------------------------------------*/
259 /*! \name Constructors */
260 /*! \{ */
262 CSMDrawThread(const Char8 *szName, UInt32 uiId, bool bGlobal);
264 /*! \} */
265 /*---------------------------------------------------------------------*/
266 /*! \name Destructor */
267 /*! \{ */
269 virtual ~CSMDrawThread(void);
271 /*! \} */
272 /*---------------------------------------------------------------------*/
273 /*! \name Destructor */
274 /*! \{ */
276 virtual void workProc(void);
278 /*! \} */
279 /*---------------------------------------------------------------------*/
280 /*! \name Constructors */
281 /*! \{ */
283 /*! \} */
284 /*========================== PRIVATE ================================*/
286 private:
288 /*!\brief prohibit default function (move to 'public' if needed) */
289 CSMDrawThread(const CSMDrawThread &source);
290 void operator =(const CSMDrawThread &source);
293 OSG_END_NAMESPACE
295 #include "OSGCSMDrawerBase.inl"
296 #include "OSGCSMDrawer.inl"
298 #endif /* _OSGCSMDRAWER_H_ */