ClipControl 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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_CLIPCONTROL
  14. #define OSG_CLIPCONTROL 1
  15. #include <osg/StateAttribute>
  16. #ifndef GL_VERSION_4_5
  17. #define GL_NEGATIVE_ONE_TO_ONE 0x935E
  18. #define GL_ZERO_TO_ONE 0x935F
  19. #endif
  20. namespace osg {
  21. /** Encapsulate OpenGL glClipControl functions.
  22. */
  23. class OSG_EXPORT ClipControl : public StateAttribute
  24. {
  25. public :
  26. enum Origin
  27. {
  28. LOWER_LEFT = GL_LOWER_LEFT,
  29. UPPER_LEFT = GL_UPPER_LEFT
  30. };
  31. enum DepthMode
  32. {
  33. NEGATIVE_ONE_TO_ONE = GL_NEGATIVE_ONE_TO_ONE,
  34. ZERO_TO_ONE = GL_ZERO_TO_ONE
  35. };
  36. ClipControl(Origin origin=LOWER_LEFT, DepthMode depthMode=NEGATIVE_ONE_TO_ONE);
  37. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  38. ClipControl(const ClipControl& clipControl,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
  39. META_StateAttribute(osg, ClipControl, CLIPCONTROL);
  40. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
  41. virtual int compare(const StateAttribute& sa) const
  42. {
  43. // check the types are equal and then create the rhs variable
  44. // used by the COMPARE_StateAttribute_Parameter macros below.
  45. COMPARE_StateAttribute_Types(ClipControl,sa)
  46. // compare each parameter in turn against the rhs.
  47. COMPARE_StateAttribute_Parameter(_origin)
  48. COMPARE_StateAttribute_Parameter(_depthMode)
  49. return 0; // passed all the above comparison macros, must be equal.
  50. }
  51. void setOrigin(Origin origin) { _origin = origin; }
  52. Origin getOrigin() const { return _origin; }
  53. void setDepthMode(DepthMode depthMode) { _depthMode = depthMode; }
  54. DepthMode getDepthMode() const { return _depthMode; }
  55. virtual void apply(State& state) const;
  56. protected:
  57. virtual ~ClipControl();
  58. Origin _origin;
  59. DepthMode _depthMode;
  60. };
  61. }
  62. #endif