TextureCubeMap
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_TEXTURECUBEMAP
#define OSG_TEXTURECUBEMAP 1
#include <osg/Texture>
namespace osg {
class OSG_EXPORT TextureCubeMap : public Texture
{
public :
TextureCubeMap();
TextureCubeMap(const TextureCubeMap& cm,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, TextureCubeMap,TEXTURE);
virtual int compare(const StateAttribute& rhs) const;
virtual GLenum getTextureTarget() const { return GL_TEXTURE_CUBE_MAP; }
enum Face {
POSITIVE_X=0,
NEGATIVE_X=1,
POSITIVE_Y=2,
NEGATIVE_Y=3,
POSITIVE_Z=4,
NEGATIVE_Z=5
};
virtual void setImage(unsigned int face, Image* image);
template<class T> void setImage(unsigned int face, const ref_ptr<T>& image) { setImage(face, image.get()); }
virtual Image* getImage(unsigned int face);
virtual const Image* getImage(unsigned int face) const;
virtual unsigned int getNumImages() const { return 6; }
virtual bool isDirty(unsigned int contextID) const
{
return (_images[0].valid() && _images[0]->getModifiedCount()!=_modifiedCount[0][contextID]) ||
(_images[1].valid() && _images[1]->getModifiedCount()!=_modifiedCount[1][contextID]) ||
(_images[2].valid() && _images[2]->getModifiedCount()!=_modifiedCount[2][contextID]) ||
(_images[3].valid() && _images[3]->getModifiedCount()!=_modifiedCount[3][contextID]) ||
(_images[4].valid() && _images[4]->getModifiedCount()!=_modifiedCount[4][contextID]) ||
(_images[5].valid() && _images[5]->getModifiedCount()!=_modifiedCount[5][contextID]);
}
inline unsigned int& getModifiedCount(unsigned int face,unsigned int contextID) const
{
// get the modified count for the current contextID.
return _modifiedCount[face][contextID];
}
inline void setTextureSize(int width, int height) const
{
_textureWidth = width;
_textureHeight = height;
}
void setTextureWidth(int width) { _textureWidth=width; }
void setTextureHeight(int height) { _textureHeight=height; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return _textureHeight; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced
{
public:
virtual void load(const TextureCubeMap& texture,State& state) const = 0;
virtual void subload(const TextureCubeMap& texture,State& state) const = 0;
};
void setSubloadCallback(SubloadCallback* cb) { _subloadCallback = cb;; }
SubloadCallback* getSubloadCallback() { return _subloadCallback.get(); }
const SubloadCallback* getSubloadCallback() const { return _subloadCallback.get(); }
void setNumMipmapLevels(unsigned int num) const { _numMipmapLevels=num; }
unsigned int getNumMipmapLevels() const { return _numMipmapLevels; }
void copyTexSubImageCubeMap(State& state, int face, int xoffset, int yoffset, int x, int y, int width, int height );
virtual void apply(State& state) const;
protected :
virtual ~TextureCubeMap();
bool imagesValid() const;
virtual void computeInternalFormat() const;
void allocateMipmap(State& state) const;
ref_ptr<Image> _images[6];
// subloaded images can have different texture and image sizes.
mutable GLsizei _textureWidth, _textureHeight;
// number of mip map levels the texture has been created with,
mutable GLsizei _numMipmapLevels;
ref_ptr<SubloadCallback> _subloadCallback;
typedef buffered_value<unsigned int> ImageModifiedCount;
mutable ImageModifiedCount _modifiedCount[6];
};
}
#endif
Texture
GL_TEXTURE_CUBE_MAP
#define GL_TEXTURE_CUBE_MAP
Definition Texture:193
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Image
Definition Image:179
osg::Referenced::Referenced
Referenced()
osg::StateAttribute
Definition StateAttribute:77
osg::StateAttribute::TEXTURE
@ TEXTURE
Definition StateAttribute:125
osg::State
Definition State:80
osg::TextureCubeMap::SubloadCallback
Definition TextureCubeMap:98
osg::TextureCubeMap::SubloadCallback::subload
virtual void subload(const TextureCubeMap &texture, State &state) const =0
osg::TextureCubeMap::SubloadCallback::load
virtual void load(const TextureCubeMap &texture, State &state) const =0
osg::TextureCubeMap::getSubloadCallback
SubloadCallback * getSubloadCallback()
Definition TextureCubeMap:106
osg::TextureCubeMap::getModifiedCount
unsigned int & getModifiedCount(unsigned int face, unsigned int contextID) const
Definition TextureCubeMap:75
osg::TextureCubeMap::compare
virtual int compare(const StateAttribute &rhs) const
osg::TextureCubeMap::getNumImages
virtual unsigned int getNumImages() const
Definition TextureCubeMap:61
osg::TextureCubeMap::getNumMipmapLevels
unsigned int getNumMipmapLevels() const
Definition TextureCubeMap:117
osg::TextureCubeMap::TextureCubeMap
TextureCubeMap()
osg::TextureCubeMap::_modifiedCount
ImageModifiedCount _modifiedCount[6]
Definition TextureCubeMap:154
osg::TextureCubeMap::setTextureHeight
void setTextureHeight(int height)
Definition TextureCubeMap:91
osg::TextureCubeMap::getTextureDepth
virtual int getTextureDepth() const
Definition TextureCubeMap:95
osg::TextureCubeMap::setTextureSize
void setTextureSize(int width, int height) const
Definition TextureCubeMap:84
osg::TextureCubeMap::setImage
virtual void setImage(unsigned int face, Image *image)
osg::TextureCubeMap::getSubloadCallback
const SubloadCallback * getSubloadCallback() const
Definition TextureCubeMap:108
osg::TextureCubeMap::apply
virtual void apply(State &state) const
osg::TextureCubeMap::imagesValid
bool imagesValid() const
osg::TextureCubeMap::setNumMipmapLevels
void setNumMipmapLevels(unsigned int num) const
Definition TextureCubeMap:114
osg::TextureCubeMap::_textureHeight
GLsizei _textureHeight
Definition TextureCubeMap:146
osg::TextureCubeMap::_numMipmapLevels
GLsizei _numMipmapLevels
Definition TextureCubeMap:149
osg::TextureCubeMap::getTextureHeight
virtual int getTextureHeight() const
Definition TextureCubeMap:94
osg::TextureCubeMap::TextureCubeMap
TextureCubeMap(const TextureCubeMap &cm, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::TextureCubeMap::_subloadCallback
ref_ptr< SubloadCallback > _subloadCallback
Definition TextureCubeMap:151
osg::TextureCubeMap::allocateMipmap
void allocateMipmap(State &state) const
osg::TextureCubeMap::setSubloadCallback
void setSubloadCallback(SubloadCallback *cb)
Definition TextureCubeMap:104
osg::TextureCubeMap::computeInternalFormat
virtual void computeInternalFormat() const
osg::TextureCubeMap::copyTexSubImageCubeMap
void copyTexSubImageCubeMap(State &state, int face, int xoffset, int yoffset, int x, int y, int width, int height)
osg::TextureCubeMap::_textureWidth
GLsizei _textureWidth
Definition TextureCubeMap:146
osg::TextureCubeMap::getTextureTarget
virtual GLenum getTextureTarget() const
Definition TextureCubeMap:38
osg::TextureCubeMap::~TextureCubeMap
virtual ~TextureCubeMap()
osg::TextureCubeMap::META_StateAttribute
META_StateAttribute(osg, TextureCubeMap, TEXTURE)
osg::TextureCubeMap::isDirty
virtual bool isDirty(unsigned int contextID) const
Definition TextureCubeMap:65
osg::TextureCubeMap::getTextureWidth
virtual int getTextureWidth() const
Definition TextureCubeMap:93
osg::TextureCubeMap::Face
Face
Definition TextureCubeMap:40
osg::TextureCubeMap::POSITIVE_X
@ POSITIVE_X
Definition TextureCubeMap:41
osg::TextureCubeMap::NEGATIVE_Y
@ NEGATIVE_Y
Definition TextureCubeMap:44
osg::TextureCubeMap::POSITIVE_Y
@ POSITIVE_Y
Definition TextureCubeMap:43
osg::TextureCubeMap::NEGATIVE_X
@ NEGATIVE_X
Definition TextureCubeMap:42
osg::TextureCubeMap::POSITIVE_Z
@ POSITIVE_Z
Definition TextureCubeMap:45
osg::TextureCubeMap::NEGATIVE_Z
@ NEGATIVE_Z
Definition TextureCubeMap:46
osg::TextureCubeMap::_images
ref_ptr< Image > _images[6]
Definition TextureCubeMap:143
osg::TextureCubeMap::getImage
virtual const Image * getImage(unsigned int face) const
osg::TextureCubeMap::getImage
virtual Image * getImage(unsigned int face)
osg::TextureCubeMap::setTextureWidth
void setTextureWidth(int width)
Definition TextureCubeMap:90
osg::TextureCubeMap::setImage
void setImage(unsigned int face, const ref_ptr< T > &image)
Definition TextureCubeMap:52
osg::TextureCubeMap::ImageModifiedCount
buffered_value< unsigned int > ImageModifiedCount
Definition TextureCubeMap:153
osg::Texture::Texture
Texture()
osg::buffered_value
Definition buffered_value:27
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39