LineWidth 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_LINEWIDTH
  14. #define OSG_LINEWIDTH 1
  15. #include <osg/StateAttribute>
  16. namespace osg {
  17. /** LineWidth - encapsulates the OpenGL glLineWidth for setting the width of lines in pixels. */
  18. class OSG_EXPORT LineWidth : public StateAttribute
  19. {
  20. public :
  21. LineWidth(float width=1.0f);
  22. /** Copy constructor using CopyOp to manage deep vs shallow copy. */
  23. LineWidth(const LineWidth& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY) :
  24. StateAttribute(lw,copyop),
  25. _width(lw._width) {}
  26. META_StateAttribute(osg, LineWidth, LINEWIDTH);
  27. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
  28. virtual int compare(const StateAttribute& sa) const
  29. {
  30. // check if the types are equal and then create the rhs variable
  31. // used by the COMPARE_StateAttribute_Parameter macros below.
  32. COMPARE_StateAttribute_Types(LineWidth,sa)
  33. // compare each parameter in turn against the rhs.
  34. COMPARE_StateAttribute_Parameter(_width)
  35. return 0; // passed all the above comparison macros, must be equal.
  36. }
  37. void setWidth(float width);
  38. inline float getWidth() const { return _width; }
  39. virtual void apply(State& state) const;
  40. protected :
  41. virtual ~LineWidth();
  42. float _width;
  43. };
  44. }
  45. #endif