changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGState.h
blobdb8d2f84d8d05023b99affa76f3918c1cb3ad0fb
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGSTATE_H_
41 #define _OSGSTATE_H_
42 #ifdef __sgi
43 #pragma once
44 #endif
46 #include "OSGStateBase.h"
47 #include "OSGStateChunk.h"
49 OSG_BEGIN_NAMESPACE
51 class StateOverride;
52 class DrawEnv;
54 /*! \brief Wrapper for a complete State. See \ref State for a description.
55 \ingroup GrpSystemStateBase
56 \ingroup GrpLibOSGSystem
57 \includebasedoc
60 class OSG_SYSTEM_DLLMAPPING State : public StateBase
62 /*========================== PUBLIC =================================*/
64 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 /*---------------------------------------------------------------------*/
82 /*! \name Sync */
83 /*! \{ */
85 virtual void changed(ConstFieldMaskArg whichField,
86 UInt32 origin,
87 BitVector details);
89 /*! \} */
90 /*---------------------------------------------------------------------*/
91 /*! \name Output */
92 /*! \{ */
94 virtual void dump( UInt32 uiIndent = 0,
95 const BitVector bvFlags = 0) const;
97 /*! \} */
98 /*---------------------------------------------------------------------*/
99 /*! \name OpenGL State Management */
100 /*! \{ */
102 /*! \} */
103 /*---------------------------------------------------------------------*/
104 /*! \name OpenGL State Management */
105 /*! \{ */
107 void activate (DrawEnv *pEnv) const;
109 void changeFrom(DrawEnv *pEnv,
110 State *pOld) const;
112 void deactivate(DrawEnv *pEnv) const;
114 /*! \} */
115 /*---------------------------------------------------------------------*/
116 /*! \name Enums */
117 /*! \{ */
119 enum
121 AutoSlot = -1,
122 AutoSlotReplace = -2
125 /*! \} */
126 /*---------------------------------------------------------------------*/
127 /*! \name Access */
128 /*! \{ */
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,
141 Int32 index );
143 void clearChunks (void );
145 /*! \} */
146 /*---------------------------------------------------------------------*/
147 /*! \name Access */
148 /*! \{ */
150 void setCoreGLChunkLimit(UInt32 uiCoreGLChunkLimit);
151 UInt32 getCoreGLChunkLimit(void );
153 /*! \} */
154 /*---------------------------------------------------------------------*/
155 /*! \name Properties */
156 /*! \{ */
158 bool isTransparent(void) const;
160 /*! \} */
161 /*---------------------------------------------------------------------*/
162 /*! \name StateSorting Interface (for Material/Sorter only) */
163 /*! \{ */
165 void setDefaultSortKey(UInt32 uiSortKey);
166 UInt32 getSortKey (UInt32 uiKeyGen = SkipRebuild);
168 /*! \} */
169 /*---------------------------------------------------------------------*/
170 /*! \name Comparison */
171 /*! \{ */
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;
180 /*! \} */
181 /*========================= PROTECTED ===============================*/
183 protected:
185 UInt32 _uiDefaultSortKey;
186 UInt32 _uiSortKey;
187 UInt32 _uiKeyGen;
188 UInt32 _uiCoreGLChunkLimit;
190 /*---------------------------------------------------------------------*/
191 /*! \name Init */
192 /*! \{ */
194 void onCreateAspect(const State *createAspect,
195 const State *source = NULL);
197 /*! \} */
198 /*---------------------------------------------------------------------*/
199 /*! \name Constructors */
200 /*! \{ */
202 State(void);
203 State(const State &source);
205 /*! \} */
206 /*---------------------------------------------------------------------*/
207 /*! \name Destructors */
208 /*! \{ */
210 virtual ~State(void);
212 /*! \} */
213 /*---------------------------------------------------------------------*/
214 /*! \name Destructors */
215 /*! \{ */
217 void rebuildSortKey(void);
219 /*! \} */
220 /*---------------------------------------------------------------------*/
221 /*! \name Init */
222 /*! \{ */
224 const MFUnrecStateChunkPtr *getMFChunks(void) const;
226 virtual void resolveLinks(void);
228 /*! \} */
229 /*---------------------------------------------------------------------*/
230 /*! \name Init */
231 /*! \{ */
233 static void initMethod(InitPhase ePhase);
235 /*! \} */
236 /*========================== PRIVATE ================================*/
238 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)
255 OSG_END_NAMESPACE
257 #include "OSGStateBase.inl"
258 #include "OSGState.inl"
260 #endif /* _OSGSTATE_H_ */