FrontFace 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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_FRONTFACE
  14. #define OSG_FRONTFACE 1
  15. #include <osg/StateAttribute>
  16. #include <osg/GL>
  17. namespace osg {
  18. /** Class to specify the orientation of front-facing polygons.
  19. */
  20. class OSG_EXPORT FrontFace : public StateAttribute
  21. {
  22. public :
  23. enum Mode {
  24. CLOCKWISE = GL_CW,
  25. COUNTER_CLOCKWISE = GL_CCW
  26. };
  27. FrontFace(Mode face=COUNTER_CLOCKWISE);
  28. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  29. FrontFace(const FrontFace& ff,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  30. StateAttribute(ff,copyop),
  31. _mode(ff._mode) {}
  32. META_StateAttribute(osg, FrontFace, FRONTFACE);
  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 the types are equal and then create the rhs variable
  37. // used by the COMPARE_StateAttribute_Parameter macros below.
  38. COMPARE_StateAttribute_Types(FrontFace,sa)
  39. // compare each parameter in turn against the rhs.
  40. COMPARE_StateAttribute_Parameter(_mode)
  41. return 0; // passed all the above comparison macros, must be equal.
  42. }
  43. inline void setMode(Mode mode) { _mode = mode; }
  44. inline Mode getMode() const { return _mode; }
  45. virtual void apply(State& state) const;
  46. protected:
  47. virtual ~FrontFace();
  48. Mode _mode;
  49. };
  50. }
  51. #endif