OpenSceneGraph 3.6.5
BufferIndexBinding
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 * Copyright (C) 2010 Tim Moore
3 * Copyright (C) 2012 David Callu
4 * Copyright (C) 2017 Julien Valentin
5 *
6 * This library is open source and may be redistributed and/or modified under
7 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
8 * (at your option) any later version. The full license is in LICENSE file
9 * included with this distribution, and on the openscenegraph.org website.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#ifndef OSG_BUFFERINDEXBINDING
18#define OSG_BUFFERINDEXBINDING 1
19
20#include <osg/Array>
21#include <osg/Export>
22#include <osg/BufferObject>
23#include <osg/StateAttribute>
24
25#ifndef GL_TRANSFORM_FEEDBACK_BUFFER
26 #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
27#endif
28
29
30namespace osg {
31
32class State;
33
38
39// Common implementation superclass
41{
42 protected:
43 BufferIndexBinding(GLenum target, GLuint index);
44 BufferIndexBinding(GLenum target, GLuint index, BufferData* bd, GLintptr offset=0, GLsizeiptr size=0);
46 public:
47 // The member value is part of the key to this state attribute in
48 // the State class. Using the index target, we can separately
49 // track the bindings for many different index targets.
50 virtual unsigned getMember() const { return static_cast<unsigned int>(_index); }
51 GLenum getTarget() const { return _target; }
54 void setTarget(GLenum t){_target=t;}
55
56 inline void setBufferData(BufferData *bufferdata) {
57 if (_bufferData.valid())
58 {
59 _bufferData->removeClient(this);
60 }
61
62 _bufferData=bufferdata;
63
64 if (_bufferData.valid())
65 {
66 if(!_bufferData->getBufferObject())
67 _bufferData->setBufferObject(new VertexBufferObject());
68 if(_size==0)
69 _size=_bufferData->getTotalDataSize();
70 }
71 }
72
74 inline const BufferData* getBufferData() const { return _bufferData.get(); }
75 inline BufferData* getBufferData(){ return _bufferData.get(); }
76
79 inline GLuint getIndex() const { return _index; }
82 void setIndex(GLuint index);
83
84
90 inline void setOffset(GLintptr offset) { _offset = offset; }
91 inline GLintptr getOffset() const { return _offset; }
92
95 inline void setSize(GLsizeiptr size) { _size = size; }
96 inline GLsizeiptr getSize() const { return _size; }
97
98 virtual void apply(State& state) const;
99
100 protected:
102 /*const*/ GLenum _target;
104 GLuint _index;
107};
108
137
159
189
215
216} // namespace osg
217
218#endif
#define COMPARE_StateAttribute_Parameter(parameter)
COMPARE_StateAttribute_Parameter macro is a helper for implementing the StatateAtribute::compare(....
Definition StateAttribute:69
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
COMPARE_StateAttribute_Types macro is a helper for implementing the StateAtribute::compare(....
Definition StateAttribute:57
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
TemplateIndexArray< GLuint, Array::UIntArrayType, 1, GL_UNSIGNED_INT > UIntArray
Definition Array:419
ptrdiff_t GLintptr
Definition GLDefines:692
ptrdiff_t GLsizeiptr
Definition GLDefines:691
void setTarget(GLenum t)
enable arbitrary BufferBinding (user is responsible for _target mismatch with bufferdata what can be ...
Definition BufferIndexBinding:54
BufferData * getBufferData()
Definition BufferIndexBinding:75
GLenum _target
Definition BufferIndexBinding:102
GLenum getTarget() const
Definition BufferIndexBinding:51
GLsizeiptr getSize() const
Definition BufferIndexBinding:96
void setIndex(GLuint index)
Set the index target.
GLintptr getOffset() const
Definition BufferIndexBinding:91
const BufferData * getBufferData() const
Get the buffer data to be bound.
Definition BufferIndexBinding:74
void setOffset(GLintptr offset)
Set the starting offset into the buffer data for the indexed target.
Definition BufferIndexBinding:90
GLuint getIndex() const
Get the index target.
Definition BufferIndexBinding:79
ref_ptr< BufferData > _bufferData
Definition BufferIndexBinding:103
virtual void apply(State &state) const
apply the OpenGL state attributes.
virtual unsigned getMember() const
Return the member identifier within the attribute's class type.
Definition BufferIndexBinding:50
BufferIndexBinding(GLenum target, GLuint index)
GLuint _index
Definition BufferIndexBinding:104
GLintptr _offset
Definition BufferIndexBinding:105
void setBufferData(BufferData *bufferdata)
Definition BufferIndexBinding:56
BufferIndexBinding(GLenum target, GLuint index, BufferData *bd, GLintptr offset=0, GLsizeiptr size=0)
BufferIndexBinding(const BufferIndexBinding &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
void setSize(GLsizeiptr size)
Set the size override of bufferdata binded for the indexed target.
Definition BufferIndexBinding:95
GLsizeiptr _size
Definition BufferIndexBinding:106
virtual int compare(const StateAttribute &bb) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition BufferIndexBinding:126
META_StateAttribute(osg, UniformBufferBinding, UNIFORMBUFFERBINDING)
UniformBufferBinding(const UniformBufferBinding &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
UniformBufferBinding(GLuint index)
UniformBufferBinding(GLuint index, BufferData *bd, GLintptr offset=0, GLsizeiptr size=0)
Create a binding for a uniform buffer index target.
TransformFeedbackBufferBinding(const TransformFeedbackBufferBinding &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
virtual int compare(const StateAttribute &bb) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition BufferIndexBinding:148
META_StateAttribute(osg, TransformFeedbackBufferBinding, TRANSFORMFEEDBACKBUFFERBINDING)
TransformFeedbackBufferBinding(GLuint index, BufferData *bd, GLintptr offset=0, GLsizeiptr size=0)
TransformFeedbackBufferBinding(GLuint index=0)
void readData(osg::State &state, osg::UIntArray &uintArray) const
AtomicCounterBufferBinding(const AtomicCounterBufferBinding &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
AtomicCounterBufferBinding(GLuint index, BufferData *bd, GLintptr offset=0, GLsizeiptr size=0)
Create a binding for a atomic counter buffer index target.
AtomicCounterBufferBinding(GLuint index=0)
virtual int compare(const StateAttribute &bb) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition BufferIndexBinding:178
META_StateAttribute(osg, AtomicCounterBufferBinding, ATOMICCOUNTERBUFFERBINDING)
ShaderStorageBufferBinding(GLuint index=0)
META_StateAttribute(osg, ShaderStorageBufferBinding, SHADERSTORAGEBUFFERBINDING)
ShaderStorageBufferBinding(const ShaderStorageBufferBinding &rhs, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
ShaderStorageBufferBinding(GLuint index, BufferData *bd, GLintptr offset=0, GLsizeiptr size=0)
Create a binding for a shader storage buffer index target.
virtual int compare(const StateAttribute &bb) const
Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.
Definition BufferIndexBinding:204
Definition BufferObject:495
Definition BufferObject:599
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
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
@ ATOMICCOUNTERBUFFERBINDING
Definition StateAttribute:195
@ SHADERSTORAGEBUFFERBINDING
Definition StateAttribute:203
@ UNIFORMBUFFERBINDING
Definition StateAttribute:192
@ TRANSFORMFEEDBACKBUFFERBINDING
Definition StateAttribute:193
#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.