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 "OSGFBOViewport.h"
50 #include "OSGFrameBufferObject.h"
51 #include "OSGDrawEnv.h"
53 #include "OSGCamera.h"
54 #include "OSGBackground.h"
55 #include "OSGWindow.h"
56 #include "OSGFrameBufferAttachment.h"
60 // Documentation for this class is emited in the
61 // OSGFBOViewportBase.cpp file.
62 // To modify it, please change the .fcd file (OSGFBOViewport.fcd) and
63 // regenerate the base file.
65 Int32
FBOViewport::computePixelLeft(void) const
68 return Int32(getLeft());
70 if(getFrameBufferObject() == NULL
)
71 return Int32(getLeft());
73 return Int32(getFrameBufferObject()->getWidth() * getLeft());
76 Int32
FBOViewport::computePixelRight(void) const
80 return Int32(getRight());
82 if(getFrameBufferObject() == NULL
)
83 return Int32(getRight());
85 // <=1: partial screen, use 1 less to not overlap other windows
86 return Int32(getFrameBufferObject()->getWidth() * getRight() - 1);
89 Int32
FBOViewport::computePixelBottom(void) const
92 return Int32(getBottom());
94 if(getFrameBufferObject() == NULL
)
95 return Int32(getBottom());
97 return Int32(getFrameBufferObject()->getHeight() * getBottom());
100 Int32
FBOViewport::computePixelTop(void) const
104 return Int32(getTop());
106 if(getFrameBufferObject() == NULL
)
107 return Int32(getTop());
109 // <=1: partial screen, use 1 less to not overlap other windows
110 return Int32(getFrameBufferObject()->getHeight() * getTop() - 1);
113 bool FBOViewport::computeIsFullWindow(void) const
115 if(getFrameBufferObject() == NULL
)
119 computePixelBottom() == 0 &&
120 computePixelLeft() == 0 &&
121 computePixelTop() == getFrameBufferObject()->getHeight() - 1 &&
122 computePixelRight() == getFrameBufferObject()->getWidth () - 1;
125 /*----------------------- constructors & destructors ----------------------*/
127 FBOViewport::FBOViewport(void) :
132 FBOViewport::FBOViewport(const FBOViewport
&source
) :
137 FBOViewport::~FBOViewport(void)
141 /*----------------------------- class specific ----------------------------*/
143 void FBOViewport::initMethod(InitPhase ePhase
)
145 Inherited::initMethod(ePhase
);
148 void FBOViewport::changed(ConstFieldMaskArg whichField
,
152 Inherited::changed(whichField
, origin
, details
);
155 void FBOViewport::dump( UInt32
,
156 const BitVector
) const
158 SLOG
<< "Dump DBOViewport NI" << std::endl
;
162 FrameBufferObject
*FBOViewport::getTarget(void)
164 return this->getFrameBufferObject();
167 #ifdef OSG_OLD_RENDER_ACTION
168 void FBOViewport::render(DrawActionBase
*action
)
170 if(getFrameBufferObject() != NULL
)
173 oEnv
.setWindow(action
->getWindow());
175 getFrameBufferObject()->activate(&oEnv
);
177 Inherited::render(action
);
179 getFrameBufferObject()->deactivate(&oEnv
);
183 Inherited::render(action
);