DepthRangeIndexed 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2016 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 OSG_DepthRangeIndexed
  14. #define OSG_DepthRangeIndexed 1
  15. #include <osg/Depth>
  16. namespace osg {
  17. /** Encapsulates glDepthRangeIndexed function : the index version of glDepth
  18. */
  19. class OSG_EXPORT DepthRangeIndexed : public osg::StateAttribute
  20. {
  21. public :
  22. DepthRangeIndexed();
  23. DepthRangeIndexed(unsigned int index, double zNear=0.0, double zFar=1.0):
  24. _index(index),
  25. _zNear(zNear),
  26. _zFar(zFar) {}
  27. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  28. DepthRangeIndexed(const DepthRangeIndexed& dp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  29. StateAttribute(dp,copyop),
  30. _index(dp._index),
  31. _zNear(dp._zNear),
  32. _zFar(dp._zFar) {}
  33. META_StateAttribute(osg, DepthRangeIndexed, DEPTHRANGEINDEXED);
  34. /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  35. virtual int compare(const StateAttribute& sa) const
  36. {
  37. // Check for equal types, then create the rhs variable
  38. // used by the COMPARE_StateAttribute_Parameter macros below.
  39. COMPARE_StateAttribute_Types(DepthRangeIndexed,sa)
  40. COMPARE_StateAttribute_Parameter(_index);
  41. COMPARE_StateAttribute_Parameter(_zNear)
  42. COMPARE_StateAttribute_Parameter(_zFar)
  43. return 0;
  44. }
  45. /** Return the buffer index as the member identifier.*/
  46. virtual unsigned int getMember() const { return _index; }
  47. /** Set the index of the DepthRangeIndexed. */
  48. void setIndex(unsigned int index);
  49. /** Get the index of the DepthRangeIndexed. */
  50. unsigned int getIndex() const { return _index; }
  51. inline void setZNear(double zNear) { _zNear=zNear; }
  52. inline double getZNear() const { return _zNear; }
  53. inline void setZFar(double zFar) { _zFar=zFar; }
  54. inline double getZFar() const { return _zFar; }
  55. virtual void apply(State& state) const;
  56. protected:
  57. virtual ~DepthRangeIndexed();
  58. unsigned int _index;
  59. double _zNear;
  60. double _zFar;
  61. };
  62. }
  63. #endif