OpenSceneGraph 3.6.5
AttributeDispatchers
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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#ifndef OSG_ATTRIBUTEDISPATCHERS
15#define OSG_ATTRIBUTEDISPATCHERS 1
16
17#include <osg/ref_ptr>
18#include <osg/Array>
19#include <osg/Matrixd>
20
21namespace osg {
22
23// forward declare
24class State;
25class AttributeDispatchMap;
26
28{
29 virtual void assign(const GLvoid*) {}
30 virtual void operator() (unsigned int) {};
31};
32
35{
36 public:
37
40
41 void setState(osg::State* state);
42
43 void reset();
44
47
48
49 #define DISPATCH_OR_ACTIVATE(array, dispatcher) \
50 if (array) { \
51 unsigned int binding = array->getBinding(); \
52 if (binding==osg::Array::BIND_OVERALL) \
53 { \
54 AttributeDispatch* at = dispatcher; \
55 if (at) (*at)(0); \
56 } \
57 else if (binding==osg::Array:: BIND_PER_PRIMITIVE_SET) \
58 { \
59 AttributeDispatch* at = dispatcher; \
60 if (at) _activeDispatchList.push_back(at); \
61 } \
62 }
63
64
69 void activateVertexAttribArray(unsigned int unit, osg::Array* array) { DISPATCH_OR_ACTIVATE(array, vertexAttribDispatcher(unit , array)); }
70
75 AttributeDispatch* vertexAttribDispatcher(unsigned int unit, Array* array);
76
77 void dispatch(unsigned int index)
78 {
79 for(AttributeDispatchList::iterator itr = _activeDispatchList.begin();
80 itr != _activeDispatchList.end();
81 ++itr)
82 {
83 (*(*itr))(index);
84 }
85 }
86
87 bool active() const { return !_activeDispatchList.empty(); }
88
89 protected:
90
91 void init();
92
93 void assignTexCoordDispatchers(unsigned int unit);
94 void assignVertexAttribDispatchers(unsigned int unit);
95
98
99 AttributeDispatchMap* _normalDispatchers;
100 AttributeDispatchMap* _colorDispatchers;
101 AttributeDispatchMap* _secondaryColorDispatchers;
102 AttributeDispatchMap* _fogCoordDispatchers;
103
104 typedef std::vector<AttributeDispatchMap*> AttributeDispatchMapList;
106
107 typedef std::vector<AttributeDispatch*> AttributeDispatchList;
108
110
112};
113
114}
115
116#endif
#define DISPATCH_OR_ACTIVATE(array, dispatcher)
Definition AttributeDispatchers:49
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Definition Array:61
Definition AttributeDispatchers:28
virtual void operator()(unsigned int)
Definition AttributeDispatchers:30
virtual void assign(const GLvoid *)
Definition AttributeDispatchers:29
AttributeDispatchMap * _secondaryColorDispatchers
Definition AttributeDispatchers:101
AttributeDispatch * colorDispatcher(Array *array)
void activateVertexAttribArray(unsigned int unit, osg::Array *array)
Definition AttributeDispatchers:69
AttributeDispatch * fogCoordDispatcher(Array *array)
AttributeDispatchList _activeDispatchList
Definition AttributeDispatchers:109
State * _state
Definition AttributeDispatchers:97
void dispatch(unsigned int index)
Definition AttributeDispatchers:77
void assignVertexAttribDispatchers(unsigned int unit)
void activateSecondaryColorArray(osg::Array *array)
Definition AttributeDispatchers:67
bool _useVertexAttribAlias
Definition AttributeDispatchers:111
AttributeDispatch * secondaryColorDispatcher(Array *array)
void activateNormalArray(osg::Array *array)
Definition AttributeDispatchers:66
void setUseVertexAttribAlias(bool flag)
Definition AttributeDispatchers:45
bool _initialized
Definition AttributeDispatchers:96
std::vector< AttributeDispatch * > AttributeDispatchList
Definition AttributeDispatchers:107
AttributeDispatchMap * _fogCoordDispatchers
Definition AttributeDispatchers:102
std::vector< AttributeDispatchMap * > AttributeDispatchMapList
Definition AttributeDispatchers:104
AttributeDispatch * normalDispatcher(Array *array)
AttributeDispatchMapList _vertexAttribDispatchers
Definition AttributeDispatchers:105
void assignTexCoordDispatchers(unsigned int unit)
AttributeDispatch * vertexAttribDispatcher(unsigned int unit, Array *array)
void activateFogCoordArray(osg::Array *array)
Definition AttributeDispatchers:68
void activateColorArray(osg::Array *array)
Definition AttributeDispatchers:65
bool getUseVertexAttribAlias() const
Definition AttributeDispatchers:46
void setState(osg::State *state)
AttributeDispatchMap * _colorDispatchers
Definition AttributeDispatchers:100
bool active() const
Definition AttributeDispatchers:87
AttributeDispatchMap * _normalDispatchers
Definition AttributeDispatchers:99
Base class for providing reference counted objects.
Definition Referenced:44
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
#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.