Capability 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2014 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_ENABLEI
  14. #define OSG_ENABLEI 1
  15. #include <osg/GL>
  16. #include <osg/StateAttribute>
  17. namespace osg {
  18. class OSG_EXPORT Capability : public osg::StateAttribute
  19. {
  20. public :
  21. Capability();
  22. Capability(GLenum capability):
  23. _capability(capability) {}
  24. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  25. Capability(const Capability& cap,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  26. StateAttribute(cap, copyop),
  27. _capability(cap._capability) {}
  28. META_Object(osg, Capability);
  29. /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  30. virtual int compare(const StateAttribute& sa) const
  31. {
  32. // Check for equal types, then create the rhs variable
  33. // used by the COMPARE_StateAttribute_Parameter macros below.
  34. COMPARE_StateAttribute_Types(Capability,sa)
  35. COMPARE_StateAttribute_Parameter(_capability);
  36. return 0;
  37. }
  38. /** Return the Type identifier of the attribute's class type.*/
  39. virtual Type getType() const { return static_cast<Type>(CAPABILITY+_capability); }
  40. void setCapability(GLenum capability) { _capability = capability; }
  41. GLenum getCapability() const { return _capability; }
  42. protected:
  43. virtual ~Capability();
  44. GLenum _capability;
  45. };
  46. /** Encapsulates glEnablei/glDisablei
  47. */
  48. class OSG_EXPORT Capabilityi : public osg::Capability
  49. {
  50. public :
  51. Capabilityi();
  52. Capabilityi(GLenum capability, unsigned int buf):
  53. Capability(capability),
  54. _index(buf) {}
  55. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  56. Capabilityi(const Capabilityi& cap,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  57. Capability(cap,copyop),
  58. _index(cap._index) {}
  59. META_Object(osg, Capabilityi);
  60. /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  61. virtual int compare(const StateAttribute& sa) const
  62. {
  63. // Check for equal types, then create the rhs variable
  64. // used by the COMPARE_StateAttribute_Parameter macros below.
  65. COMPARE_StateAttribute_Types(Capabilityi,sa)
  66. COMPARE_StateAttribute_Parameter(_index);
  67. COMPARE_StateAttribute_Parameter(_capability);
  68. return 0;
  69. }
  70. /** Return the member identifier within the attribute's class type. Used for light number/clip plane number etc.*/
  71. virtual unsigned int getMember() const { return _index; }
  72. /** Set the renderbuffer index of the Enablei. */
  73. void setIndex(unsigned int buf) { _index = buf; }
  74. /** Get the renderbuffer index of the Enablei. */
  75. unsigned int getIndex() const { return _index; }
  76. protected:
  77. virtual ~Capabilityi();
  78. unsigned int _index;
  79. };
  80. class OSG_EXPORT Enablei : public Capabilityi
  81. {
  82. public :
  83. Enablei() {}
  84. Enablei(unsigned int buf, GLenum capability):
  85. Capabilityi(buf, capability) {}
  86. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  87. Enablei(const Enablei& ei,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  88. Capabilityi(ei,copyop) {}
  89. META_Object(osg, Enablei);
  90. virtual void apply(State&) const;
  91. protected:
  92. virtual ~Enablei() {}
  93. };
  94. class OSG_EXPORT Disablei : public Capabilityi
  95. {
  96. public :
  97. Disablei() {}
  98. Disablei(unsigned int buf, GLenum capability):
  99. Capabilityi(buf, capability) {}
  100. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  101. Disablei(const Disablei& ei,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  102. Capabilityi(ei,copyop) {}
  103. META_Object(osg, Disablei);
  104. virtual void apply(State&) const;
  105. protected:
  106. virtual ~Disablei() {}
  107. };
  108. }
  109. #endif