1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSHADEREXECUTABLEVARCHUNK_H_
40 #define _OSGSHADEREXECUTABLEVARCHUNK_H_
45 #include "OSGShaderExecutableVarChunkBase.h"
46 #include "OSGShaderExecutableChunk.h"
53 class SimpleSHLVariableChunk
;
55 /*! \brief ShaderExecutableVarChunk class. See \ref
56 PageStateShaderExecutableVarChunk for a description.
57 \ingroup GrpSystemShaderChunks
58 \ingroup GrpLibOSGSystem
62 class OSG_SYSTEM_DLLMAPPING ShaderExecutableVarChunk
:
63 public ShaderExecutableVarChunkBase
67 /*========================== PUBLIC =================================*/
71 typedef ShaderExecutableVarChunkBase Inherited
;
72 typedef ShaderExecutableVarChunk Self
;
74 typedef MFProgramVarChunksType::const_iterator VarChunksIt
;
76 /*---------------------------------------------------------------------*/
77 /*! \name Chunk Class Access */
80 virtual const StateChunkClass
*getClass(void) const;
83 /*---------------------------------------------------------------------*/
84 /*! \name Static Chunk Class Access */
87 static UInt32
getStaticClassId(void);
88 static const StateChunkClass
*getStaticClass (void);
91 /*---------------------------------------------------------------------*/
95 virtual UInt16
getChunkId(void);
98 /*---------------------------------------------------------------------*/
102 virtual void changed(ConstFieldMaskArg whichField
,
107 /*---------------------------------------------------------------------*/
111 void setShaderExecutableChunk(ShaderExecutableChunk
* const);
114 /*---------------------------------------------------------------------*/
118 void merge(ShaderProgramVariableChunk
*pVar
);
121 /*---------------------------------------------------------------------*/
126 /*---------------------------------------------------------------------*/
130 virtual void activate (DrawEnv
*, UInt32 index
= 0);
131 virtual void changeFrom(DrawEnv
*, StateChunk
*, UInt32 index
= 0);
132 virtual void deactivate(DrawEnv
*, UInt32 index
= 0);
135 /*---------------------------------------------------------------------*/
139 virtual void dump( UInt32 uiIndent
= 0,
140 const BitVector bvFlags
= 0) const;
143 /*========================= PROTECTED ===============================*/
147 #ifdef OSG_MULTISHADER_VARCHUNK
148 typedef std::map
<UInt32
, MFInt32
> ShaderVarLocMap
;
149 typedef std::map
<UInt32
, MFInt32
>::value_type ShaderVarLocMapValueT
;
150 typedef std::map
<UInt32
, MFInt32
>::iterator ShaderVarLocMapIt
;
151 typedef std::map
<UInt32
, MFInt32
>::const_iterator ShaderVarLocMapConstIt
;
154 /*---------------------------------------------------------------------*/
156 static volatile UInt16 _uiChunkCounter
;
158 #ifdef OSG_MULTISHADER_VARCHUNK
159 ShaderVarLocMap _mShaderVarLocs
;
163 // Variables should all be in SHLVariableChunkBase.
165 /*---------------------------------------------------------------------*/
169 void onCreate (const ShaderExecutableVarChunk
*source
= NULL
);
170 void onCreateAspect(const ShaderExecutableVarChunk
*createAspect
,
171 const ShaderExecutableVarChunk
*source
= NULL
);
174 /*---------------------------------------------------------------------*/
175 /*! \name Constructors */
178 ShaderExecutableVarChunk(void);
179 ShaderExecutableVarChunk(const ShaderExecutableVarChunk
&source
);
182 /*---------------------------------------------------------------------*/
183 /*! \name Destructors */
186 virtual ~ShaderExecutableVarChunk(void);
189 /*---------------------------------------------------------------------*/
193 static void initMethod(InitPhase ePhase
);
196 /*---------------------------------------------------------------------*/
200 void updateVariables (DrawEnv
*pEnv
);
201 void remergeVariables(void );
204 /*---------------------------------------------------------------------*/
208 const MFProgramVarChunksType
*getMFProgramVarChunks(void);
211 /*========================== PRIVATE ================================*/
215 // class. Used for indexing in State
216 static StateChunkClass _class
;
218 friend class FieldContainer
;
219 friend class ShaderExecutableVarChunkBase
;
220 friend class ShaderCache
;
221 friend class SimpleSHLVariableChunk
;
223 // prohibit default functions (move to 'public' if you need one)
224 void operator =(const ShaderExecutableVarChunk
&source
);
227 typedef ShaderExecutableVarChunk
*ShaderExecutableVarChunkP
;
231 #include "OSGShaderExecutableVarChunkBase.inl"
232 #include "OSGShaderExecutableVarChunk.inl"
234 #endif /* _OSGSHADEREXECUTABLEVARCHUNK_H_ */