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 \*---------------------------------------------------------------------------*/
46 #include "OSGStateBase.h"
47 #include "OSGStateChunk.h"
54 /*! \brief Wrapper for a complete State. See \ref State for a description.
55 \ingroup GrpSystemStateBase
56 \ingroup GrpLibOSGSystem
60 class OSG_SYSTEM_DLLMAPPING State
: public StateBase
62 /*========================== PUBLIC =================================*/
66 static const UInt32 InvalidKey
= 0x000003FF;
68 static const UInt32 SkipRebuild
= 0x80000000;
70 static const UInt32 Key1Mask
= 0x000003FF;
71 static const UInt32 Key2Mask
= 0x000FFC00;
72 static const UInt32 Key3Mask
= 0x3FF00000;
74 static const UInt32 DefaultKeyMask
= 0x80000000;
75 static const UInt32 FullStateMask
= 0x40000000;
77 static const UInt32 SkipNumChunks
= 2;
78 static const UInt32 UpdateChunk
= 2;
79 static const UInt32 FullStateIndex
= 2;
81 /*---------------------------------------------------------------------*/
85 virtual void changed(ConstFieldMaskArg whichField
,
90 /*---------------------------------------------------------------------*/
94 virtual void dump( UInt32 uiIndent
= 0,
95 const BitVector bvFlags
= 0) const;
98 /*---------------------------------------------------------------------*/
99 /*! \name OpenGL State Management */
103 /*---------------------------------------------------------------------*/
104 /*! \name OpenGL State Management */
107 void activate (DrawEnv
*pEnv
) const;
109 void changeFrom(DrawEnv
*pEnv
,
112 void deactivate(DrawEnv
*pEnv
) const;
115 /*---------------------------------------------------------------------*/
126 /*---------------------------------------------------------------------*/
130 StateChunk
*getChunk (UInt32 chunkId
) const;
132 bool chunkPresent (UInt32 chunkId
) const;
133 bool chunkPresent (StateChunk
*chunk
) const;
135 bool addChunk (StateChunk
*chunk
,
136 Int32 index
= AutoSlotReplace
);
138 bool subChunk (StateChunk
*chunk
);
140 bool subChunk (UInt32 classid
,
143 void clearChunks (void );
146 /*---------------------------------------------------------------------*/
150 void setCoreGLChunkLimit(UInt32 uiCoreGLChunkLimit
);
151 UInt32
getCoreGLChunkLimit(void );
154 /*---------------------------------------------------------------------*/
155 /*! \name Properties */
158 bool isTransparent(void) const;
161 /*---------------------------------------------------------------------*/
162 /*! \name StateSorting Interface (for Material/Sorter only) */
165 void setDefaultSortKey(UInt32 uiSortKey
);
166 UInt32
getSortKey (UInt32 uiKeyGen
= SkipRebuild
);
169 /*---------------------------------------------------------------------*/
170 /*! \name Comparison */
173 virtual Real32
switchCost (State
* state
);
175 virtual bool operator < (const State
&other
) const;
177 virtual bool operator == (const State
&other
) const;
178 virtual bool operator != (const State
&other
) const;
181 /*========================= PROTECTED ===============================*/
185 UInt32 _uiDefaultSortKey
;
188 UInt32 _uiCoreGLChunkLimit
;
190 /*---------------------------------------------------------------------*/
194 void onCreateAspect(const State
*createAspect
,
195 const State
*source
= NULL
);
198 /*---------------------------------------------------------------------*/
199 /*! \name Constructors */
203 State(const State
&source
);
206 /*---------------------------------------------------------------------*/
207 /*! \name Destructors */
210 virtual ~State(void);
213 /*---------------------------------------------------------------------*/
214 /*! \name Destructors */
217 void rebuildSortKey(void);
220 /*---------------------------------------------------------------------*/
224 const MFUnrecStateChunkPtr
*getMFChunks(void) const;
226 virtual void resolveLinks(void);
229 /*---------------------------------------------------------------------*/
233 static void initMethod(InitPhase ePhase
);
236 /*========================== PRIVATE ================================*/
240 typedef StateBase Inherited
;
242 friend class FieldContainer
;
243 friend class StateBase
;
244 friend class DrawEnv
;
246 // prohibit default functions (move to 'public' if you need one)
247 void operator =(const State
&source
);
250 typedef State
*StateP
;
252 #define OSG_SKIP_IT(ITERATOR, STEPS) \
253 (ITERATOR) += (STEPS)
257 #include "OSGStateBase.inl"
258 #include "OSGState.inl"
260 #endif /* _OSGSTATE_H_ */