1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 _OSGSTATEOVERRIDE_H_
40 #define _OSGSTATEOVERRIDE_H_
46 #include "OSGBaseTypes.h"
47 #include "OSGSystemDef.h"
48 #include "OSGSimplePool.h"
57 class ShaderExecutableChunk
;
58 class ShaderExecutableVarChunk
;
59 class ShaderProgramChunk
;
60 class ShaderProgramVariableChunk
;
64 /*! \ingroup GrpSystemStateBase
65 \ingroup GrpLibOSGSystem
69 class OSG_SYSTEM_DLLMAPPING StateOverride
71 /*========================== PUBLIC =================================*/
75 typedef std::pair
<UInt32
, StateChunk
*> ChunkElement
;
77 typedef std::vector
<ChunkElement
> ChunkStore
;
78 typedef std::vector
<ChunkElement
>::iterator ChunkStoreIt
;
79 typedef std::vector
<ChunkElement
>::const_iterator ChunkStoreConstIt
;
81 typedef std::vector
<UInt16
> IdStore
;
82 typedef std::vector
<UInt16
>::iterator IdStoreIt
;
85 typedef std::vector
<ShaderProgramChunk
*> ProgramChunkStore
;
86 typedef std::vector
<ShaderProgramVariableChunk
*> ProgramVarChunkStore
;
89 static const UInt32 InvalidKey
= State::InvalidKey
;
91 static const UInt32 SkipRebuild
= State::SkipRebuild
;
93 static const UInt32 Key1Mask
= State::Key1Mask
;
94 static const UInt32 Key2Mask
= State::Key2Mask
;
95 static const UInt32 Key3Mask
= State::Key3Mask
;
97 /*---------------------------------------------------------------------*/
98 /*! \name Constructors */
104 /*---------------------------------------------------------------------*/
105 /*! \name Destructor */
108 virtual ~StateOverride(void);
111 /*---------------------------------------------------------------------*/
112 /*! \name Statistic */
115 void fillFrom(StateOverride
*pState
);
118 /*---------------------------------------------------------------------*/
119 /*! \name Statistic */
122 void setKeyGen (UInt32 uiKeyGen
);
123 void updateSortKey(UInt32
&uiSortKey
, UInt32 uiKeyGen
= SkipRebuild
);
126 /*---------------------------------------------------------------------*/
127 /*! \name Statistic */
130 ChunkStoreConstIt
begin (void) const;
131 ChunkStoreConstIt
end (void) const;
132 SizeT
size (void) const;
133 UInt32
size32(void) const;
136 /*---------------------------------------------------------------------*/
142 void addOverride (UInt32 uiSlot
,
144 void addOverride (UInt32 uiSlot
,
145 SimpleSHLChunk
*pChunk
);
146 void addOverride (UInt32 uiSlot
,
147 ShaderProgramChunk
*pChunk
);
148 void addOverride (UInt32 uiSlot
,
149 ShaderProgramVariableChunk
*pChunk
);
152 void subOverride (UInt32 uiSlot
,
154 void subOverride (UInt32 uiSlot
,
155 SimpleSHLChunk
*pChunk
);
156 void subOverride (UInt32 uiSlot
,
157 ShaderProgramChunk
*pChunk
);
158 void subOverride (UInt32 uiSlot
,
159 ShaderProgramVariableChunk
*pChunk
);
164 bool isTransparent(void );
167 /*---------------------------------------------------------------------*/
171 const IdStore
&getProgIds (void);
172 const ProgramChunkStore
&getPrograms (void);
174 const IdStore
&getVarIds (void);
175 const ProgramVarChunkStore
&getVariables(void);
178 /*---------------------------------------------------------------------*/
182 void setShader (ShaderExecutableChunk
*pShader
);
183 ShaderExecutableChunk
*getShader (void );
185 void setShaderVar(ShaderExecutableVarChunk
*pVar
);
186 ShaderExecutableVarChunk
*getShaderVar(void );
189 /*========================= PROTECTED ===============================*/
194 /*---------------------------------------------------------------------*/
200 ShaderExecutableChunk
*_pShader
;
201 ShaderExecutableVarChunk
*_pShaderVar
;
203 ProgramChunkStore _vProgChunks
;
206 ProgramVarChunkStore _vProgVarChunks
;
207 IdStore _vProgVarIds
;
214 /*---------------------------------------------------------------------*/
218 void rebuildSortKey(void);
221 /*---------------------------------------------------------------------*/
225 void insertOverride(UInt32 uiSlot
,
228 void eraseOverride (UInt32 uiSlot
,
232 /*========================== PRIVATE ================================*/
238 class RefCountPolicy
,
239 class LockPolicy
> friend class SimplePool
;
241 /*! \brief prohibit default function (move to 'public' if needed) */
242 StateOverride(const StateOverride
&source
);
243 /*! \brief prohibit default function (move to 'public' if needed) */
244 void operator =(const StateOverride
&source
);
247 bool operator <(const StateOverride::ChunkElement
&lhs
,
248 const StateOverride::ChunkElement
&rhs
);
252 #include "OSGStateOverride.inl"
254 #endif /* _OSGSTATEOVERRIDE_H_ */