PatchParameter 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 OSG_PATCHPARAMETER
  14. #define OSG_PATCHPARAMETER 1
  15. #include <osg/Vec2>
  16. #include <osg/Vec4>
  17. #include <osg/StateAttribute>
  18. namespace osg {
  19. /** Class which encapsulates glPatchParameter(..).
  20. */
  21. class OSG_EXPORT PatchParameter : public StateAttribute
  22. {
  23. public :
  24. PatchParameter(GLint vertices=3);
  25. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  26. PatchParameter(const PatchParameter& rhs,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  27. StateAttribute(rhs,copyop),
  28. _vertices(rhs._vertices),
  29. _patchDefaultInnerLevel(rhs._patchDefaultInnerLevel),
  30. _patchDefaultOuterLevel(rhs._patchDefaultOuterLevel) {}
  31. META_StateAttribute(osg, PatchParameter, PATCH_PARAMETER);
  32. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
  33. virtual int compare(const StateAttribute& sa) const
  34. {
  35. // check the types are equal and then create the rhs variable
  36. // used by the COMPARE_StateAttribute_Parameter macros below.
  37. COMPARE_StateAttribute_Types(PatchParameter,sa)
  38. // compare each parameter in turn against the rhs.
  39. COMPARE_StateAttribute_Parameter(_vertices)
  40. COMPARE_StateAttribute_Parameter(_patchDefaultInnerLevel)
  41. COMPARE_StateAttribute_Parameter(_patchDefaultOuterLevel)
  42. return 0; // passed all the above comparison macros, must be equal.
  43. }
  44. /** Set GL_PATCH_VERTICES parameter.*/
  45. void setVertices(GLint vertices) { _vertices = vertices; }
  46. /** Get GL_PATCH_VERTICES parameter.*/
  47. GLint getVertices() const { return _vertices; }
  48. /** Set GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
  49. void setPatchDefaultInnerLevel(const osg::Vec2& level) { _patchDefaultInnerLevel = level; }
  50. /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
  51. const osg::Vec2& getPatchDefaultInnerLevel() const { return _patchDefaultInnerLevel; }
  52. /** Set GL_PATCH_DEFAULT_OUTER_LEVEL parameter.*/
  53. void setPatchDefaultOuterLevel(const osg::Vec4& level) { _patchDefaultOuterLevel = level; }
  54. /** Get GL_PATCH_DEFAULT_INNER_LEVEL parameter.*/
  55. const osg::Vec4& getPatchDefaultOuterLevel() const { return _patchDefaultOuterLevel; }
  56. virtual void apply(State& state) const;
  57. protected:
  58. virtual ~PatchParameter();
  59. GLint _vertices;
  60. osg::Vec2 _patchDefaultInnerLevel;
  61. osg::Vec4 _patchDefaultOuterLevel;
  62. };
  63. }
  64. #endif