Added support s/getImage(uint i) and getNumImages().
This commit is contained in:
parent
a4f93740d1
commit
bb5576bef8
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <osg/Export>
|
#include <osg/Export>
|
||||||
|
|
||||||
#define USE_REF_MUTEX 1
|
// #define USE_REF_MUTEX 1
|
||||||
|
|
||||||
namespace osg {
|
namespace osg {
|
||||||
|
|
||||||
|
@ -315,6 +315,20 @@ class SG_EXPORT Texture : public osg::StateAttribute
|
|||||||
void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
|
void setShadowAmbient(float shadow_ambient) { _shadow_ambient = shadow_ambient; }
|
||||||
float getShadowAmbient() { return _shadow_ambient; }
|
float getShadowAmbient() { return _shadow_ambient; }
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the texture image for specified face. */
|
||||||
|
virtual void setImage(unsigned int face, Image* image) = 0;
|
||||||
|
|
||||||
|
/** Get the texture image for specified face. */
|
||||||
|
virtual Image* getImage(unsigned int face) = 0;
|
||||||
|
|
||||||
|
/** Get the const texture image for specified face. */
|
||||||
|
virtual const Image* getImage(unsigned int face) const = 0;
|
||||||
|
|
||||||
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const = 0;
|
||||||
|
|
||||||
|
|
||||||
/** Texture is pure virtual base class, apply must be overriden. */
|
/** Texture is pure virtual base class, apply must be overriden. */
|
||||||
virtual void apply(State& state) const = 0;
|
virtual void apply(State& state) const = 0;
|
||||||
|
|
||||||
|
@ -58,6 +58,19 @@ class SG_EXPORT Texture1D : public Texture
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the texture image, ignoring face. as there is only one image*/
|
||||||
|
virtual void setImage(unsigned int, Image* image) { setImage(image); }
|
||||||
|
|
||||||
|
/** Get the texture image, ignoring face value as there is only one image. */
|
||||||
|
virtual Image* getImage(unsigned int) { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the const texture image , ignoring face value as there is only one image. */
|
||||||
|
virtual const Image* getImage(unsigned int) const { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const { return 1; }
|
||||||
|
|
||||||
|
|
||||||
/** Set the texture width and height. If width or height are zero then
|
/** Set the texture width and height. If width or height are zero then
|
||||||
* the repsective size value is calculated from the source image sizes. */
|
* the repsective size value is calculated from the source image sizes. */
|
||||||
inline void setTextureSize(int width) const
|
inline void setTextureSize(int width) const
|
||||||
|
@ -57,6 +57,20 @@ class SG_EXPORT Texture2D : public Texture
|
|||||||
return _modifiedTag[contextID];
|
return _modifiedTag[contextID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the texture image, ignoring face. as there is only one image*/
|
||||||
|
virtual void setImage(unsigned int, Image* image) { setImage(image); }
|
||||||
|
|
||||||
|
/** Get the texture image, ignoring face value as there is only one image. */
|
||||||
|
virtual Image* getImage(unsigned int) { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the const texture image , ignoring face value as there is only one image. */
|
||||||
|
virtual const Image* getImage(unsigned int) const { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const { return 1; }
|
||||||
|
|
||||||
|
|
||||||
/** Set the texture width and height. If width or height are zero then
|
/** Set the texture width and height. If width or height are zero then
|
||||||
* the repsective size value is calculated from the source image sizes. */
|
* the repsective size value is calculated from the source image sizes. */
|
||||||
inline void setTextureSize(int width, int height) const
|
inline void setTextureSize(int width, int height) const
|
||||||
|
@ -55,6 +55,19 @@ class SG_EXPORT Texture3D : public Texture
|
|||||||
return _modifiedTag[contextID];
|
return _modifiedTag[contextID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Set the texture image, ignoring face. as there is only one image*/
|
||||||
|
virtual void setImage(unsigned int, Image* image) { setImage(image); }
|
||||||
|
|
||||||
|
/** Get the texture image, ignoring face value as there is only one image. */
|
||||||
|
virtual Image* getImage(unsigned int) { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the const texture image , ignoring face value as there is only one image. */
|
||||||
|
virtual const Image* getImage(unsigned int) const { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const { return 1; }
|
||||||
|
|
||||||
|
|
||||||
/** Set the texture width and height. If width or height are zero then
|
/** Set the texture width and height. If width or height are zero then
|
||||||
* the repsective size value is calculated from the source image sizes. */
|
* the repsective size value is calculated from the source image sizes. */
|
||||||
inline void setTextureSize(int width, int height, int depth) const
|
inline void setTextureSize(int width, int height, int depth) const
|
||||||
|
@ -54,15 +54,18 @@ class SG_EXPORT TextureCubeMap : public Texture
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Set the texture image for specified face. */
|
/** Set the texture image for specified face. */
|
||||||
void setImage(Face, Image* image);
|
virtual void setImage(unsigned int face, Image* image);
|
||||||
|
|
||||||
/** Get the texture image for specified face. */
|
/** Get the texture image for specified face. */
|
||||||
Image* getImage(Face);
|
virtual Image* getImage(unsigned int face);
|
||||||
|
|
||||||
/** Get the const texture image for specified face. */
|
/** Get the const texture image for specified face. */
|
||||||
const Image* getImage(Face) const;
|
virtual const Image* getImage(unsigned int face) const;
|
||||||
|
|
||||||
inline unsigned int& getModifiedTag(Face face,unsigned int contextID) const
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const { return 6; }
|
||||||
|
|
||||||
|
inline unsigned int& getModifiedTag(unsigned int face,unsigned int contextID) const
|
||||||
{
|
{
|
||||||
// get the modified tag for the current contextID.
|
// get the modified tag for the current contextID.
|
||||||
return _modifiedTag[face][contextID];
|
return _modifiedTag[face][contextID];
|
||||||
|
@ -65,6 +65,20 @@ class SG_EXPORT TextureRectangle : public Texture
|
|||||||
return _modifiedTag[contextID];
|
return _modifiedTag[contextID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** Set the texture image, ignoring face. as there is only one image*/
|
||||||
|
virtual void setImage(unsigned int, Image* image) { setImage(image); }
|
||||||
|
|
||||||
|
/** Get the texture image, ignoring face value as there is only one image. */
|
||||||
|
virtual Image* getImage(unsigned int) { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the const texture image , ignoring face value as there is only one image. */
|
||||||
|
virtual const Image* getImage(unsigned int) const { return _image.get(); }
|
||||||
|
|
||||||
|
/** Get the number of images that can be assigned to the Texture. */
|
||||||
|
virtual unsigned int getNumImages() const { return 1; }
|
||||||
|
|
||||||
|
|
||||||
/** Set the texture width and height. If width or height are zero then
|
/** Set the texture width and height. If width or height are zero then
|
||||||
* the repsective size value is calculated from the source image sizes. */
|
* the repsective size value is calculated from the source image sizes. */
|
||||||
inline void setTextureSize(int width, int height) const
|
inline void setTextureSize(int width, int height) const
|
||||||
|
@ -27,6 +27,8 @@ using namespace std;
|
|||||||
|
|
||||||
Image::Image()
|
Image::Image()
|
||||||
{
|
{
|
||||||
|
setDataVariance(STATIC);
|
||||||
|
|
||||||
_fileName = "";
|
_fileName = "";
|
||||||
_s = _t = _r = 0;
|
_s = _t = _r = 0;
|
||||||
_internalTextureFormat = 0;
|
_internalTextureFormat = 0;
|
||||||
|
@ -18,6 +18,7 @@ using namespace osg;
|
|||||||
ImageStream::ImageStream():
|
ImageStream::ImageStream():
|
||||||
_status(PAUSED)
|
_status(PAUSED)
|
||||||
{
|
{
|
||||||
|
setDataVariance(DYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageStream::ImageStream(const ImageStream& image,const CopyOp& copyop):
|
ImageStream::ImageStream(const ImageStream& image,const CopyOp& copyop):
|
||||||
|
@ -152,18 +152,12 @@ void Texture1D::apply(State& state) const
|
|||||||
// update the modified tag to show that it is upto date.
|
// update the modified tag to show that it is upto date.
|
||||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||||
|
|
||||||
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
|
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
|
||||||
{
|
{
|
||||||
Texture1D* non_const_this = const_cast<Texture1D*>(this);
|
Texture1D* non_const_this = const_cast<Texture1D*>(this);
|
||||||
non_const_this->_image = 0;
|
non_const_this->_image = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in theory the following line is redundent, but in practice
|
|
||||||
// have found that the first frame drawn doesn't apply the textures
|
|
||||||
// unless a second bind is called?!!
|
|
||||||
// perhaps it is the first glBind which is not required...
|
|
||||||
//glBindTexture( GL_TEXTURE_1D, handle );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -188,7 +188,7 @@ void Texture2D::apply(State& state) const
|
|||||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||||
|
|
||||||
|
|
||||||
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
|
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
|
||||||
{
|
{
|
||||||
Texture2D* non_const_this = const_cast<Texture2D*>(this);
|
Texture2D* non_const_this = const_cast<Texture2D*>(this);
|
||||||
non_const_this->_image = 0;
|
non_const_this->_image = 0;
|
||||||
|
@ -168,18 +168,12 @@ void Texture3D::apply(State& state) const
|
|||||||
// update the modified tag to show that it is upto date.
|
// update the modified tag to show that it is upto date.
|
||||||
getModifiedTag(contextID) = _image->getModifiedTag();
|
getModifiedTag(contextID) = _image->getModifiedTag();
|
||||||
|
|
||||||
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
|
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
|
||||||
{
|
{
|
||||||
Texture3D* non_const_this = const_cast<Texture3D*>(this);
|
Texture3D* non_const_this = const_cast<Texture3D*>(this);
|
||||||
non_const_this->_image = 0;
|
non_const_this->_image = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// in theory the following line is redundent, but in practice
|
|
||||||
// have found that the first frame drawn doesn't apply the textures
|
|
||||||
// unless a second bind is called?!!
|
|
||||||
// perhaps it is the first glBind which is not required...
|
|
||||||
//glBindTexture( GL_TEXTURE_3D, handle );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -164,18 +164,18 @@ int TextureCubeMap::compare(const StateAttribute& sa) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextureCubeMap::setImage( Face face, Image* image)
|
void TextureCubeMap::setImage( unsigned int face, Image* image)
|
||||||
{
|
{
|
||||||
_images[face] = image;
|
_images[face] = image;
|
||||||
_modifiedTag[face].setAllElementsTo(0);
|
_modifiedTag[face].setAllElementsTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image* TextureCubeMap::getImage(Face face)
|
Image* TextureCubeMap::getImage(unsigned int face)
|
||||||
{
|
{
|
||||||
return _images[face].get();
|
return _images[face].get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Image* TextureCubeMap::getImage(Face face) const
|
const Image* TextureCubeMap::getImage(unsigned int face) const
|
||||||
{
|
{
|
||||||
return _images[face].get();
|
return _images[face].get();
|
||||||
}
|
}
|
||||||
@ -284,7 +284,7 @@ void TextureCubeMap::apply(State& state) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
|
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
|
||||||
{
|
{
|
||||||
TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this);
|
TextureCubeMap* non_const_this = const_cast<TextureCubeMap*>(this);
|
||||||
for (int n=0; n<6; n++)
|
for (int n=0; n<6; n++)
|
||||||
@ -293,12 +293,6 @@ void TextureCubeMap::apply(State& state) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in theory the following line is redundent, but in practice
|
|
||||||
// have found that the first frame drawn doesn't apply the textures
|
|
||||||
// unless a second bind is called?!!
|
|
||||||
// perhaps it is the first glBind which is not required...
|
|
||||||
//glBindTexture( GL_TEXTURE_CUBE_MAP, handle );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -182,11 +182,11 @@ void TextureRectangle::apply(State& state) const
|
|||||||
|
|
||||||
textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0);
|
textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0);
|
||||||
|
|
||||||
// in theory the following line is redundant, but in practice
|
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
|
||||||
// have found that the first frame drawn doesn't apply the textures
|
{
|
||||||
// unless a second bind is called?!!
|
TextureRectangle* non_const_this = const_cast<TextureRectangle*>(this);
|
||||||
// perhaps it is the first glBind which is not required...
|
non_const_this->_image = 0;
|
||||||
//glBindTexture(GL_TEXTURE_RECTANGLE, handle);
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user