ScissorIndexed 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_ScissorIndexed
  14. #define OSG_ScissorIndexed 1
  15. #include <osg/Depth>
  16. namespace osg {
  17. /** Encapsulates glScissorIndexed function : the index version of glDepth
  18. */
  19. class OSG_EXPORT ScissorIndexed : public osg::StateAttribute
  20. {
  21. public :
  22. ScissorIndexed();
  23. ScissorIndexed(unsigned int index, float x, float y, float width, float height):
  24. _index(index),
  25. _x(x),
  26. _y(y),
  27. _width(width),
  28. _height(height) {}
  29. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  30. ScissorIndexed(const ScissorIndexed& dp,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  31. StateAttribute(dp,copyop),
  32. _index(dp._index),
  33. _x(dp._x),
  34. _y(dp._y),
  35. _width(dp._width),
  36. _height(dp._height) {}
  37. META_StateAttribute(osg, ScissorIndexed, SCISSORINDEXED);
  38. /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  39. virtual int compare(const StateAttribute& sa) const
  40. {
  41. // Check for equal types, then create the rhs variable
  42. // used by the COMPARE_StateAttribute_Parameter macros below.
  43. COMPARE_StateAttribute_Types(ScissorIndexed,sa)
  44. COMPARE_StateAttribute_Parameter(_index);
  45. COMPARE_StateAttribute_Parameter(_x)
  46. COMPARE_StateAttribute_Parameter(_y)
  47. COMPARE_StateAttribute_Parameter(_width)
  48. COMPARE_StateAttribute_Parameter(_height)
  49. return 0;
  50. }
  51. /** Return the buffer index as the member identifier.*/
  52. virtual unsigned int getMember() const { return _index; }
  53. /** Set the index of the ScissorIndexed. */
  54. void setIndex(unsigned int index);
  55. /** Get the index of the ScissorIndexed. */
  56. unsigned int getIndex() const { return _index; }
  57. inline void setX(float x) { _x=x; }
  58. inline float getX() const { return _x; }
  59. inline void setY(float y) { _y=y; }
  60. inline float getY() const { return _y; }
  61. inline void setWidth(float w) { _width=w; }
  62. inline float getWidth() const { return _width; }
  63. inline void setHeight(float height) { _height=height; }
  64. inline float getHeight() const { return _height; }
  65. virtual void apply(State& state) const;
  66. protected:
  67. virtual ~ScissorIndexed();
  68. unsigned int _index;
  69. float _x;
  70. float _y;
  71. float _width;
  72. float _height;
  73. };
  74. }
  75. #endif