DrawPixels 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_DRAWPIXELS
  14. #define OSG_DRAWPIXELS 1
  15. #include <osg/Drawable>
  16. #include <osg/Vec3>
  17. #include <osg/Image>
  18. namespace osg {
  19. /** DrawPixels is an osg::Drawable subclass which encapsulates the drawing of
  20. * images using glDrawPixels.*/
  21. class OSG_EXPORT DrawPixels : public Drawable
  22. {
  23. public:
  24. DrawPixels();
  25. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  26. DrawPixels(const DrawPixels& drawimage,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
  27. virtual Object* cloneType() const { return new DrawPixels(); }
  28. virtual Object* clone(const CopyOp& copyop) const { return new DrawPixels(*this,copyop); }
  29. virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawPixels*>(obj)!=NULL; }
  30. virtual const char* libraryName() const { return "osg"; }
  31. virtual const char* className() const { return "DrawPixels"; }
  32. void setPosition(const osg::Vec3& position);
  33. osg::Vec3& getPosition() { return _position; }
  34. const osg::Vec3& getPosition() const { return _position; }
  35. void setImage(osg::Image* image) { _image = image; }
  36. osg::Image* getImage() { return _image.get(); }
  37. const osg::Image* getImage() const { return _image.get(); }
  38. void setUseSubImage(bool useSubImage) { _useSubImage=useSubImage; }
  39. bool getUseSubImage() const { return _useSubImage; }
  40. void setSubImageDimensions(unsigned int offsetX,unsigned int offsetY,unsigned int width,unsigned int height);
  41. void getSubImageDimensions(unsigned int& offsetX,unsigned int& offsetY,unsigned int& width,unsigned int& height) const;
  42. virtual void drawImplementation(RenderInfo& renderInfo) const;
  43. virtual BoundingBox computeBoundingBox() const;
  44. protected:
  45. DrawPixels& operator = (const DrawPixels&) { return *this;}
  46. virtual ~DrawPixels();
  47. Vec3 _position;
  48. ref_ptr<Image> _image;
  49. bool _useSubImage;
  50. unsigned int _offsetX, _offsetY, _width, _height;
  51. };
  52. }
  53. #endif