MeVisLab Toolbox Reference
SoGLVertexAttributeElement.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2011, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef SO_GLVERTEX_ATTRIBUTE_ELEMENT_H
14 #define SO_GLVERTEX_ATTRIBUTE_ELEMENT_H
15 
16 
18 
19 #include "SoShaderSystem.h"
20 #include <Inventor/elements/SoAccumulatedElement.h>
21 #include <Inventor/SoLists.h>
22 #include <Inventor/misc/SoVBO.h>
23 #include <vector>
24 
26 struct INVENTOR_SHADER_API SoVertexAttributeInfo
27 {
28 public:
30 
32  SbString _name;
33 
35  SoNode* _node;
36 
38  const void* _data;
40  uint32_t _numBytes;
42  uint32_t _numValues;
43 
46 
48  GLenum _type;
53 
55  SoVBO _vbo;
56 
59  GLint _index;
60 
63 };
64 
65 class SoVertexShape;
66 class SoGLRenderAction;
67 
69 class INVENTOR_SHADER_API SoGLVertexAttributeElement : public SoAccumulatedElement
70 {
71  typedef SoAccumulatedElement inherited;
72 
73  SO_ELEMENT_HEADER(SoGLVertexAttributeElement);
74 
75  public:
76  typedef std::vector<SoVertexAttributeInfo*> AttributeList;
77 
79  void init(SoState *state) override;
80 
82  static void add(SoState *state, SoVertexAttributeInfo* info);
83 
85  static void clear(SoState *state, SoNode *node);
86 
88  static const AttributeList& get(SoState *state);
89 
91  void push(SoState *state) override;
92 
93  SoINTERNAL public:
94 
96  static void initClass();
97 
98  protected:
99  static void enableVertexAttributesCB(SoNode* shape, SoGLRenderAction* action, bool useVbo, uint32_t numVertices);
100  static void disableVertexAttributesCB(SoNode* shape, SoGLRenderAction* action, bool useVbo, uint32_t numVertices);
101 
104 };
105 
106 #endif
Open Inventor element storing a list of shader parameter nodes.
static void initClass()
Initialize class with runtime type system.
AttributeList _attributes
List of vertex attributes.
void init(SoState *state) override
Initialize element.
static void add(SoState *state, SoVertexAttributeInfo *info)
Add vertex attribute info to the list (replacing an info with the same name).
std::vector< SoVertexAttributeInfo * > AttributeList
void push(SoState *state) override
Overrides push() method to copy values from next instance in the stack.
static void enableVertexAttributesCB(SoNode *shape, SoGLRenderAction *action, bool useVbo, uint32_t numVertices)
static void disableVertexAttributesCB(SoNode *shape, SoGLRenderAction *action, bool useVbo, uint32_t numVertices)
static void clear(SoState *state, SoNode *node)
Clear list.
static const AttributeList & get(SoState *state)
Returns the current list of vertex attributes from the state.
Open Inventor element storing a list of vertex attributes.
bool _perInstance
set if data should be used for instanced rendering
SbString _name
the name of the attribute
uint32_t _numBytes
the number of bytes in _data
bool _shouldFlipRGBAOnLittleEndian
indicates the 4ub data should be flipped
SoNode * _node
the node that holds the attribute
const void * _data
a pointer to the data (not owned by this object)
bool _normalized
a flag if the attribute should be normalized by GL
uint32_t _numValues
the number of values in _data
GLint _index
the index of the attribute in the current shader program, only becomes valid while attribute is enabl...
SoVBO _vbo
a VBO to manage the data
int _numComponents
the number of components for GL
GLenum _type
the GL data type to use for sending