changed: gcc8 base update
[opensg.git] / Source / System / Window / Passive / OSGPassiveViewport.cpp
blob9db57ddd1392decfe2b7e8e937fca249e2bc0191
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <stdlib.h>
44 #include <stdio.h>
46 #include "OSGConfig.h"
48 #include "OSGGL.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"
57 OSG_USING_NAMESPACE
59 /***************************************************************************\
60 * Description *
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) :
74 Inherited ( ),
75 _pDeactivateTask(NULL)
79 PassiveViewport::PassiveViewport(const PassiveViewport &source) :
80 Inherited (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,
97 UInt32 origin,
98 BitVector details)
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;
115 return;
117 if ( getBackground() == NULL )
119 SWARNING << "Viewport::render: no background!" << std::endl;
120 return;
122 if ( getRoot() == NULL )
124 SWARNING << "Viewport::render: no root!" << std::endl;
125 return;
127 if ( action->getWindow() == NULL)
129 SWARNING << "Viewport::render: no window!" << std::endl;
130 return;
133 Window *pWin = action->getWindow();
135 if((pWin->getDrawMode() & Window::PartitionDrawMask) ==
136 Window::ParallelPartitionDraw)
138 if(_pDeactivateTask == NULL)
140 _pDeactivateTask =
141 new WindowDrawTask(WindowDrawTask::DeactivateAndWait);
144 pWin->_pContextThread->queueTask(_pDeactivateTask);
146 _pDeactivateTask->waitForBarrier();
148 pWin->doActivate();
151 GLint vp[4];
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);
167 #endif
169 Inherited::render(action);
172 bool PassiveViewport::isPassive(void)
174 return true;