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 _OSGSHADEREXECUTABLECHUNK_H_
40 #define _OSGSHADEREXECUTABLECHUNK_H_
45 #include "OSGShaderProgram.h"
46 #include "OSGShaderExecutableChunkBase.h"
50 class ShaderProgramChunk
;
54 /*! \brief ShaderExecutableChunk class. See \ref
55 PageSystemShaderExecutableChunk for a description.
56 \ingroup GrpSystemShaderChunks
57 \ingroup GrpLibOSGSystem
61 class OSG_SYSTEM_DLLMAPPING ShaderExecutableChunk
:
62 public ShaderExecutableChunkBase
66 /*========================== PUBLIC =================================*/
70 typedef ShaderExecutableChunkBase Inherited
;
71 typedef ShaderExecutableChunk Self
;
73 static const UInt32 KeepProgActive
= ShaderProgram::KeepProgActive
;
75 static const UInt32 ProgActive
= ShaderProgram::ProgActive
;
77 /*---------------------------------------------------------------------*/
78 /*! \name Chunk Class Access */
81 virtual const StateChunkClass
*getClass(void) const;
84 /*---------------------------------------------------------------------*/
85 /*! \name Static Chunk Class Access */
88 static UInt32
getStaticClassId(void);
89 static const StateChunkClass
*getStaticClass (void);
92 /*---------------------------------------------------------------------*/
96 virtual UInt16
getChunkId(void);
99 /*---------------------------------------------------------------------*/
103 virtual void changed(ConstFieldMaskArg whichField
,
108 /*---------------------------------------------------------------------*/
112 virtual void activate (DrawEnv
*pEnv
,
115 virtual void changeFrom (DrawEnv
*pEnv
,
119 virtual void deactivate (DrawEnv
*pEnv
,
122 virtual void updateObjectDependencies(DrawEnv
*pEnv
,
126 /*---------------------------------------------------------------------*/
130 void merge(const ShaderProgramChunk
*pChunk
);
133 /*---------------------------------------------------------------------*/
137 virtual void dump( UInt32 uiIndent
= 0,
138 const BitVector bvFlags
= 0) const;
141 /*========================= PROTECTED ===============================*/
145 static UInt32 _extSHL
;
147 static const UInt32 UsesAttribs
= 0x0001;
149 /*---------------------------------------------------------------------*/
151 static volatile UInt16 _uiChunkCounter
;
155 typedef MFFragmentShaderType ::const_iterator FragmentShaderIt
;
156 typedef MFGeometryShaderType ::const_iterator GeometryShaderIt
;
157 typedef MFTessEvaluationShaderType::const_iterator TessEvalShaderIt
;
158 typedef MFTessControlShaderType ::const_iterator TessControlShaderIt
;
159 typedef MFVertexShaderType ::const_iterator VertexShaderIt
;
161 /*---------------------------------------------------------------------*/
162 /*! \name Constructors */
165 ShaderExecutableChunk(void);
166 ShaderExecutableChunk(const ShaderExecutableChunk
&source
);
169 /*---------------------------------------------------------------------*/
170 /*! \name Destructors */
173 virtual ~ShaderExecutableChunk(void);
176 /*---------------------------------------------------------------------*/
180 static void initMethod(InitPhase ePhase
);
183 /*---------------------------------------------------------------------*/
187 virtual void resolveLinks(void);
190 /*---------------------------------------------------------------------*/
194 UInt32
handleGL (DrawEnv
*pEnv
,
196 Window::GLObjectStatusE mode
,
198 static void handleDestroyGL(DrawEnv
*pEnv
,
200 Window::GLObjectStatusE mode
);
203 /*---------------------------------------------------------------------*/
207 void onCreate (const ShaderExecutableChunk
*source
= NULL
);
208 void onCreateAspect(const ShaderExecutableChunk
*createAspect
,
209 const ShaderExecutableChunk
*source
= NULL
);
210 void onDestroy( UInt32 uiId
);
213 /*---------------------------------------------------------------------*/
217 void updateVariableLocations (DrawEnv
*pEnv
,
219 void updateVariables (DrawEnv
*pEnv
,
221 void updateParameters (DrawEnv
*pEnv
,
223 void updateAttribBindings (DrawEnv
*pEnv
,
226 void updateProceduralVariables(DrawEnv
*pEnv
,
227 UInt32 uiUpdateDependents
);
229 void remergeVariables (void );
232 /*---------------------------------------------------------------------*/
236 const MFFragmentShaderType
*getMFFragmentShader (void);
237 const MFGeometryShaderType
*getMFGeometryShader (void);
238 const MFTessEvaluationShaderType
*getMFTessEvaluationShader(void);
239 const MFTessControlShaderType
*getMFTessControlShader (void);
240 const MFVertexShaderType
*getMFVertexShader (void);
243 /*========================== PRIVATE ================================*/
247 // class. Used for indexing in State
248 static StateChunkClass _class
;
250 friend class FieldContainer
;
251 friend class ShaderExecutableChunkBase
;
252 friend class ShaderCache
;
253 friend class SimpleSHLChunk
;
255 // prohibit default functions (move to 'public' if you need one)
256 void operator =(const ShaderExecutableChunk
&source
);
259 typedef ShaderExecutableChunk
*ShaderExecutableChunkP
;
263 #include "OSGShaderExecutableChunkBase.inl"
264 #include "OSGShaderExecutableChunk.inl"
266 #endif /* _OSGSHADEREXECUTABLECHUNK_H_ */