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
00135 static SbBool isColorIndex(SoState *state) {
00136 return(getInstance(state)->isColorIndexMode());
00137 }
00138
00144 static SoGLLazyElement * getInstance(const SoState *state) {
00145 return const_cast<SoGLLazyElement*>(state->getConstElement<SoGLLazyElement>());
00146 }
00147
00148 private:
00149
00151 virtual void commonInit();
00152
00154 virtual void init(SoState *state);
00155
00157 virtual SbBool matches(const SoElement *) const;
00158
00160 virtual SoElement* copyMatchInfo() const;
00161
00162 private:
00163
00164 typedef SoGLLazyState GLLazyState;
00165
00166
00167 static void initClass();
00168 static void exitClass();
00169
00170
00171
00172
00173
00174 void send(const SoState *state, uint32_t mask) const {
00175 if ((mask & invalidBits)||(state->isCacheOpen()))
00176 ((SoGLLazyElement*)(this))->reallySend(state, mask);
00177 }
00178
00179
00180
00181 SbBool lazyMatches(uint32_t checkGLFlag, uint32_t checkIVFlag,
00182 const SoGLLazyElement *eltInState) {
00183 if (checkGLFlag || checkIVFlag ||
00184 ivState.transpType != eltInState->ivState.transpType)
00185 return fullLazyMatches(checkGLFlag, checkIVFlag, eltInState);
00186 else
00187 return TRUE;
00188 }
00189
00190
00191 bool isColorMaterialMode() const;
00192
00194 const GLLazyState& getGLState() const;
00195
00196
00197
00198
00199 SoGLLazyElement *copyLazyMatchInfo(SoState *state) const;
00200
00201
00202
00203
00204 void getCopyGL(SoGLLazyElement *cacheLazyElement,
00205 SoGLLazyElement::GLLazyState& cacheGLState);
00206
00207
00208
00209
00210
00211 void copyBackGL(SoGLLazyElement *cacheLazyElement,
00212 SoGLLazyElement::GLLazyState& cacheGLState) {
00213 if (cacheLazyElement->GLSendBits)
00214 reallyCopyBackGL(cacheLazyElement->GLSendBits, cacheGLState);
00215 }
00216
00217
00218
00219 void sendVPPacked(SoState *state, const unsigned char *pcolor);
00220
00221
00222 virtual ~SoGLLazyElement();
00223
00224 void mergeCacheInfo(SoGLRenderCache * childCache,
00225 SoGLRenderCache *parentCache,
00226 uint32_t doSendFlag,
00227 uint32_t checkIVFlag,
00228 uint32_t checkGLFlag);
00229
00230
00231 void copyIVValues(uint32_t bitmask, SoGLLazyElement *cacheLazyElement);
00232
00233 private:
00234
00235 void copyGLValues(uint32_t bitmask, SoGLLazyElement *cacheLazyElement);
00236
00237
00238 void reallySend(const SoState *state, uint32_t bitmask);
00239
00240
00241 SbBool fullLazyMatches(uint32_t checkGLFlag, uint32_t checkIVFlag,
00242 const SoGLLazyElement* eltInState);
00243
00244
00245 void packColors(SoColorPacker *cPacker);
00246 void packColors2(SoColorPacker *cPacker);
00247
00248
00249
00250 virtual void setDiffuseElt(SoNode *node, int32_t numColors,
00251 const SbColor *colors,
00252 SoColorPacker *cPacker);
00253
00254 virtual void setTranspElt(SoNode *node, int32_t numTrans,
00255 const float *trans,
00256 SoColorPacker *cPacker);
00257
00258 virtual void setTranspTypeElt(int32_t type);
00259 virtual void setPatternFlagElt(SbBool flag);
00260 virtual void setPackedElt(SoNode *node,
00261 int32_t numColors,
00262 const uint32_t *packedColors,
00263 SoColorPacker *cPacker);
00264
00265 virtual void setColorIndexElt(SoNode *, int32_t numIndices,
00266 const int32_t *indices);
00267
00268 virtual void setAmbientElt(const SbColor *color);
00269 virtual void setEmissiveElt(const SbColor *color);
00270 virtual void setSpecularElt(const SbColor *color);
00271 virtual void setShininessElt(float color);
00272 virtual void setColorMaterialElt(SbBool value);
00273 virtual void setBlendingElt(SbBool value);
00274 virtual void setSmoothingElt(SbBool value);
00275 virtual void setLightModelElt(SoState *, int32_t model);
00276 virtual void setMaterialElt(SoNode *, uint32_t bitmask,
00277 SoColorPacker *cPacker,
00278 const SoMFColor &, const SoMFFloat &,
00279 const SoMFColor &, const SoMFColor &,
00280 const SoMFColor &, const SoMFFloat &);
00281 virtual void setMaterialElt(SoNode *, uint32_t bitmask,
00282 SoColorPacker *cPacker, SoMFColor *,
00283 SoMFFloat *, SoMFColor *,
00284 SoMFColor *, SoMFColor *, SoMFFloat *);
00285 virtual void setLineWidthElt(float lineWidth);
00286
00287 virtual void registerRedundantSet(SoState *, uint32_t bitmask);
00288
00289
00290 virtual void registerGetDependence(SoState *, uint32_t bitmask);
00291
00292
00293 void reallyCopyBackGL(uint32_t bitmask, SoGLLazyElement::GLLazyState &);
00294
00295 SbBool isColorIndexMode() const;
00296
00297
00298 SoGLLazyElement::GLLazyState* glState;
00299
00300
00301 uint32_t GLSendBits;
00302
00303
00304 mutable int m_isColorIndex;
00305
00306
00307
00308
00309 static u_char patterns[64+1][32 * 4];
00310
00311
00312 static SbBool patternsCreated;
00313
00314
00315
00316 static SbBool patternListDefined[64+1];
00317
00318
00319 static int patternListBase;
00320
00321
00322 static int patternListContext;
00323
00324
00325
00326 SbBool cacheOpen;
00327
00328
00329 void sendStipple(const SoState *state, int transpIndex);
00330
00331
00332 void sendPattern(const SoState *state);
00333
00334
00335
00336 static void createPatterns();
00337
00338
00339 void sendLineWidth(const SoState *state);
00340
00341
00342
00343 static uint64_t GLSTATE_INVALID_NODEID;
00344
00345
00346 static bool s_forceLineWidth;
00347 };
00348
00349 #endif
00350
00351
00352