LineStipple 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 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_LINESTIPPLE
  14. #define OSG_LINESTIPPLE 1
  15. #include <osg/StateAttribute>
  16. #ifndef GL_LINE_STIPPLE
  17. #define GL_LINE_STIPPLE 0x0B24
  18. #endif
  19. namespace osg {
  20. class OSG_EXPORT LineStipple : public StateAttribute
  21. {
  22. public :
  23. LineStipple();
  24. LineStipple(GLint factor, GLushort pattern):
  25. _factor(factor),
  26. _pattern(pattern) {}
  27. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  28. LineStipple(const LineStipple& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  29. StateAttribute(lw,copyop),
  30. _factor(lw._factor),
  31. _pattern(lw._pattern) {}
  32. META_StateAttribute(osg, LineStipple, LINESTIPPLE);
  33. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  34. virtual int compare(const StateAttribute& sa) const
  35. {
  36. // check if the types are equal and then create the rhs variable.
  37. // used by the COMPARE_StateAttribute_Parameter macros below.
  38. COMPARE_StateAttribute_Types(LineStipple,sa)
  39. // compare each parameter in turn against the rhs.
  40. COMPARE_StateAttribute_Parameter(_factor)
  41. COMPARE_StateAttribute_Parameter(_pattern)
  42. return 0; // passed all the above comparison macros, must be equal.
  43. }
  44. virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
  45. {
  46. usage.usesMode(GL_LINE_STIPPLE);
  47. return true;
  48. }
  49. void setFactor(GLint factor);
  50. inline GLint getFactor() const { return _factor; }
  51. void setPattern(GLushort pattern);
  52. inline GLushort getPattern() const { return _pattern; }
  53. virtual void apply(State& state) const;
  54. protected :
  55. virtual ~LineStipple();
  56. GLint _factor;
  57. GLushort _pattern;
  58. };
  59. }
  60. #endif