1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
45 #include "OSGConfig.h"
47 #include "OSGAction.h"
48 #include "OSGCamera.h"
49 #include "OSGSceneFileHandler.h"
50 #include "OSGVolumeDraw.h"
52 #include "OSGComputeAlgorithm.h"
53 #include "OSGDrawEnv.h"
57 // Documentation for this class is emited in the
58 // OSGComputeAlgorithmBase.cpp file.
59 // To modify it, please change the .fcd file (OSGComputeAlgorithm.fcd) and
60 // regenerate the base file.
62 /*-------------------------------------------------------------------------*/
65 void ComputeAlgorithm::changed(ConstFieldMaskArg whichField
,
69 Inherited::changed(whichField
, origin
, details
);
72 /*-------------------------------------------------------------------------*/
75 void ComputeAlgorithm::dump( UInt32
OSG_CHECK_ARG(uiIndent
),
76 const BitVector
OSG_CHECK_ARG(bvFlags
)) const
78 SLOG
<< "Dump ComputeAlgorithm NI" << std::endl
;
81 /*-------------------------------------------------------------------------*/
84 ComputeAlgorithm::ComputeAlgorithm(void) :
89 ComputeAlgorithm::ComputeAlgorithm(const ComputeAlgorithm
&source
) :
94 /*-------------------------------------------------------------------------*/
97 ComputeAlgorithm::~ComputeAlgorithm(void)
101 /*-------------------------------------------------------------------------*/
105 /*-------------------------------------------------------------------------*/
108 /*-------------------------------------------------------------------------*/
111 void ComputeAlgorithm::initMethod(InitPhase ePhase
)
113 Inherited::initMethod(ePhase
);
115 if(ePhase
== TypeObject::SystemPost
)
122 /*-------------------------------------------------------------------------*/
126 ComputeAlgorithmDrawTask::ComputeAlgorithmDrawTask(UInt32 uiType
) :
131 if(_uiTypeTask
== AlgorithmWithBarrier
)
133 _pBarrier
= Barrier::get(NULL
, false);
134 _pBarrier
->setNumWaitFor(2);
138 ComputeAlgorithmDrawTask::ComputeAlgorithmDrawTask(
139 ComputeAlgorithmP pAlgorithm
,
143 _pAlgorithm(pAlgorithm
),
146 if(_uiTypeTask
== AlgorithmWithBarrier
)
148 _pBarrier
= Barrier::get(NULL
, false);
149 _pBarrier
->setNumWaitFor(2);
153 ComputeAlgorithmDrawTask::~ComputeAlgorithmDrawTask(void)
159 void ComputeAlgorithmDrawTask::execute(HardwareContext
*pContext
,
162 Window
*pWindow
= pEnv
->getWindow();
164 OSG_ASSERT( pWindow
!= NULL
);
165 OSG_ASSERT(_pAlgorithm
);
171 _pAlgorithm
->execute(pContext
, pEnv
);
175 case AlgorithmWithBarrier
:
177 _pAlgorithm
->execute(pContext
, pEnv
);
179 OSG_ASSERT(_pBarrier
!= NULL
);
190 void ComputeAlgorithmDrawTask::activateBarrier(bool bVal
)
194 _uiTypeTask
= AlgorithmWithBarrier
;
196 if(_pBarrier
== NULL
)
198 _pBarrier
= Barrier::get(NULL
, false);
199 _pBarrier
->setNumWaitFor(2);
204 _uiTypeTask
= Algorithm
;
208 void ComputeAlgorithmDrawTask::setAlgorithm(ComputeAlgorithmP pAlgorithm
)
210 _pAlgorithm
= pAlgorithm
;
214 void ComputeAlgorithmDrawTask::waitForBarrier(void)
216 OSG_ASSERT(_uiTypeTask
== AlgorithmWithBarrier
);
217 OSG_ASSERT(_pBarrier
!= NULL
);
222 void ComputeAlgorithmDrawTask::dump(UInt32 uiIndent
)
224 for(UInt32 i
= 0; i
< uiIndent
; ++i
) { fprintf(stderr
, " "); }
225 fprintf(stderr
, "ComputeAlgorithmDrawTask : ");
231 fprintf(stderr
, "Algorithm\n");
235 case AlgorithmWithBarrier
:
237 fprintf(stderr
, "AlgorithmWithBarrier\n");
243 fprintf(stderr
, "Unknown\n");