SoGLLazyElement.h Source File

| http://www.sim.no/ http://www.coin3d.org/

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

SoGLLazyElement.h
1 #ifndef COIN_SOGLLAZYELEMENT_H
2 #define COIN_SOGLLAZYELEMENT_H
3
4 /**************************************************************************\
5 *
6 * This file is part of the Coin 3D visualization library.
7 * Copyright (C) by Kongsberg Oil & Gas Technologies.
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * ("GPL") version 2 as published by the Free Software Foundation.
12 * See the file LICENSE.GPL at the root directory of this source
13 * distribution for additional information about the GNU GPL.
14 *
15 * For using Coin with software that can not be combined with the GNU
16 * GPL, and for taking advantage of the additional benefits of our
17 * support services, please contact Kongsberg Oil & Gas Technologies
18 * about acquiring a Coin Professional Edition License.
19 *
20 * See http://www.coin3d.org/ for more information.
21 *
22 * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
23 * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
24 *
25 \**************************************************************************/
26
27 #include <Inventor/elements/SoLazyElement.h>
28 #include <Inventor/C/glue/gl.h>
29
30 class SoGLRenderCache;
31 class SoGLLazyElementP;
32 class SoVBO;
33
34 class COIN_DLL_API SoGLLazyElement : public SoLazyElement {
35 typedef SoLazyElement inherited;
36
37 SO_ELEMENT_HEADER(SoGLLazyElement);
38
39 public:
40 static void initClass();
41 protected:
42 ~SoGLLazyElement();
43 public:
44
45 virtual void init(SoState *state);
46 virtual void push(SoState *state);
47 virtual void pop(SoState *state, const SoElement * prevtopelement);
48
49 static void sendAllMaterial(SoState * state);
50 static void sendNoMaterial(SoState * state);
51 static void sendOnlyDiffuseColor(SoState * state);
52 static void sendLightModel(SoState * state, const int32_t model);
53 static void sendPackedDiffuse(SoState * state, const uint32_t diffuse);
54 static void sendFlatshading(SoState * state, const SbBool onoff);
55 static void sendVertexOrdering(SoState * state, const VertexOrdering ordering);
56 static void sendTwosideLighting(SoState * state, const SbBool onoff);
57 static void sendBackfaceCulling(SoState * state, const SbBool onoff);
58
59 void sendDiffuseByIndex(const int index) const;
60 static SbBool isColorIndex(SoState *state);
61 static SoGLLazyElement * getInstance(const SoState *state);
62 void send(const SoState *state, uint32_t mask) const;
63
64 void sendVPPacked(SoState* state, const unsigned char* pcolor);
65
66 void reset(SoState* state, uint32_t bitmask) const;
67
68 typedef struct COIN_DLL_API {
69 uint32_t cachebitmask;
70 uint32_t diffuse;
71 SbColor ambient;
72 SbColor emissive;
73 SbColor specular;
74 float shininess;
75 int32_t lightmodel;
76 int32_t blending;
77 int32_t blend_sfactor;
78 int32_t blend_dfactor;
79 int32_t alpha_blend_sfactor;
80 int32_t alpha_blend_dfactor;
81 int32_t stipplenum;
82 int32_t vertexordering;
83 int32_t culling;
84 int32_t twoside;
85 int32_t flatshading;
86 int32_t glimageid;
87 int32_t alphatest;
88 uint32_t diffusenodeid;
89 uint32_t transpnodeid;
90 uint32_t reserved[4];
91 } GLState;
92
93 virtual void setDiffuseElt(SoNode*, int32_t numcolors,
94 const SbColor * colors, SoColorPacker * packer);
95 virtual void setPackedElt(SoNode * node, int32_t numcolors,
96 const uint32_t * colors, const SbBool packedtransparency);
97 virtual void setColorIndexElt(SoNode * node, int32_t numindices,
98 const int32_t * indices);
99 virtual void setTranspElt(SoNode * node, int32_t numtransp,
100 const float * transp, SoColorPacker * packer);
101
102 virtual void setTranspTypeElt(int32_t type);
103 virtual void setAmbientElt(const SbColor* color);
104 virtual void setEmissiveElt(const SbColor* color);
105 virtual void setSpecularElt(const SbColor* color);
106 virtual void setShininessElt(float value);
107 virtual void setColorMaterialElt(SbBool value);
108 virtual void enableBlendingElt(int sfactor, int dfactor, int alpha_sfactor, int alpha_dfactor);
109 virtual void disableBlendingElt(void);
110 virtual void setLightModelElt(SoState *state, int32_t model);
111 virtual void setMaterialElt(SoNode * node, uint32_t bitmask,
112 SoColorPacker * packer,
113 const SbColor * diffuse, const int numdiffuse,
114 const float * transp, const int numtransp,
115 const SbColor & ambient,
116 const SbColor & emissive,
117 const SbColor & specular,
118 const float shininess,
119 const SbBool istransparent);
120 virtual void setVertexOrderingElt(VertexOrdering ordering);
121 virtual void setBackfaceCullingElt(SbBool onoff);
122 virtual void setTwosideLightingElt(SbBool onoff);
123 virtual void setShadeModelElt(SbBool flatshading);
124 virtual void setGLImageIdElt(uint32_t glimageid, SbBool alphatest);
125 virtual void setAlphaTestElt(SbBool onoff);
126
127 static void beginCaching(SoState * state,
128 SoGLLazyElement::GLState * prestate,
129 SoGLLazyElement::GLState * poststate);
130 static void endCaching(SoState * state);
131
132 static SbBool preCacheCall(SoState * state, SoGLLazyElement::GLState * prestate);
133 static void postCacheCall(SoState * state, SoGLLazyElement::GLState * poststate);
134
135 static void mergeCacheInfo(SoState * state,
136 SoGLLazyElement::GLState * childprestate,
137 SoGLLazyElement::GLState * childpoststate);
138
139 void updateColorVBO(SoVBO * vbo);
140
141 protected:
142 virtual void lazyDidSet(uint32_t mask);
143 virtual void lazyDidntSet(uint32_t mask);
144
145 private:
146 void sendPackedDiffuse(const uint32_t diffuse) const;
147 void sendAmbient(const SbColor & color) const;
148 void sendEmissive(const SbColor & color) const;
149 void sendSpecular(const SbColor & specular) const;
150 void sendShininess(const float shininess) const;
151 void sendTransparency(const int stipplenum) const;
152 void enableBlending(const int sfactor, const int dfactor) const;
153 void enableSeparateBlending(const cc_glglue * glue,
154 const int sfactor, const int dfactor,
155 const int alpha_sfactor, const int alpha_dfactor) const;
156 void disableBlending(void) const;
157
158 void sendLightModel(const int32_t model) const;
159 void sendFlatshading(const SbBool onoff) const;
160 void sendVertexOrdering(const VertexOrdering ordering) const;
161 void sendTwosideLighting(const SbBool onoff) const;
162 void sendBackfaceCulling(const SbBool onoff) const;
163 void sendGLImage(const uint32_t glimageid) const;
164 void sendAlphaTest(const SbBool onoff) const;
165 void initGL(void);
166 void packColors(SoColorPacker * packer) const;
167
168 uint32_t didsetbitmask;
169 uint32_t didntsetbitmask;
170 uint32_t cachebitmask;
171 uint32_t opencacheflags;
172
173 GLState glstate;
174 GLState * postcachestate;
175 GLState * precachestate;
176 SbBool colorindex;
177 SoColorPacker * colorpacker;
178 const uint32_t * packedpointer;
179 uint32_t transpmask;
180 SoState * state;
181 SoGLLazyElementP * pimpl; // for future use
182 };
183
184 #endif // !COIN_SOGLLAZYELEMENT_H
SbColor
The SbColor class contains the red, green and blue components which make up a color value...
Definition: SbColor.h:30
SoNode
The SoNode class is the base class for nodes used in scene graphs.Coin is a retained mode 3D visualiz...
Definition: SoNode.h:47
SoElement
SoElement is the abstract base class for all elements.
Definition: SoElement.h:34
SoLazyElement::push
virtual void push(SoState *state)
Definition: SoLazyElement.cpp:188
SoState
The SoState class manages the Coin scenegraph traversal state data.The SoState class is used by actio...
Definition: SoState.h:35
SoGLLazyElement
The SoGLLazyElement class is meant to optimize GL rendering.This is just a wrap-around implementation...
Definition: SoGLLazyElement.h:34
SoLazyElement::initClass
static void initClass()
Definition: SoLazyElement.cpp:123
SoLazyElement::init
virtual void init(SoState *state)
Definition: SoLazyElement.cpp:152
SoLazyElement
The SoLazyElement class is used to handle material and shape properties.So[GL]LazyElement is...
Definition: SoLazyElement.h:40
SoGLRenderCache
The SoGLRenderCache class is used to cache OpenGL calls.
Definition: SoGLRenderCache.h:34
SoElement::pop
virtual void pop(SoState *state, const SoElement *prevTopElement)
Definition: SoElement.cpp:585

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.