TextureBuffer
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 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_TEXTUREBUFFEROBJECT
#define OSG_TEXTUREBUFFEROBJECT 1
#include <osg/Texture>
#include <osg/BufferObject>
namespace osg {
class OSG_EXPORT TextureBuffer : public Texture
{
public :
TextureBuffer();
TextureBuffer(BufferData* image);
TextureBuffer(const TextureBuffer& text,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_StateAttribute(osg, TextureBuffer, TEXTURE);
virtual int compare(const StateAttribute& rhs) const;
virtual GLenum getTextureTarget() const { return GL_TEXTURE_BUFFER; }
void setImage(Image* image);
Image* getImage() { return dynamic_cast<Image*>(_bufferData.get() ); }
inline const Image* getImage() const { return dynamic_cast<Image*>(_bufferData.get() ); }
virtual bool isDirty(unsigned int contextID) const { return (_bufferData.valid() && _bufferData->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 getImage(); }
virtual const Image* getImage(unsigned int) const { return getImage(); }
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; }
virtual void allocateMipmap(State& /*state*/) const {};
virtual void apply(State& state) const;
void setBufferData(BufferData *bo);
const BufferData * getBufferData()const {return _bufferData.get();}
protected :
virtual ~TextureBuffer();
virtual void computeInternalFormat() const;
ref_ptr< BufferData > _bufferData;
GLsizei _textureWidth;
typedef buffered_value< unsigned int > BufferDataModifiedCount;
mutable BufferDataModifiedCount _modifiedCount;
};
}
#endif
BufferObject
GL_TEXTURE_BUFFER
#define GL_TEXTURE_BUFFER
Definition GLDefines:402
Texture
osg::BufferData
Definition BufferObject:495
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Image
Definition Image:179
osg::StateAttribute
Definition StateAttribute:77
osg::StateAttribute::TEXTURE
@ TEXTURE
Definition StateAttribute:125
osg::State
Definition State:80
osg::TextureBuffer::computeInternalFormat
virtual void computeInternalFormat() const
osg::TextureBuffer::apply
virtual void apply(State &state) const
osg::TextureBuffer::getImage
virtual Image * getImage(unsigned int)
Definition TextureBuffer:67
osg::TextureBuffer::BufferDataModifiedCount
buffered_value< unsigned int > BufferDataModifiedCount
Definition TextureBuffer:105
osg::TextureBuffer::_bufferData
ref_ptr< BufferData > _bufferData
Definition TextureBuffer:101
osg::TextureBuffer::TextureBuffer
TextureBuffer(const TextureBuffer &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::TextureBuffer::TextureBuffer
TextureBuffer()
osg::TextureBuffer::setImage
virtual void setImage(unsigned int, Image *image)
Definition TextureBuffer:64
osg::TextureBuffer::getNumImages
virtual unsigned int getNumImages() const
Definition TextureBuffer:73
osg::TextureBuffer::getTextureHeight
virtual int getTextureHeight() const
Definition TextureBuffer:82
osg::TextureBuffer::TextureBuffer
TextureBuffer(BufferData *image)
osg::TextureBuffer::~TextureBuffer
virtual ~TextureBuffer()
osg::TextureBuffer::setImage
void setImage(Image *image)
osg::TextureBuffer::setTextureWidth
void setTextureWidth(int width)
Definition TextureBuffer:78
osg::TextureBuffer::getModifiedCount
unsigned int & getModifiedCount(unsigned int contextID) const
Definition TextureBuffer:57
osg::TextureBuffer::_textureWidth
GLsizei _textureWidth
Definition TextureBuffer:103
osg::TextureBuffer::getTextureWidth
virtual int getTextureWidth() const
Definition TextureBuffer:81
osg::TextureBuffer::compare
virtual int compare(const StateAttribute &rhs) const
osg::TextureBuffer::getImage
virtual const Image * getImage(unsigned int) const
Definition TextureBuffer:70
osg::TextureBuffer::getImage
const Image * getImage() const
Definition TextureBuffer:52
osg::TextureBuffer::getImage
Image * getImage()
Definition TextureBuffer:49
osg::TextureBuffer::META_StateAttribute
META_StateAttribute(osg, TextureBuffer, TEXTURE)
osg::TextureBuffer::allocateMipmap
virtual void allocateMipmap(State &) const
Definition TextureBuffer:85
osg::TextureBuffer::_modifiedCount
BufferDataModifiedCount _modifiedCount
Definition TextureBuffer:106
osg::TextureBuffer::getTextureDepth
virtual int getTextureDepth() const
Definition TextureBuffer:83
osg::TextureBuffer::getTextureTarget
virtual GLenum getTextureTarget() const
Definition TextureBuffer:43
osg::TextureBuffer::isDirty
virtual bool isDirty(unsigned int contextID) const
Definition TextureBuffer:55
osg::TextureBuffer::getBufferData
const BufferData * getBufferData() const
Definition TextureBuffer:94
osg::TextureBuffer::setBufferData
void setBufferData(BufferData *bo)
osg::Texture::Texture
Texture()
osg::buffered_value< unsigned int >
osg::ref_ptr
Definition ref_ptr:32
osg
Definition AlphaFunc:19
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39