#include <OSGViewport.h>
Inheritance diagram for osg::Viewport:

Public Types | |
| typedef ViewportPtr | Ptr |
| enum | { LeftFieldId = Inherited::NextFieldId, RightFieldId = LeftFieldId + 1, BottomFieldId = RightFieldId + 1, TopFieldId = BottomFieldId + 1, ParentFieldId = TopFieldId + 1, CameraFieldId = ParentFieldId + 1, RootFieldId = CameraFieldId + 1, BackgroundFieldId = RootFieldId + 1, ForegroundsFieldId = BackgroundFieldId + 1, TravMaskFieldId = ForegroundsFieldId + 1, DrawTimeFieldId = TravMaskFieldId + 1, NextFieldId = DrawTimeFieldId + 1 } |
Public Member Functions | |
access | |
| *void | setSize (Real32 left, Real32 bottom, Real32 right, Real32 top) |
| Int32 | getPixelLeft (void) const |
| Int32 | getPixelRight (void) const |
| Int32 | getPixelBottom (void) const |
| Int32 | getPixelTop (void) const |
| Int32 | getPixelWidth (void) const |
| Int32 | getPixelHeight (void) const |
| bool | isFullWindow (void) const |
your_category | |
| *virtual void | draw (DrawAction *action) |
| virtual void | render (RenderActionBase *action) |
change | |
| *virtual void | changed (BitVector whichField, UInt32 origin) |
dump | |
| *virtual void | dump (UInt32 uiIndent=0, const BitVector bvFlags=0) const |
FieldContainer Get | |
| *virtual FieldContainerType & | getType (void) |
| virtual const FieldContainerType & | getType (void) const |
| virtual UInt32 | getContainerSize (void) const |
Field Get | |
| *SFReal32 * | getSFLeft (void) |
| Get the Viewport::_sfLeft field. | |
| SFReal32 * | getSFRight (void) |
| Get the Viewport::_sfRight field. | |
| SFReal32 * | getSFBottom (void) |
| Get the Viewport::_sfBottom field. | |
| SFReal32 * | getSFTop (void) |
| Get the Viewport::_sfTop field. | |
| SFWindowPtr * | getSFParent (void) |
| Get the Viewport::_sfParent field. | |
| SFCameraPtr * | getSFCamera (void) |
| Get the Viewport::_sfCamera field. | |
| SFNodePtr * | getSFRoot (void) |
| Get the Viewport::_sfRoot field. | |
| SFBackgroundPtr * | getSFBackground (void) |
| Get the Viewport::_sfBackground field. | |
| MFForegroundPtr * | getMFForegrounds (void) |
| Get the Viewport::_mfForegrounds field. | |
| SFUInt32 * | getSFTravMask (void) |
| Get the Viewport::_sfTravMask field. | |
| SFReal32 * | getSFDrawTime (void) |
| Get the Viewport::_sfDrawTime field. | |
| Real32 & | getLeft (void) |
| Get the value of the Viewport::_sfLeft field. | |
| const Real32 & | getLeft (void) const |
| Get the value of the Viewport::_sfLeft field. | |
| Real32 & | getRight (void) |
| Get the value of the Viewport::_sfRight field. | |
| const Real32 & | getRight (void) const |
| Get the value of the Viewport::_sfRight field. | |
| Real32 & | getBottom (void) |
| Get the value of the Viewport::_sfBottom field. | |
| const Real32 & | getBottom (void) const |
| Get the value of the Viewport::_sfBottom field. | |
| Real32 & | getTop (void) |
| Get the value of the Viewport::_sfTop field. | |
| const Real32 & | getTop (void) const |
| Get the value of the Viewport::_sfTop field. | |
| WindowPtr & | getParent (void) |
| Get the value of the Viewport::_sfParent field. | |
| const WindowPtr & | getParent (void) const |
| Get the value of the Viewport::_sfParent field. | |
| CameraPtr & | getCamera (void) |
| Get the value of the Viewport::_sfCamera field. | |
| const CameraPtr & | getCamera (void) const |
| Get the value of the Viewport::_sfCamera field. | |
| NodePtr & | getRoot (void) |
| Get the value of the Viewport::_sfRoot field. | |
| const NodePtr & | getRoot (void) const |
| Get the value of the Viewport::_sfRoot field. | |
| BackgroundPtr & | getBackground (void) |
| Get the value of the Viewport::_sfBackground field. | |
| const BackgroundPtr & | getBackground (void) const |
| Get the value of the Viewport::_sfBackground field. | |
| UInt32 & | getTravMask (void) |
| Get the value of the Viewport::_sfTravMask field. | |
| const UInt32 & | getTravMask (void) const |
| Get the value of the Viewport::_sfTravMask field. | |
| Real32 & | getDrawTime (void) |
| Get the value of the Viewport::_sfDrawTime field. | |
| const Real32 & | getDrawTime (void) const |
| Get the value of the Viewport::_sfDrawTime field. | |
| ForegroundPtr & | getForegrounds (const UInt32 index) |
| Get the value of the index element the Viewport::_mfForegrounds field. | |
| MFForegroundPtr & | getForegrounds (void) |
| Get the Viewport::_mfForegrounds field. | |
| const MFForegroundPtr & | getForegrounds (void) const |
| Get the Viewport::_mfForegrounds field. | |
Field Set | |
| *void | setLeft (const Real32 &value) |
| Set the value of the Viewport::_sfLeft field. | |
| void | setRight (const Real32 &value) |
| Set the value of the Viewport::_sfRight field. | |
| void | setBottom (const Real32 &value) |
| Set the value of the Viewport::_sfBottom field. | |
| void | setTop (const Real32 &value) |
| Set the value of the Viewport::_sfTop field. | |
| void | setParent (const WindowPtr &value) |
| Set the value of the Viewport::_sfParent field. | |
| void | setCamera (const CameraPtr &value) |
| Set the value of the Viewport::_sfCamera field. | |
| void | setRoot (const NodePtr &value) |
| Set the value of the Viewport::_sfRoot field. | |
| void | setBackground (const BackgroundPtr &value) |
| Set the value of the Viewport::_sfBackground field. | |
| void | setTravMask (const UInt32 &value) |
| Set the value of the Viewport::_sfTravMask field. | |
| void | setDrawTime (const Real32 &value) |
| Set the value of the Viewport::_sfDrawTime field. | |
Binary Access | |
| *virtual UInt32 | getBinSize (const BitVector &whichField) |
| virtual void | copyToBin (BinaryDataHandler &pMem, const BitVector &whichField) |
| virtual void | copyFromBin (BinaryDataHandler &pMem, const BitVector &whichField) |
Copy | |
| *virtual FieldContainerPtr | shallowCopy (void) const |
Static Public Member Functions | |
Class Get | |
| *static const char * | getClassname (void) |
Class Get | |
| *static FieldContainerType & | getClassType (void) |
| access the type of the class | |
| static UInt32 | getClassTypeId (void) |
| access the numerical type of the class | |
Construction | |
| *static ViewportPtr | create (void) |
| create a new instance of the class | |
| static ViewportPtr | createEmpty (void) |
| create an empty new instance of the class, do not copy the prototype | |
Static Public Attributes | |
| static const osg::BitVector | LeftFieldMask |
| static const osg::BitVector | RightFieldMask |
| static const osg::BitVector | BottomFieldMask |
| static const osg::BitVector | TopFieldMask |
| static const osg::BitVector | ParentFieldMask |
| static const osg::BitVector | CameraFieldMask |
| static const osg::BitVector | RootFieldMask |
| static const osg::BitVector | BackgroundFieldMask |
| static const osg::BitVector | ForegroundsFieldMask |
| static const osg::BitVector | TravMaskFieldMask |
| static const osg::BitVector | DrawTimeFieldMask |
| static const osg::BitVector | MTInfluenceMask |
| static const BitVector | AttachmentsFieldMask |
| static const BitVector | NextFieldMask |
Protected Member Functions | |
Constructors | |
| * | Viewport (void) |
| Viewport (const Viewport &source) | |
Destructors | |
| *virtual | ~Viewport (void) |
Sync | |
| *void | executeSyncImpl (ViewportBase *pOther, const BitVector &whichField) |
| virtual void | executeSync (FieldContainer &other, const BitVector &whichField) |
Protected Attributes | |
Fields | |
| *SFReal32 | _sfLeft |
| SFReal32 | _sfRight |
| SFReal32 | _sfBottom |
| SFReal32 | _sfTop |
| SFWindowPtr | _sfParent |
| SFCameraPtr | _sfCamera |
| SFNodePtr | _sfRoot |
| SFBackgroundPtr | _sfBackground |
| MFForegroundPtr | _mfForegrounds |
| SFUInt32 | _sfTravMask |
| SFReal32 | _sfDrawTime |
Private Types | |
| typedef ViewportBase | Inherited |
Private Member Functions | |
| void | operator= (const Viewport &source) |
Static Private Member Functions | |
| static void | initMethod (void) |
Friends | |
| class | FieldContainer |
| class | ViewportBase |
The size of the viewport is defined by the _sfLeft, _sfRight, _sfBottom and _sfTop Fields. The Window this Viewport is attached is stored in _sfWindow. _sfBackground defines the background clearing method, the _sfRoot and _sfCamera Fields the scene being rendered and the camera used to view it. The optional _mfForegrounds define which information are added or actions are executed after the Viewport has been rendered.
Ext:
To create a new Viewport the draw and render methods should be overridden.
Dev:
When adding fields to the Viewport, make sure to add the code to copy them to all the different CLusterWindows!
Definition at line 59 of file OSGViewport.h.
|
|
Reimplemented from osg::ViewportBase. Reimplemented in osg::ColorBufferViewport, osg::ColorBufferViewportBase, osg::PassiveViewport, osg::PassiveViewportBase, osg::StereoBufferViewport, and osg::StereoBufferViewportBase. Definition at line 132 of file OSGViewport.h. |
|
|
Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and osg::StereoBufferViewportBase. Definition at line 100 of file OSGViewportBase.h. |
|
|
Reimplemented from osg::AttachmentContainer. Definition at line 102 of file OSGViewportBase.h. 00103 { 00104 LeftFieldId = Inherited::NextFieldId, 00105 RightFieldId = LeftFieldId + 1, 00106 BottomFieldId = RightFieldId + 1, 00107 TopFieldId = BottomFieldId + 1, 00108 ParentFieldId = TopFieldId + 1, 00109 CameraFieldId = ParentFieldId + 1, 00110 RootFieldId = CameraFieldId + 1, 00111 BackgroundFieldId = RootFieldId + 1, 00112 ForegroundsFieldId = BackgroundFieldId + 1, 00113 TravMaskFieldId = ForegroundsFieldId + 1, 00114 DrawTimeFieldId = TravMaskFieldId + 1, 00115 NextFieldId = DrawTimeFieldId + 1 00116 };
|
|
|
Definition at line 114 of file OSGViewport.cpp. 00114 : 00115 Inherited() 00116 { 00117 }
|
|
|
Definition at line 119 of file OSGViewport.cpp. 00119 : 00120 Inherited(source) 00121 { 00122 }
|
|
|
Definition at line 124 of file OSGViewport.cpp.
|
|
|
Definition at line 67 of file OSGViewport.h.
|
|
||||||||||||||||||||
|
Set all of the size-related fields of the viewport. Does not call begin/endEdit internally! Definition at line 66 of file OSGViewport.inl. References osg::ViewportBase::_sfBottom, osg::ViewportBase::_sfLeft, osg::ViewportBase::_sfRight, osg::ViewportBase::_sfTop, and osg::SField< FieldTypeT, fieldNameSpace >::setValue(). 00068 { 00069 _sfLeft.setValue( left ); 00070 _sfRight.setValue( right ); 00071 _sfBottom.setValue( bottom ); 00072 _sfTop.setValue( top ); 00073 }
|
|
|
Calculate the positon of the left border of the viewport. Needs a valid _sfParent value. Definition at line 138 of file OSGViewport.cpp. References osg::ViewportBase::getLeft(), and osg::ViewportBase::getParent(). Referenced by osg::Camera::calcViewRay(), osg::TextureGrabBackground::clear(), osg::DVRIsoShader::deactivate_ColorMatrixShading(), draw(), osg::TextureGrabForeground::draw(), osg::PassiveViewport::draw(), osg::GrabForeground::draw(), getPixelWidth(), isFullWindow(), and osg::RenderAction::start(). 00139 { 00140 if(getLeft() > 1) 00141 return Int32(getLeft()); 00142 00143 return Int32(getParent()->getWidth() * getLeft()); 00144 }
|
|
|
Calculate the positon of the right border of the viewport. Needs a valid _sfParent value. Definition at line 149 of file OSGViewport.cpp. References osg::ViewportBase::getParent(), and osg::ViewportBase::getRight(). Referenced by osg::DVRIsoShader::deactivate_ColorMatrixShading(), draw(), osg::PassiveViewport::draw(), getPixelWidth(), isFullWindow(), and osg::RenderAction::start(). 00150 { 00151 // >1: pixel 00152 if(getRight() > 1) 00153 return Int32(getRight()); 00154 00155 // <=1: partial screen, use 1 less to not overlap other windows 00156 return Int32(getParent()->getWidth() * getRight() - 1); 00157 }
|
|
|
Calculate the positon of the bottom border of the viewport. Needs a valid _sfParent value. Definition at line 162 of file OSGViewport.cpp. References osg::ViewportBase::getBottom(), and osg::ViewportBase::getParent(). Referenced by osg::TextureGrabBackground::clear(), osg::DVRIsoShader::deactivate_ColorMatrixShading(), draw(), osg::TextureGrabForeground::draw(), osg::PassiveViewport::draw(), osg::GrabForeground::draw(), getPixelHeight(), isFullWindow(), and osg::RenderAction::start(). 00163 { 00164 if(getBottom() > 1) 00165 return Int32(getBottom()); 00166 00167 return Int32(getParent()->getHeight() * getBottom()); 00168 }
|
|
|
Calculate the positon of the top border of the viewport. Needs a valid _sfParent value. Definition at line 173 of file OSGViewport.cpp. References osg::ViewportBase::getParent(), and osg::ViewportBase::getTop(). Referenced by osg::Camera::calcViewRay(), osg::DVRIsoShader::deactivate_ColorMatrixShading(), draw(), osg::PassiveViewport::draw(), getPixelHeight(), isFullWindow(), and osg::RenderAction::start(). 00174 { 00175 // >1: pixel 00176 if(getTop() > 1) 00177 return Int32(getTop()); 00178 00179 // <=1: partial screen, use 1 less to not overlap other windows 00180 return Int32(getParent()->getHeight() * getTop() - 1); 00181 }
|
|
|
|
|
Checks if the viewport fills the whole window. Needs a valid _sfParent value. Definition at line 186 of file OSGViewport.cpp. References osg::ViewportBase::getParent(), getPixelBottom(), getPixelLeft(), getPixelRight(), and getPixelTop(). Referenced by draw(), and osg::RenderAction::start(). 00187 { 00188 return getPixelBottom() == 0 && 00189 getPixelLeft() == 0 && 00190 getPixelTop() == getParent()->getHeight() - 1 && 00191 getPixelRight() == getParent()->getWidth() - 1; 00192 }
|
|
|
Draw the viewport. Restrict the OpenGL rendering to the given part of the window, clear it, draw it using the given DrawAction and add the Foregrounds. The _sfCamera, _sfBackground and _sfRoot Fields need to be valid, otherwise drawing will fail. Dev: Activates scissoring only if the viewport doesn't fill the wholw window, as it significantly slows down some OpenGL implementations. Reimplemented in osg::ColorBufferViewport, osg::PassiveViewport, and osg::StereoBufferViewport. Definition at line 210 of file OSGViewport.cpp. References osg::Action::apply(), osg::ViewportBase::getBackground(), osg::ViewportBase::getCamera(), osg::ViewportBase::getForegrounds(), getPixelBottom(), getPixelLeft(), getPixelRight(), getPixelTop(), osg::ViewportBase::getRoot(), osg::ViewportBase::getTravMask(), isFullWindow(), osg::NullFC, osg::DrawActionBase::setBackground(), osg::DrawActionBase::setCamera(), osg::Action::setTravMask(), osg::DrawActionBase::setViewport(), osg::MField< FieldTypeT, fieldNameSpace >::size(), and SWARNING. Referenced by osg::StereoBufferViewport::draw(), and osg::ColorBufferViewport::draw(). 00211 { 00212 if(getCamera() == NullFC) 00213 { 00214 SWARNING << "Viewport::draw: no camera!" << std::endl; 00215 return; 00216 } 00217 if(getBackground() == NullFC) 00218 { 00219 SWARNING << "Viewport::draw: no Background!" << std::endl; 00220 return; 00221 } 00222 if(getRoot() == NullFC) 00223 { 00224 SWARNING << "Viewport::draw: no root!" << std::endl; 00225 return; 00226 } 00227 00228 GLint pl=getPixelLeft(), pr=getPixelRight(), pb=getPixelBottom(), 00229 pt=getPixelTop(); 00230 GLint pw=pr-pl+1,ph=pt-pb+1; 00231 bool full = isFullWindow(); 00232 00233 glViewport(pl, pb, pw, ph); 00234 glScissor(pl, pb, pw, ph); 00235 00236 if(! full) 00237 glEnable(GL_SCISSOR_TEST); 00238 00239 action->setViewport (this); 00240 action->setCamera (getCamera ().getCPtr()); 00241 action->setBackground(getBackground().getCPtr()); 00242 action->setTravMask (getTravMask() ); 00243 00244 getCamera ()->setup(action, *this); 00245 getBackground()->clear(action, this); 00246 00247 action->apply(getRoot()); 00248 00249 for(UInt16 i=0; i < getForegrounds().size(); i++) 00250 getForegrounds(i)->draw(action, this); 00251 00252 if(! full) 00253 glDisable(GL_SCISSOR_TEST); 00254 }
|
|
|
Draw the viewport. Restrict the OpenGL rendering to the given part of the window, clear it, draw it using the given DrawAction and add the Foregrounds. The _sfCamera, _sfBackground and _sfRoot Fields need to be valid, otherwise drawing will fail. Dev: Activates scissoring only if the viewport doesn't fill the wholw window, as it significantly slows down some OpenGL implementations. Reimplemented in osg::ColorBufferViewport, osg::PassiveViewport, and osg::StereoBufferViewport. Definition at line 257 of file OSGViewport.cpp. References osg::Action::apply(), osg::ViewportBase::getBackground(), osg::ViewportBase::getCamera(), osg::ViewportBase::getForegrounds(), osg::ViewportBase::getRoot(), osg::ViewportBase::getTravMask(), osg::NullFC, osg::DrawActionBase::setBackground(), osg::DrawActionBase::setCamera(), osg::Action::setTravMask(), osg::DrawActionBase::setViewport(), osg::MField< FieldTypeT, fieldNameSpace >::size(), and SWARNING. Referenced by osg::StereoBufferViewport::render(), and osg::ColorBufferViewport::render(). 00258 { 00259 if(getCamera() == NullFC) 00260 { 00261 SWARNING << "Viewport::render: no camera!" << std::endl; 00262 return; 00263 } 00264 if(getBackground() == NullFC) 00265 { 00266 SWARNING << "Viewport::render: no Background!" << std::endl; 00267 return; 00268 } 00269 if(getRoot() == NullFC) 00270 { 00271 SWARNING << "Viewport::render: no root!" << std::endl; 00272 return; 00273 } 00274 00275 /* 00276 GLint pl=getPixelLeft(), pr=getPixelRight(), pb=getPixelBottom(), 00277 pt=getPixelTop(); 00278 GLint pw=pr-pl+1,ph=pt-pb+1; 00279 bool full = isFullWindow(); 00280 00281 glViewport(pl, pb, pw, ph); 00282 glScissor(pl, pb, pw, ph); 00283 00284 if(! full) 00285 glEnable(GL_SCISSOR_TEST); 00286 */ 00287 00288 action->setCamera (getCamera ().getCPtr()); 00289 action->setBackground(getBackground().getCPtr()); 00290 action->setViewport (this ); 00291 action->setTravMask (getTravMask() ); 00292 00293 // getCamera()->setup(action, *this); 00294 // getBackground()->clear(action, this); 00295 00296 /* 00297 fprintf(stderr,"%p: node 0x%p startrender\n", Thread::getCurrent(), 00298 getRoot().getCPtr()); 00299 */ 00300 action->apply(getRoot()); 00301 00302 for(UInt16 i=0; i < getForegrounds().size(); i++) 00303 getForegrounds(i)->draw(action, this); 00304 00305 /* 00306 if(! full) 00307 glDisable(GL_SCISSOR_TEST); 00308 */ 00309 }
|
|
||||||||||||
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewport, osg::PassiveViewport, and osg::StereoBufferViewport. Definition at line 128 of file OSGViewport.cpp. References osg::AttachmentContainer::changed(). Referenced by osg::StereoBufferViewport::changed(), osg::PassiveViewport::changed(), and osg::ColorBufferViewport::changed(). 00129 { 00130 Inherited::changed(whichField, origin); 00131 }
|
|
||||||||||||
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewport, osg::PassiveViewport, and osg::StereoBufferViewport. Definition at line 313 of file OSGViewport.cpp. References SLOG. 00315 { 00316 SLOG << "Dump Viewport NI" << std::endl; 00317 }
|
|
|
Reimplemented in osg::ColorBufferViewport, osg::PassiveViewport, and osg::StereoBufferViewport. Definition at line 104 of file OSGViewport.cpp.
|
|
|
|
|
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and osg::StereoBufferViewportBase. Definition at line 58 of file OSGViewportBase.inl. References osg::ViewportBase::_type. Referenced by osg::ViewportBase::create(). 00059 { 00060 return _type; 00061 }
|
|
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and osg::StereoBufferViewportBase. Definition at line 65 of file OSGViewportBase.inl. References osg::ViewportBase::_type, and osg::TypeBase::getId(). 00066 { 00067 return _type.getId(); 00068 }
|
|
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and osg::StereoBufferViewportBase. Definition at line 216 of file OSGViewportBase.cpp. References osg::ViewportBase::_type. 00217 { 00218 return _type; 00219 }
|
|
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and osg::StereoBufferViewportBase. Definition at line 221 of file OSGViewportBase.cpp. References osg::ViewportBase::_type. 00222 { 00223 return _type; 00224 }
|
|
|
Reimplemented from osg::AttachmentContainer. Reimplemented in osg::ColorBufferViewportBase, osg::PassiveViewportBase, and |