Added new osg::DrawPixels class with encapsulates glDrawPixels as and
osg::Drawable. Added osg::Image::readPixels to osg::Image. Made osg::LightSource to default to cullActive set to false to that LightSource nodes don't get culled by default.
This commit is contained in:
74
include/osg/DrawPixels
Normal file
74
include/osg/DrawPixels
Normal file
@@ -0,0 +1,74 @@
|
||||
//C++ header - Open Scene Graph - Copyright (C) 1998-2001 Robert Osfield
|
||||
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
||||
//as published by the Free Software Foundation.
|
||||
|
||||
#ifndef OSG_DRAWPIXELS
|
||||
#define OSG_DRAWPIXELS 1
|
||||
|
||||
#include <osg/Drawable>
|
||||
#include <osg/Vec3>
|
||||
#include <osg/Image>
|
||||
|
||||
namespace osg {
|
||||
|
||||
/** DrawPixels is an osg::Drawable subclass which encapsulates the drawing of
|
||||
* images using glDrawPixels.*/
|
||||
class SG_EXPORT DrawPixels : public Drawable
|
||||
{
|
||||
public:
|
||||
|
||||
DrawPixels();
|
||||
|
||||
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
|
||||
DrawPixels(const DrawPixels& drawimage,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
|
||||
|
||||
virtual Object* cloneType() const { return osgNew DrawPixels(); }
|
||||
|
||||
virtual Object* clone(const CopyOp& copyop) const { return osgNew DrawPixels(*this,copyop); }
|
||||
|
||||
virtual bool isSameKindAs(const Object* obj) const { return dynamic_cast<const DrawPixels*>(obj)!=NULL; }
|
||||
|
||||
virtual const char* className() const { return "DrawPixels"; }
|
||||
|
||||
|
||||
void setPosition(const osg::Vec3& position);
|
||||
|
||||
osg::Vec3& getPosition() { return _position; }
|
||||
const osg::Vec3& getPosition() const { return _position; }
|
||||
|
||||
void setImage(osg::Image* image) { _image = image; }
|
||||
|
||||
osg::Image* getImage() { return _image.get(); }
|
||||
const osg::Image* getImage() const { return _image.get(); }
|
||||
|
||||
void setUseCompleteImage() { _useSubImage = false; }
|
||||
|
||||
void setSubImageDimensions(unsigned int offsetX,unsigned int offsetY,unsigned int width,unsigned int height);
|
||||
|
||||
void getSubImageDimensions(unsigned int& offsetX,unsigned int& offsetY,unsigned int& width,unsigned int& height) const;
|
||||
|
||||
const bool getUseSubImage() const { return _useSubImage; }
|
||||
|
||||
|
||||
virtual void drawImmediateMode(State& state);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
DrawPixels& operator = (const DrawPixels&) { return *this;}
|
||||
|
||||
virtual ~DrawPixels();
|
||||
|
||||
virtual const bool computeBound() const;
|
||||
|
||||
Vec3 _position;
|
||||
ref_ptr<Image> _image;
|
||||
|
||||
bool _useSubImage;
|
||||
unsigned int _offsetX, _offsetY, _width, _height;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -33,6 +33,11 @@ class SG_EXPORT Image : public Object
|
||||
inline const std::string& getFileName() const { return _fileName; }
|
||||
void setFileName(const std::string& fileName);
|
||||
|
||||
|
||||
void createImage(const int s,const int t,const int r,
|
||||
const unsigned int pixelFormat,const unsigned int dataType);
|
||||
|
||||
|
||||
/** set the image data and format.
|
||||
* note, when the packing value is negative (the default is -1) this method assumes
|
||||
* a _packing width of 1 if the width is not a multiple of 4,
|
||||
@@ -40,11 +45,17 @@ class SG_EXPORT Image : public Object
|
||||
* value of packing is supplied than _packing is simply set to that value.
|
||||
*/
|
||||
void setImage(const int s,const int t,const int r,
|
||||
const int internalFormat,
|
||||
const unsigned int pixelFormat,
|
||||
const unsigned int dataType,
|
||||
unsigned char *data,
|
||||
const int packing=-1);
|
||||
const int internalFormat,const unsigned int pixelFormat,const unsigned int dataType,
|
||||
unsigned char *data,
|
||||
const int packing=-1);
|
||||
|
||||
/** readPixels from screen at specified position and size, using glReadPixels.
|
||||
* Create memory for storage if required, reuse existing pixel coords if possible.
|
||||
* if pixelFormat or dataType*/
|
||||
void readPixels(int x,int y,int width,int height,
|
||||
unsigned int pixelFormat,unsigned int dataType,
|
||||
const int packing=-1);
|
||||
|
||||
|
||||
/** Width of image.*/
|
||||
inline const int s() const { return _s; }
|
||||
@@ -54,10 +65,15 @@ class SG_EXPORT Image : public Object
|
||||
inline const int r() const { return _r; }
|
||||
|
||||
inline const int internalFormat() const { return _internalFormat; }
|
||||
|
||||
inline const unsigned int pixelFormat() const { return _pixelFormat; }
|
||||
|
||||
inline const unsigned int dataType() const { return _dataType; }
|
||||
|
||||
inline const unsigned int packing() const { return _packing; }
|
||||
|
||||
inline const unsigned int pixelSizeInBits() const { return _pixelSizeInBits; }
|
||||
|
||||
/** raw image data.*/
|
||||
inline unsigned char *data() { return _data; }
|
||||
|
||||
@@ -88,12 +104,15 @@ class SG_EXPORT Image : public Object
|
||||
|
||||
Image& operator = (const Image&) { return *this; }
|
||||
|
||||
void computePixelSize();
|
||||
|
||||
std::string _fileName;
|
||||
int _s, _t, _r;
|
||||
int _internalFormat;
|
||||
unsigned int _pixelFormat;
|
||||
unsigned int _dataType;
|
||||
unsigned int _packing;
|
||||
unsigned int _pixelSizeInBits;
|
||||
unsigned char *_data;
|
||||
|
||||
unsigned int _modifiedTag;
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
// For systems that don't have the __FUNCTION__ variable, we can just define it here
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef __FUNCTION__
|
||||
#define __FUNCTION__ "??"
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------
|
||||
// Types
|
||||
|
||||
Reference in New Issue
Block a user