changed: gcc8 base update
[opensg.git] / Source / System / State / Shader / Chunks / OSGShaderProgramVariableChunk.h
blobce13e51614f137199b8265f2417902393143299d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSHADERPROGRAMVARIABLECHUNK_H_
40 #define _OSGSHADERPROGRAMVARIABLECHUNK_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGShaderProgramVariableChunkBase.h"
46 #include "OSGShaderProgramVariables.h"
47 #include "OSGLockPolicies.h"
48 #include "OSGSimpleReusePool.h"
50 OSG_BEGIN_NAMESPACE
52 /*! \brief ShaderProgramVariableChunk class. See \ref
53 PageStateShaderProgramVariableChunk for a description.
54 \ingroup GrpSystemShaderChunks
55 \ingroup GrpLibOSGSystem
56 \includebasedoc
59 class OSG_SYSTEM_DLLMAPPING ShaderProgramVariableChunk :
60 public ShaderProgramVariableChunkBase
62 protected:
64 /*========================== PUBLIC =================================*/
66 public:
68 typedef ShaderProgramVariableChunkBase Inherited;
69 typedef ShaderProgramVariableChunk Self;
71 struct VariableIdPoolTag;
73 /*---------------------------------------------------------------------*/
74 /*! \name Chunk Class Access */
75 /*! \{ */
77 virtual const StateChunkClass *getClass(void) const;
79 /*! \} */
80 /*---------------------------------------------------------------------*/
81 /*! \name Static Chunk Class Access */
82 /*! \{ */
84 static UInt32 getStaticClassId(void);
85 static const StateChunkClass *getStaticClass (void);
87 /*! \} */
88 /*---------------------------------------------------------------------*/
89 /*! \name Chunk Id */
90 /*! \{ */
92 virtual UInt16 getChunkId(void);
94 /*! \} */
95 /*---------------------------------------------------------------------*/
96 /*! \name Sync */
97 /*! \{ */
99 virtual void changed(ConstFieldMaskArg whichField,
100 UInt32 origin,
101 BitVector details );
103 /*! \} */
104 /*---------------------------------------------------------------------*/
105 /*! \name Output */
106 /*! \{ */
108 UInt16 getVariableId(void);
110 /*! \} */
111 /*---------------------------------------------------------------------*/
112 /*! \name Output */
113 /*! \{ */
114 template<class ValueT>
115 bool addUniformVariable (const Char8 *name, const ValueT &value);
117 template<class ValueT>
118 bool updateUniformVariable (const Char8 *name, const ValueT &value);
120 template<class ValueT>
121 bool getUniformVariable (const Char8 *name, ValueT &value);
123 bool subUniformVariable (const Char8 *name );
124 void clearUniformVariables ( void );
126 /*! \} */
127 /*---------------------------------------------------------------------*/
128 /*! \name Output */
129 /*! \{ */
130 bool addUniformBlock (const Char8 *name, UInt32 value);
131 bool updateUniformBlock (const Char8 *name, UInt32 value);
132 bool getUniformBlock (const Char8 *name, UInt32 &value);
133 bool subUniformBlock (const Char8 *name );
135 /*! \} */
136 /*---------------------------------------------------------------------*/
137 /*! \name Output */
138 /*! \{ */
139 bool addShaderStorageBlock (const Char8 *name, UInt32 value);
140 bool updateShaderStorageBlock(const Char8 *name, UInt32 value);
141 bool getShaderStorageBlock (const Char8 *name, UInt32 &value);
142 bool subShaderStorageBlock (const Char8 *name );
144 /*! \} */
145 /*---------------------------------------------------------------------*/
146 /*! \name Init */
147 /*! \{ */
149 virtual void activate (DrawEnv*, UInt32 index = 0);
150 virtual void changeFrom(DrawEnv*, StateChunk*, UInt32 index = 0);
151 virtual void deactivate(DrawEnv*, UInt32 index = 0);
153 /*! \} */
154 /*---------------------------------------------------------------------*/
155 /*! \name Output */
156 /*! \{ */
158 void addDestroyedFunctor (ChangedFunctor func,
159 std::string createSymbol);
161 template<class FunctorT>
162 void subDestroyedFunctor (FunctorT func );
164 template<class FunctorT>
165 bool hasDestroyedFunctor (FunctorT func );
167 void clearDestroyedFunctors(void );
169 /*! \} */
170 /*---------------------------------------------------------------------*/
171 /*! \name Output */
172 /*! \{ */
174 void addParent(FieldContainer * const pParent,
175 UInt16 uiParentFieldId);
177 void subParent(FieldContainer * const pParent );
179 /*! \} */
180 /*---------------------------------------------------------------------*/
181 /*! \name Output */
182 /*! \{ */
184 virtual void dump( UInt32 uiIndent = 0,
185 const BitVector bvFlags = 0) const;
187 /*! \} */
188 /*========================= PROTECTED ===============================*/
190 protected:
192 typedef SimpleReusePool<Int32,
193 VariableIdPoolTag,
194 SingleLockPolicy > VarIdPool;
197 static VarIdPool *_pVarIdPool;
199 UInt16 _uiVarId;
201 /*---------------------------------------------------------------------*/
203 static volatile UInt16 _uiChunkCounter;
205 UInt16 _uiChunkId;
207 // Variables should all be in ShaderProgramVariableChunkBase.
209 /*---------------------------------------------------------------------*/
210 /*! \name Init */
211 /*! \{ */
213 void onCreate (const ShaderProgramVariableChunk *source = NULL);
214 void onCreateAspect(const ShaderProgramVariableChunk *createAspect,
215 const ShaderProgramVariableChunk *source = NULL);
217 /*! \} */
218 /*---------------------------------------------------------------------*/
219 /*! \name Constructors */
220 /*! \{ */
222 virtual void onDestroy(UInt32 uiId);
224 /*! \} */
225 /*---------------------------------------------------------------------*/
226 /*! \name Constructors */
227 /*! \{ */
229 ShaderProgramVariableChunk(void);
230 ShaderProgramVariableChunk(const ShaderProgramVariableChunk &source);
232 /*! \} */
233 /*---------------------------------------------------------------------*/
234 /*! \name Destructors */
235 /*! \{ */
237 virtual ~ShaderProgramVariableChunk(void);
239 /*! \} */
240 /*---------------------------------------------------------------------*/
241 /*! \name Init */
242 /*! \{ */
244 static void initMethod(InitPhase ePhase);
246 /*! \} */
247 /*---------------------------------------------------------------------*/
248 /*! \name Init */
249 /*! \{ */
251 virtual void resolveLinks(void);
253 /*! \} */
254 /*========================== PRIVATE ================================*/
256 private:
258 // class. Used for indexing in State
259 static StateChunkClass _class;
261 friend class FieldContainer;
262 friend class ShaderProgramVariableChunkBase;
264 // prohibit default functions (move to 'public' if you need one)
265 void operator =(const ShaderProgramVariableChunk &source);
268 typedef ShaderProgramVariableChunk *ShaderProgramVariableChunkP;
270 OSG_END_NAMESPACE
272 #include "OSGShaderProgramVariableChunkBase.inl"
273 #include "OSGShaderProgramVariableChunk.inl"
275 #endif /* _OSGSHADERPROGRAMVARIABLECHUNK_H_ */