OpenSceneGraph 3.6.5
TextureBuffer
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14// -*-c++-*-
15
16#ifndef OSG_TEXTUREBUFFEROBJECT
17#define OSG_TEXTUREBUFFEROBJECT 1
18
19#include <osg/Texture>
20#include <osg/BufferObject>
21
22namespace osg {
23
27{
28
29 public :
30
32
34
37
39
41 virtual int compare(const StateAttribute& rhs) const;
42
43 virtual GLenum getTextureTarget() const { return GL_TEXTURE_BUFFER; }
44
46 void setImage(Image* image);
47
49 Image* getImage() { return dynamic_cast<Image*>(_bufferData.get() ); }
50
52 inline const Image* getImage() const { return dynamic_cast<Image*>(_bufferData.get() ); }
53
55 virtual bool isDirty(unsigned int contextID) const { return (_bufferData.valid() && _bufferData->getModifiedCount()!=_modifiedCount[contextID]); }
56
57 inline unsigned int & getModifiedCount(unsigned int contextID) const
58 {
59 // get the modified count for the current contextID.
60 return _modifiedCount[contextID];
61 }
62
64 virtual void setImage(unsigned int, Image* image) { setImage(image); }
65
67 virtual Image* getImage(unsigned int) { return getImage(); }
68
70 virtual const Image* getImage(unsigned int) const { return getImage(); }
71
73 virtual unsigned int getNumImages() const { return 1; }
74
75
78 inline void setTextureWidth(int width) { _textureWidth = width; }
79
81 virtual int getTextureWidth() const { return _textureWidth; }
82 virtual int getTextureHeight() const { return 1; }
83 virtual int getTextureDepth() const { return 1; }
84
85 virtual void allocateMipmap(State& /*state*/) const {};
86
88 virtual void apply(State& state) const;
89
92
94 const BufferData * getBufferData()const {return _bufferData.get();}
95 protected :
96
97 virtual ~TextureBuffer();
98
99 virtual void computeInternalFormat() const;
100
102
104
107
108
109 };
110
111}
112
113#endif
#define GL_TEXTURE_BUFFER
Definition GLDefines:402
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Definition BufferObject:495
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Image class for encapsulating the storage texture image data.
Definition Image:179
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Base class for state attributes.
Definition StateAttribute:77
@ TEXTURE
Definition StateAttribute:125
virtual void computeInternalFormat() const
virtual void apply(State &state) const
Bind the texture buffer.
virtual Image * getImage(unsigned int)
Gets the texture image, ignoring face.
Definition TextureBuffer:67
buffered_value< unsigned int > BufferDataModifiedCount
Definition TextureBuffer:105
ref_ptr< BufferData > _bufferData
Definition TextureBuffer:101
TextureBuffer(const TextureBuffer &text, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
virtual void setImage(unsigned int, Image *image)
Sets the texture image, ignoring face.
Definition TextureBuffer:64
virtual unsigned int getNumImages() const
Gets the number of images that can be assigned to the Texture.
Definition TextureBuffer:73
virtual int getTextureHeight() const
Definition TextureBuffer:82
TextureBuffer(BufferData *image)
virtual ~TextureBuffer()
void setImage(Image *image)
Sets the texture image.
void setTextureWidth(int width)
Sets the texture width.
Definition TextureBuffer:78
unsigned int & getModifiedCount(unsigned int contextID) const
Definition TextureBuffer:57
GLsizei _textureWidth
Definition TextureBuffer:103
virtual int getTextureWidth() const
Gets the texture width.
Definition TextureBuffer:81
virtual int compare(const StateAttribute &rhs) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
virtual const Image * getImage(unsigned int) const
Gets the const texture image, ignoring face.
Definition TextureBuffer:70
const Image * getImage() const
Gets the const texture image.
Definition TextureBuffer:52
Image * getImage()
Gets the texture image.
Definition TextureBuffer:49
META_StateAttribute(osg, TextureBuffer, TEXTURE)
virtual void allocateMipmap(State &) const
Allocate mipmap levels of the texture by subsequent calling of glTexImage* function.
Definition TextureBuffer:85
BufferDataModifiedCount _modifiedCount
Definition TextureBuffer:106
virtual int getTextureDepth() const
Definition TextureBuffer:83
virtual GLenum getTextureTarget() const
Definition TextureBuffer:43
virtual bool isDirty(unsigned int contextID) const
return true if the texture image data has been modified and the associated GL texture object needs to...
Definition TextureBuffer:55
const BufferData * getBufferData() const
Set setBufferData attached.
Definition TextureBuffer:94
void setBufferData(BufferData *bo)
Set setBufferData attached.
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.