Texture1D
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.
*/
// -*-c++-*-
#ifndef OSG_TEXTURE1D
#define OSG_TEXTURE1D 1
#include <osg/Texture>
#ifndef GL_TEXTURE_1D
#define GL_TEXTURE_1D 0x0DE0
#endif
namespace osg {
class OSG_EXPORT Texture1D : public Texture
{
public :
Texture1D();
Texture1D(Image* image);
template<class T> Texture1D(const osg::ref_ptr<T>& image):
_textureWidth(0),
_numMipmapLevels(0)
{
setImage(image.get());
}
Texture1D(const Texture1D& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, Texture1D,TEXTURE);
virtual int compare(const StateAttribute& rhs) const;
virtual GLenum getTextureTarget() const { return GL_TEXTURE_1D; }
void setImage(Image* image);
template<class T> void setImage(const ref_ptr<T>& image) { setImage(image.get()); }
Image* getImage() { return _image.get(); }
inline const Image* getImage() const { return _image.get(); }
virtual bool isDirty(unsigned int contextID) const { return (_image.valid() && _image->getModifiedCount()!=_modifiedCount[contextID]); }
inline unsigned int& getModifiedCount(unsigned int contextID) const
{
// get the modified count for the current contextID.
return _modifiedCount[contextID];
}
virtual void setImage(unsigned int, Image* image) { setImage(image); }
virtual Image* getImage(unsigned int) { return _image.get(); }
virtual const Image* getImage(unsigned int) const { return _image.get(); }
virtual unsigned int getNumImages() const { return 1; }
inline void setTextureWidth(int width) { _textureWidth = width; }
virtual int getTextureWidth() const { return _textureWidth; }
virtual int getTextureHeight() const { return 1; }
virtual int getTextureDepth() const { return 1; }
class OSG_EXPORT SubloadCallback : public Referenced
{
public:
virtual void load(const Texture1D& texture,State& state) const = 0;
virtual void subload(const Texture1D& 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 copyTexImage1D(State& state, int x, int y, int width);
void copyTexSubImage1D(State& state, int xoffset, int x, int y, int width);
virtual void apply(State& state) const;
protected :
virtual ~Texture1D();
virtual void computeInternalFormat() const;
void allocateMipmap(State& state) const;
void applyTexImage1D(GLenum target, Image* image, State& state, GLsizei& width, GLsizei& numMipmapLevels) const;
mutable ref_ptr<Image> _image;
mutable GLsizei _textureWidth;
mutable GLsizei _numMipmapLevels;
ref_ptr<SubloadCallback> _subloadCallback;
typedef buffered_value<unsigned int> ImageModifiedCount;
mutable ImageModifiedCount _modifiedCount;
};
}
#endif
GL_TEXTURE_1D
#define GL_TEXTURE_1D
Definition Texture1D:22
Texture
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::Texture1D::SubloadCallback
Definition Texture1D:103
osg::Texture1D::SubloadCallback::load
virtual void load(const Texture1D &texture, State &state) const =0
osg::Texture1D::SubloadCallback::subload
virtual void subload(const Texture1D &texture, State &state) const =0
osg::Texture1D::getModifiedCount
unsigned int & getModifiedCount(unsigned int contextID) const
Definition Texture1D:72
osg::Texture1D::~Texture1D
virtual ~Texture1D()
osg::Texture1D::getImage
const Image * getImage() const
Definition Texture1D:65
osg::Texture1D::setSubloadCallback
void setSubloadCallback(SubloadCallback *cb)
Definition Texture1D:109
osg::Texture1D::Texture1D
Texture1D(Image *image)
osg::Texture1D::getImage
virtual Image * getImage(unsigned int)
Definition Texture1D:83
osg::Texture1D::allocateMipmap
void allocateMipmap(State &state) const
osg::Texture1D::getSubloadCallback
SubloadCallback * getSubloadCallback()
Definition Texture1D:111
osg::Texture1D::_numMipmapLevels
GLsizei _numMipmapLevels
Definition Texture1D:164
osg::Texture1D::Texture1D
Texture1D(const osg::ref_ptr< T > &image)
Definition Texture1D:39
osg::Texture1D::_image
ref_ptr< Image > _image
Definition Texture1D:158
osg::Texture1D::META_StateAttribute
META_StateAttribute(osg, Texture1D, TEXTURE)
osg::Texture1D::apply
virtual void apply(State &state) const
osg::Texture1D::getImage
Image * getImage()
Definition Texture1D:62
osg::Texture1D::getTextureTarget
virtual GLenum getTextureTarget() const
Definition Texture1D:54
osg::Texture1D::setNumMipmapLevels
void setNumMipmapLevels(unsigned int num) const
Definition Texture1D:119
osg::Texture1D::getImage
virtual const Image * getImage(unsigned int) const
Definition Texture1D:86
osg::Texture1D::applyTexImage1D
void applyTexImage1D(GLenum target, Image *image, State &state, GLsizei &width, GLsizei &numMipmapLevels) const
osg::Texture1D::_modifiedCount
ImageModifiedCount _modifiedCount
Definition Texture1D:169
osg::Texture1D::ImageModifiedCount
buffered_value< unsigned int > ImageModifiedCount
Definition Texture1D:168
osg::Texture1D::_textureWidth
GLsizei _textureWidth
Definition Texture1D:161
osg::Texture1D::compare
virtual int compare(const StateAttribute &rhs) const
osg::Texture1D::Texture1D
Texture1D(const Texture1D &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::Texture1D::getTextureDepth
virtual int getTextureDepth() const
Definition Texture1D:99
osg::Texture1D::setTextureWidth
void setTextureWidth(int width)
Definition Texture1D:94
osg::Texture1D::getTextureWidth
virtual int getTextureWidth() const
Definition Texture1D:97
osg::Texture1D::isDirty
virtual bool isDirty(unsigned int contextID) const
Definition Texture1D:69
osg::Texture1D::_subloadCallback
ref_ptr< SubloadCallback > _subloadCallback
Definition Texture1D:166
osg::Texture1D::Texture1D
Texture1D()
osg::Texture1D::getNumImages
virtual unsigned int getNumImages() const
Definition Texture1D:89
osg::Texture1D::getTextureHeight
virtual int getTextureHeight() const
Definition Texture1D:98
osg::Texture1D::copyTexImage1D
void copyTexImage1D(State &state, int x, int y, int width)
osg::Texture1D::getSubloadCallback
const SubloadCallback * getSubloadCallback() const
Definition Texture1D:113
osg::Texture1D::setImage
void setImage(Image *image)
osg::Texture1D::copyTexSubImage1D
void copyTexSubImage1D(State &state, int xoffset, int x, int y, int width)
osg::Texture1D::computeInternalFormat
virtual void computeInternalFormat() const
osg::Texture1D::setImage
void setImage(const ref_ptr< T > &image)
Definition Texture1D:59
osg::Texture1D::setImage
virtual void setImage(unsigned int, Image *image)
Definition Texture1D:80
osg::Texture1D::getNumMipmapLevels
unsigned int getNumMipmapLevels() const
Definition Texture1D:122
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