Hint 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_HINT
  14. #define OSG_HINT 1
  15. #include <osg/StateAttribute>
  16. namespace osg
  17. {
  18. class OSG_EXPORT Hint : public StateAttribute
  19. {
  20. public:
  21. Hint():
  22. _target(GL_NONE),
  23. _mode(GL_DONT_CARE) {}
  24. Hint(GLenum target, GLenum mode):
  25. _target(target),
  26. _mode(mode) {}
  27. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  28. Hint(const Hint& hint,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  29. StateAttribute(hint,copyop),
  30. _target(hint._target),
  31. _mode(hint._mode) {}
  32. virtual osg::Object* cloneType() const { return new Hint( _target, GL_DONT_CARE ); }
  33. virtual osg::Object* clone(const osg::CopyOp& copyop) const { return new Hint(*this,copyop); }
  34. virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Hint *>(obj)!=NULL; }
  35. virtual const char* libraryName() const { return "osg"; }
  36. virtual const char* className() const { return "Hint"; }
  37. virtual Type getType() const { return HINT; }
  38. virtual int compare(const StateAttribute& sa) const
  39. {
  40. // check the types are equal and then create the rhs variable
  41. // used by the COMPARE_StateAttribute_Parameter macros below.
  42. COMPARE_StateAttribute_Types(Hint,sa)
  43. // compare each parameter in turn against the rhs.
  44. COMPARE_StateAttribute_Parameter(_target)
  45. COMPARE_StateAttribute_Parameter(_mode)
  46. return 0;
  47. }
  48. /** Return the member identifier within the attribute's class type. Used for light number/clip plane number etc.*/
  49. virtual unsigned int getMember() const { return static_cast<unsigned int>(_target); }
  50. void setTarget(GLenum target);
  51. inline GLenum getTarget() const { return _target; }
  52. inline void setMode(GLenum mode) { _mode = mode; }
  53. inline GLenum getMode() const { return _mode; }
  54. virtual void apply(State& state) const;
  55. protected:
  56. GLenum _target;
  57. GLenum _mode;
  58. };
  59. }
  60. #endif