DisplayRequirementsVisitor 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSGUTIL_DISPLAYREQUIREMENTSVISITOR
  14. #define OSGUTIL_DISPLAYREQUIREMENTSVISITOR 1
  15. #include <osg/NodeVisitor>
  16. #include <osg/Geode>
  17. #include <osg/DisplaySettings>
  18. #include <osgUtil/Export>
  19. namespace osgUtil {
  20. /** A visitor for traversing a scene graph establishing which OpenGL visuals are
  21. * required to support rendering of that scene graph. The results can then be used by
  22. * applications to set up their windows with the correct visuals. Have a look at
  23. * src/osgGLUT/Viewer.cpp's Viewer::open() method for an example of how to use it.
  24. */
  25. class OSGUTIL_EXPORT DisplayRequirementsVisitor : public osg::NodeVisitor
  26. {
  27. public:
  28. /** Default to traversing all children, and requiresDoubleBuffer,
  29. * requiresRGB and requiresDepthBuffer to true and with
  30. * alpha and stencil off.*/
  31. DisplayRequirementsVisitor();
  32. META_NodeVisitor(osgUtil, DisplayRequirementsVisitor)
  33. /** Set the DisplaySettings. */
  34. inline void setDisplaySettings(osg::DisplaySettings* ds) { _ds = ds; }
  35. /** Get the DisplaySettings */
  36. inline const osg::DisplaySettings* getDisplaySettings() const { return _ds.get(); }
  37. virtual void applyStateSet(osg::StateSet& stateset);
  38. virtual void apply(osg::Node& node);
  39. protected:
  40. osg::ref_ptr<osg::DisplaySettings> _ds;
  41. };
  42. }
  43. #endif