PointSprite 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_POINTSPRITE
  14. #define OSG_POINTSPRITE 1
  15. #include <osg/GL>
  16. #include <osg/StateAttribute>
  17. #ifndef GL_ARB_point_sprite
  18. #define GL_POINT_SPRITE_ARB 0x8861
  19. #define GL_COORD_REPLACE_ARB 0x8862
  20. #endif
  21. #ifndef GL_POINT_SPRITE_COORD_ORIGIN
  22. #define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
  23. #define GL_LOWER_LEFT 0x8CA1
  24. #define GL_UPPER_LEFT 0x8CA2
  25. #endif
  26. namespace osg {
  27. /** PointSprite base class which encapsulates enabling of point sprites .*/
  28. class OSG_EXPORT PointSprite : public osg::StateAttribute {
  29. public:
  30. PointSprite();
  31. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  32. PointSprite(const PointSprite& ps,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
  33. StateAttribute(ps,copyop),
  34. _coordOriginMode(ps._coordOriginMode) {}
  35. META_StateAttribute(osg, PointSprite, POINTSPRITE);
  36. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
  37. virtual int compare(const StateAttribute& sa) const;
  38. virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
  39. {
  40. usage.usesMode(GL_POINT_SPRITE_ARB);
  41. return true;
  42. }
  43. virtual bool checkValidityOfAssociatedModes(osg::State&) const;
  44. virtual bool isTextureAttribute() const { return true; }
  45. virtual void apply(osg::State& state) const;
  46. enum CoordOriginMode {
  47. UPPER_LEFT = GL_UPPER_LEFT,
  48. LOWER_LEFT = GL_LOWER_LEFT
  49. };
  50. inline void setCoordOriginMode(CoordOriginMode mode) { _coordOriginMode = mode; }
  51. inline CoordOriginMode getCoordOriginMode() const { return _coordOriginMode; }
  52. protected:
  53. virtual ~PointSprite();
  54. CoordOriginMode _coordOriginMode;
  55. };
  56. }
  57. #endif