Added support s/getImage(uint i) and getNumImages().

This commit is contained in:
Robert Osfield
2004-07-27 10:11:45 +00:00
parent a4f93740d1
commit bb5576bef8
14 changed files with 91 additions and 35 deletions

View File

@@ -27,6 +27,8 @@ using namespace std;
Image::Image()
{
setDataVariance(STATIC);
_fileName = "";
_s = _t = _r = 0;
_internalTextureFormat = 0;

View File

@@ -18,6 +18,7 @@ using namespace osg;
ImageStream::ImageStream():
_status(PAUSED)
{
setDataVariance(DYNAMIC);
}
ImageStream::ImageStream(const ImageStream& image,const CopyOp& copyop):

View File

@@ -152,17 +152,11 @@ void Texture1D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
{
Texture1D* non_const_this = const_cast<Texture1D*>(this);
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

View File

@@ -188,7 +188,7 @@ void Texture2D::apply(State& state) const
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
{
Texture2D* non_const_this = const_cast<Texture2D*>(this);
non_const_this->_image = 0;

View File

@@ -168,18 +168,12 @@ void Texture3D::apply(State& state) const
// update the modified tag to show that it is upto date.
getModifiedTag(contextID) = _image->getModifiedTag();
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded())
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
{
Texture3D* non_const_this = const_cast<Texture3D*>(this);
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
{

View File

@@ -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;
_modifiedTag[face].setAllElementsTo(0);
}
Image* TextureCubeMap::getImage(Face face)
Image* TextureCubeMap::getImage(unsigned int face)
{
return _images[face].get();
}
const Image* TextureCubeMap::getImage(Face face) const
const Image* TextureCubeMap::getImage(unsigned int face) const
{
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);
for (int n=0; n<6; n++)
@@ -292,12 +292,6 @@ void TextureCubeMap::apply(State& state) const
non_const_this->_images[n] = 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_CUBE_MAP, handle );
}
else

View File

@@ -182,11 +182,11 @@ void TextureRectangle::apply(State& state) const
textureObject->setAllocated(1,_internalFormat,_textureWidth,_textureHeight,1,0);
// in theory the following line is redundant, 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_RECTANGLE, handle);
if (_unrefImageDataAfterApply && areAllTextureObjectsLoaded() && getDataVariance()==STATIC)
{
TextureRectangle* non_const_this = const_cast<TextureRectangle*>(this);
non_const_this->_image = 0;
}
}
else
{