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 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
49 #include "OSGCamera.h"
50 #include "OSGBackground.h"
51 #include "OSGForeground.h"
52 #include "OSGPassiveViewport.h"
54 #include "OSGRenderActionBase.h"
55 #include "OSGPassiveWindow.h"
59 /***************************************************************************\
61 \***************************************************************************/
63 /*! \class OSG::PassiveViewport
64 \ingroup GrpSystemWindowViewports
66 A PassiveViewport is a basic Viewport for integration into other OpenGL
67 programs. See \ref PageSystemWindowViewports for a description.
71 /*----------------------- constructors & destructors ----------------------*/
73 PassiveViewport::PassiveViewport(void) :
75 _pDeactivateTask(NULL
)
79 PassiveViewport::PassiveViewport(const PassiveViewport
&source
) :
81 _pDeactivateTask(NULL
)
85 PassiveViewport::~PassiveViewport(void)
87 _pDeactivateTask
= NULL
;
90 /*----------------------------- class specific ----------------------------*/
92 void PassiveViewport::initMethod (InitPhase ePhase
)
96 void PassiveViewport::changed(ConstFieldMaskArg whichField
,
100 Inherited::changed(whichField
, origin
, details
);
103 void PassiveViewport::dump( UInt32
,
104 const BitVector
) const
106 SLOG
<< "Dump PassiveViewport NI" << std::endl
;
109 void PassiveViewport::render(RenderActionBase
*action
)
111 #if 1 // Have to check GV
112 if ( getCamera() == NULL
)
114 SWARNING
<< "Viewport::render: no camera!" << std::endl
;
117 if ( getBackground() == NULL
)
119 SWARNING
<< "Viewport::render: no background!" << std::endl
;
122 if ( getRoot() == NULL
)
124 SWARNING
<< "Viewport::render: no root!" << std::endl
;
127 if ( action
->getWindow() == NULL
)
129 SWARNING
<< "Viewport::render: no window!" << std::endl
;
133 Window
*pWin
= action
->getWindow();
135 if((pWin
->getDrawMode() & Window::PartitionDrawMask
) ==
136 Window::ParallelPartitionDraw
)
138 if(_pDeactivateTask
== NULL
)
141 new WindowDrawTask(WindowDrawTask::DeactivateAndWait
);
144 pWin
->_pContextThread
->queueTask(_pDeactivateTask
);
146 _pDeactivateTask
->waitForBarrier();
153 glGetIntegerv(GL_VIEWPORT
, vp
);
155 setLeft (Real32(vp
[0]) );
156 setBottom (Real32(vp
[1]) );
157 setRight (Real32(vp
[0] + vp
[2] - 1));
158 setTop (Real32(vp
[1] + vp
[3] - 1));
160 if((pWin
->getDrawMode() & Window::PartitionDrawMask
) ==
161 Window::ParallelPartitionDraw
)
163 pWin
->doDeactivate();
165 pWin
->_pContextThread
->queueTask(pWin
->_pActivateTask
);
169 Inherited::render(action
);
172 bool PassiveViewport::isPassive(void)