OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BufferIndexBinding.h
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  *
5  * This library is open source and may be redistributed and/or modified under
6  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
7  * (at your option) any later version. The full license is in LICENSE file
8  * included with this distribution, and on the openscenegraph.org website.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * OpenSceneGraph Public License for more details.
14 */
15 
16 #ifndef OSG_BUFFERINDEXBINDING
17 #define OSG_BUFFERINDEXBINDING 1
18 
19 #include <osg/Array>
20 #include <osg/Export>
21 #include <osg/BufferObject>
22 #include <osg/StateAttribute>
23 
24 #ifndef GL_TRANSFORM_FEEDBACK_BUFFER
25  #define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
26 #endif
27 
28 
29 namespace osg {
30 
31 class State;
32 
38 // Common implementation superclass
40 {
41  protected:
42  BufferIndexBinding(GLenum target, GLuint index);
43  BufferIndexBinding(GLenum target, GLuint index, BufferObject* bo, GLintptr offset,
44  GLsizeiptr size);
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 
52  GLenum getTarget() const { return _target; }
55  GLuint getIndex() const { return _index; }
58  void setBufferObject(BufferObject *bo) { _bufferObject = bo; }
61  BufferObject* getBufferObject() const { return _bufferObject.get(); }
67  void setOffset(GLintptr offset) { _offset = offset; }
68  GLintptr getOffset() const { return _offset; }
71  void setSize(GLsizeiptr size) { _size = size; }
72  GLsizeiptr getSize() const { return _size; }
73  virtual void apply(State& state) const;
74  protected:
75  virtual ~BufferIndexBinding();
76  const GLenum _target;
77  const GLuint _index;
81 };
82 
86 {
87  public:
89  UniformBufferBinding(GLuint index);
96  UniformBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
98  META_StateAttribute(osg, UniformBufferBinding, UNIFORMBUFFERBINDING);
99 
100  virtual int compare(const StateAttribute& bb) const
101  {
103 
106  COMPARE_StateAttribute_Parameter(_bufferObject)
109  return 0;
110  }
111 };
112 
116 {
117  public:
118  TransformFeedbackBufferBinding(GLuint index = 0);
119  TransformFeedbackBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
121  META_StateAttribute(osg, TransformFeedbackBufferBinding, TRANSFORMFEEDBACKBUFFERBINDING);
122 
123  virtual int compare(const StateAttribute& bb) const
124  {
126 
129  COMPARE_StateAttribute_Parameter(_bufferObject)
132  return 0;
133  }
134 };
135 
139 {
140  public:
141  AtomicCounterBufferBinding(GLuint index=0);
148  AtomicCounterBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
150  META_StateAttribute(osg, AtomicCounterBufferBinding, ATOMICCOUNTERBUFFERBINDING);
151 
152  void readData(osg::State & state, osg::UIntArray & uintArray) const;
153 
154  virtual int compare(const StateAttribute& bb) const
155  {
157 
160  COMPARE_StateAttribute_Parameter(_bufferObject)
163  return 0;
164  }
165 };
166 
168 {
169  public:
170  ShaderStorageBufferBinding(GLuint index=0);
177  ShaderStorageBufferBinding(GLuint index, BufferObject* bo, GLintptr offset, GLsizeiptr size);
179  META_StateAttribute(osg, ShaderStorageBufferBinding, SHADERSTORAGEBUFFERBINDING);
180 
181  virtual int compare(const StateAttribute& bb) const
182  {
186  COMPARE_StateAttribute_Parameter(_bufferObject)
189  return 0;
190  }
191 };
192 
193 
194 
195 
196 } // namespace osg
197 
198 #endif
#define OSG_EXPORT
Definition: Export.h:43
void setOffset(GLintptr offset)
virtual unsigned getMember() const
#define COMPARE_StateAttribute_Types(TYPE, rhs_attribute)
BufferObject * getBufferObject() const
virtual int compare(const StateAttribute &bb) const
ptrdiff_t GLsizeiptr
Definition: GLDefines.h:621
void setBufferObject(BufferObject *bo)
virtual int compare(const StateAttribute &bb) const
GLsizeiptr getSize() const
ref_ptr< BufferObject > _bufferObject
void setSize(GLsizeiptr size)
#define META_StateAttribute(library, name, type)
GLintptr getOffset() const
ptrdiff_t GLintptr
Definition: GLDefines.h:622
Definition: AlphaFunc.h:19
virtual int compare(const StateAttribute &bb) const
#define COMPARE_StateAttribute_Parameter(parameter)
virtual int compare(const StateAttribute &bb) const