diff --git a/include/osg/Image b/include/osg/Image index 909e01c46..dac63c91a 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -141,8 +141,10 @@ class OSG_EXPORT Image : public Object void setPixelFormat(GLenum pixelFormat); inline GLenum getPixelFormat() const { return _pixelFormat; } + void setDataType(GLenum dataType); inline GLenum getDataType() const { return _dataType; } + void setPacking(unsigned int packing) { _packing = packing; } inline unsigned int getPacking() const { return _packing; } /** Return the number of bits required for each pixel. */ diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index bc432281c..44410b9bc 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -334,7 +334,7 @@ void Image::setPixelFormat(GLenum pixelFormat) { if (_pixelFormat==pixelFormat) return; // do nothing if the same. - if (computeNumComponents(_pixelFormat)==computeNumComponents(pixelFormat)) + if (_pixelFormat==0 || computeNumComponents(_pixelFormat)==computeNumComponents(pixelFormat)) { // if the two formats have the same number of componets then // we can do a straight swap. @@ -346,6 +346,22 @@ void Image::setPixelFormat(GLenum pixelFormat) } } +void Image::setDataType(GLenum dataType) +{ + if (_dataType==dataType) return; // do nothing if the same. + + if (_dataType==0) + { + // setting the datatype for the first time + _dataType = dataType; + } + else + { + notify(WARN)<<"Image::setDataType(..) - warning, attempt to reset the data type not permitted."<