00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifndef _SO_GL_LAZY_ELEMENT
00052 #define _SO_GL_LAZY_ELEMENT
00053
00054
00055 #include <Inventor/elements/SoLazyElement.h>
00056 #include <Inventor/actions/SoGLRenderAction.h>
00057 class SoGLRenderCache;
00058 class SoGLLazyState;
00059
00060
00077 SoEXTENDER_Documented class SoGLLazyElement : public SoLazyElement
00078 {
00079
00080 SO_ELEMENT_HEADER(SoGLLazyElement);
00081
00082 public:
00086 virtual void push(SoState *state);
00090 virtual void pop(SoState *state, const SoElement *prevTopElement);
00091
00095 static void sendAllMaterial(SoState *state) {
00096 SoGLLazyElement *le = getInstance(state);
00097 if ((le->invalidBits)||(state->isCacheOpen()))
00098 le->reallySend(state, ALL_MASK|PATTERN_MASK);
00099 }
00100
00104 static void sendNoMaterial(SoState *state) {
00105 SoGLLazyElement *le = getInstance(state);
00106 if ((NO_COLOR_MASK & le->invalidBits)||(state->isCacheOpen()))
00107 le->reallySend(state, NO_COLOR_MASK);
00108 }
00109
00113 static void sendOnlyDiffuseColor(SoState *state) {
00114 SoGLLazyElement *le = getInstance(state);
00115 if ((DIFFUSE_ONLY_MASK & le->invalidBits)||(state->isCacheOpen()))
00116 le->reallySend(state, DIFFUSE_ONLY_MASK);
00117 }
00118
00125 void sendDiffuseByIndex(int index) const;
00126
00130 void reset(SoState* state, uint32_t bitmask) const;
00131
00137 static SoGLLazyElement * getInstance(const SoState *state) {
00138 return const_cast<SoGLLazyElement*>(state->getConstElement<SoGLLazyElement>());
00139 }
00140
00141 private:
00142
00144 virtual void commonInit();
00145
00147 virtual void init(SoState *state);
00148
00150 virtual SbBool matches(const SoElement *) const;
00151
00153 virtual SoElement* copyMatchInfo() const;
00154
00156 virtual void registerRedundantSet(SoState *, uint32_t bitmask);
00157
00158 private:
00159
00160 typedef SoGLLazyState GLLazyState;
00161
00162
00163 static void initClass();
00164 static void exitClass();
00165
00166
00167
00168
00169
00170 void send(const SoState *state, uint32_t mask) const {
00171 if ((mask & invalidBits)||(state->isCacheOpen()))
00172 (const_cast<SoGLLazyElement*>(this))->reallySend(state, mask);
00173 }
00174
00175
00176
00177 SbBool lazyMatches(uint32_t checkGLFlag, uint32_t checkIVFlag,
00178 const SoGLLazyElement *eltInState) {
00179 if (checkGLFlag || checkIVFlag ||
00180 ivState.transpType != eltInState->ivState.transpType)
00181 return fullLazyMatches(checkGLFlag, checkIVFlag, eltInState);
00182 else
00183 return TRUE;
00184 }
00185
00191 void setOverrideBlending(bool value){ m_overrideBlending = value; }
00192
00193
00194 bool isColorMaterialMode() const;
00195
00197 const GLLazyState& getGLState() const;
00198
00199
00200
00201
00202 SoGLLazyElement *copyLazyMatchInfo(SoState *state) const;
00203
00204
00205
00206
00207 void getCopyGL(SoGLLazyElement *cacheLazyElement,
00208 SoGLLazyElement::GLLazyState& cacheGLState);
00209
00210
00211
00212
00213
00214 void copyBackGL(SoGLLazyElement *cacheLazyElement,
00215 SoGLLazyElement::GLLazyState& cacheGLState) {
00216 if (cacheLazyElement->GLSendBits)
00217 reallyCopyBackGL(cacheLazyElement->GLSendBits, cacheGLState);
00218 }
00219
00220
00221
00222 void sendVPPacked(SoState *state, const unsigned char *pcolor);
00223
00224
00225 virtual ~SoGLLazyElement();
00226
00227 void mergeCacheInfo(SoGLRenderCache * childCache,
00228 SoGLRenderCache *parentCache,
00229 uint32_t doSendFlag,
00230 uint32_t checkIVFlag,
00231 uint32_t checkGLFlag);
00232
00233
00234 void copyIVValues(uint32_t bitmask, SoGLLazyElement *cacheLazyElement);
00235
00236
00237 virtual void registerGetDependence(SoState *, uint32_t bitmask);
00238
00239 private:
00240
00241 void copyGLValues(uint32_t bitmask, SoGLLazyElement *cacheLazyElement);
00242
00243
00244 void reallySend(const SoState *state, uint32_t bitmask);
00245
00246
00247 SbBool fullLazyMatches(uint32_t checkGLFlag, uint32_t checkIVFlag,
00248 const SoGLLazyElement* eltInState);
00249
00250
00251 void packColors(SoColorPacker *cPacker);
00252 void packColors2(SoColorPacker *cPacker);
00253
00254
00255
00256 virtual void setDiffuseElt(SoNode *node, int32_t numColors,
00257 const SbColor *colors,
00258 SoColorPacker *cPacker);
00259
00260 virtual void setTranspElt(SoNode *node, int32_t numTrans,
00261 const float *trans,
00262 SoColorPacker *cPacker);
00263
00264 virtual void setTranspTypeElt(int32_t type);
00265 virtual void setPatternFlagElt(SbBool flag);
00266 virtual void setPackedElt(SoNode *node,
00267 int32_t numColors,
00268 const uint32_t *packedColors,
00269 SoColorPacker *cPacker);
00270
00271 virtual void setAmbientElt(const SbColor *color);
00272 virtual void setEmissiveElt(const SbColor *color);
00273 virtual void setSpecularElt(const SbColor *color);
00274 virtual void setShininessElt(float color);
00275 virtual void setColorMaterialElt(SbBool value);
00276 virtual void setBlendingElt(SbBool value);
00277 virtual void setSmoothingElt(SbBool value);
00278 virtual void setLightModelElt(SoState *, int32_t model);
00279 virtual void setMaterialElt(SoNode *, uint32_t bitmask,
00280 SoColorPacker *cPacker,
00281 const SoMFColor &, const SoMFFloat &,
00282 const SoMFColor &, const SoMFColor &,
00283 const SoMFColor &, const SoMFFloat &);
00284 virtual void setMaterialElt(SoNode *, uint32_t bitmask,
00285 SoColorPacker *cPacker, SoMFColor *,
00286 SoMFFloat *, SoMFColor *,
00287 SoMFColor *, SoMFColor *, SoMFFloat *);
00288 virtual void setLineWidthElt(float lineWidth);
00289
00290
00291 void reallyCopyBackGL(uint32_t bitmask, SoGLLazyElement::GLLazyState &);
00292
00293
00294 SoGLLazyElement::GLLazyState* glState;
00295
00296
00297 uint32_t GLSendBits;
00298
00299
00300
00301
00302
00303 static u_char patterns[64+1][32 * 4];
00304
00305
00306 static SbBool patternsCreated;
00307
00308
00309
00310 static SbBool patternListDefined[64+1];
00311
00312
00313 static int patternListBase;
00314
00315
00316 static int patternListContext;
00317
00318
00319
00320 SbBool cacheOpen;
00321
00322
00323 void sendStipple(const SoState *state, int transpIndex);
00324
00325
00326
00327 static void createPatterns();
00328
00329
00330 static bool s_useNewStippleBehavior;
00331
00332
00333 void sendLineWidth(const SoState *state);
00334
00335
00336
00337 static uint64_t GLSTATE_INVALID_NODEID;
00338
00339
00340 static bool s_forceLineWidth;
00341
00343 bool m_overrideBlending;
00344 };
00345
00346 #endif
00347
00348
00349