Open Inventor Reference
SoGLRenderAction.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * Further, this software is distributed without any warranty that it is
16  * free of the rightful claim of any third person regarding infringement
17  * or the like. Any license provided herein, whether implied or
18  * otherwise, applies only to this software file. Patent licenses, if
19  * any, provided herein do not apply to combinations of this program with
20  * other software, or any other product whatsoever.
21  *
22  * You should have received a copy of the GNU Lesser General Public
23  * License along with this library; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  *
26  * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27  * Mountain View, CA 94043, or:
28  *
29  * http://www.sgi.com
30  *
31  * For further information regarding this notice, see:
32  *
33  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34  *
35  */
36 
37 
38 /*
39  * Copyright (C) 1990,91 Silicon Graphics, Inc.
40  *
41  _______________________________________________________________________
42  ______________ S I L I C O N G R A P H I C S I N C . ____________
43  |
44  | $Revision: 1.1.1.1 $
45  |
46  | Description:
47  | Defines the SoGLRenderAction class
48  |
49  | Author(s) : Paul S. Strauss
50  |
51  ______________ S I L I C O N G R A P H I C S I N C . ____________
52  _______________________________________________________________________
53  */
54 
55 #ifndef _SO_GL_RENDER_ACTION_
56 #define _SO_GL_RENDER_ACTION_
57 
62 
63 class SbBox3f;
65 
67 typedef void SoGLRenderPassCB(void *userData);
68 
69 
72 
85 
87 
89 
90  public:
91 
95  ADD,
100  SORTED_OBJECT_BLEND
101  };
102 
104  enum AbortCode {
108  DELAY
109  };
110 
114  typedef AbortCode SoGLRenderAbortCB(void *userData);
115 
118  SoGLRenderAction(const SbViewportRegion &viewportRegion);
119 
120 
122  virtual ~SoGLRenderAction();
123 
125  void setViewportRegion(const SbViewportRegion &newRegion);
126 
128  const SbViewportRegion &getViewportRegion() const { return vpRegion; }
129 
131  void setUpdateArea(const SbVec2f &origin,
132  const SbVec2f &size);
139  void getUpdateArea(SbVec2f &origin, SbVec2f &size) const;
140 
148  void setAbortCallback(SoGLRenderAbortCB *funcArg,
149  void *userData)
150  { abortCB = funcArg; abortData = userData; }
151 
158  TransparencyType getTransparencyType() const { return transpType; }
159 
161  void setSmoothing(bool smooth);
165  bool isSmoothing() const { return doSmooth; }
166 
168  void setNumPasses(int num) { numPasses = num; }
175  int getNumPasses() const { return numPasses; }
176 
178  void setPassUpdate(bool flag) { passUpdate = flag; }
182  bool isPassUpdate() const { return passUpdate; }
183 
187  void setPassCallback(SoGLRenderPassCB *funcArg, void *userData)
188  { passCB = funcArg; passData = userData; }
189 
191  void setCacheContext(uint32_t context);
196 
198  virtual void invalidateState();
199 
200  SoEXTENDER public:
202  int getCurPass() const { return curPass; }
203 
205  bool abortNow()
206  { return (hasTerminated() || (abortCB != NULL && checkAbort())); }
207 
215  bool handleTransparency(bool isTransparent = FALSE);
216 
217 
218  SoINTERNAL public:
219  static void initClass();
220 
223  bool isDelaying() const { return sortObjs || delayObjs; }
224 
228  void addDelayedPath(SoPath *path);
229 
232  { return renderingDelPaths; }
233 
234  int getCullTestResults() { return cullBits; }
235  void setCullTestResults(int b) { cullBits = b; }
236 
239  bool setAllowDelayedPath(bool flag);
240 
242  bool getAllowDelayedPaths() { return allowDelayedPaths; }
243 
244  protected:
246  virtual void beginTraversal(SoNode *node);
247 
248  private:
249  SbViewportRegion vpRegion;
250  SbVec2f updateOrigin;
251  SbVec2f updateSize;
252 
253 
255  SoGLRenderAbortCB *abortCB;
256  void *abortData;
257 
259  TransparencyType transpType;
260  bool doSmooth;
261  int numPasses;
262  int curPass;
263  bool passUpdate;
264  SoGLRenderPassCB *passCB;
265  void *passData;
266 
268  bool renderingTranspObjs;
269  bool delayObjs;
271  bool sortObjs;
272  SoPathList transpPaths;
274  SbBox3f *bboxes;
275  int numBBoxes;
276 
277  uint32_t cacheContext;
278 
280  SoPathList delayedPaths;
281  bool renderingDelPaths;
282  bool allowDelayedPaths;
283 
287  enum flags {
288  TRANSPARENCY_TYPE = 0x01,
289  SMOOTHING = 0x02,
290  ALL = 0x03
291  };
292  uint32_t whatChanged;
293 
295  void renderAllPasses(SoNode *node);
296 
298  void renderPass(SoNode *node, int pass);
299 
302  void renderTransparentObjs();
303 
305  void enableBlending(bool enable);
306 
308  bool checkAbort();
309 
312  int cullBits;
313 
314 };
315 
316 #endif /* _SO_GL_RENDER_ACTION_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition: SbBasic.h:154
#define FALSE
Definition: SbBasic.h:79
#define SoINTERNAL
Definition: SbBasic.h:155
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition: SbSystem.h:81
unsigned int uint32_t
Definition: SbTypeDefs.h:44
void SoGLRenderPassCB(void *userData)
Callback functions used between rendering passes should be of this type.
#define SO_ACTION_HEADER(className)
Macros to be called within the class definition header for an action subclass:
Definition: SoSubAction.h:87
3D box class.
Definition: SbBox.h:81
2D vector class.
Definition: SbLinear.h:246
Class for representing a viewport.
Abstract base class for all actions.
Definition: SoAction.h:179
bool hasTerminated() const
Returns TRUE if the traversal has reached a termination condition.
Definition: SoAction.h:287
Renders a scene graph using OpenGL.
void addDelayedPath(SoPath *path)
Adds to the list of paths to render after all other stuff (including delayed/sorted transparent objec...
AbortCode
Possible return codes from a render abort callback.
@ ABORT
Stop traversing the rest of the graph.
@ PRUNE
Do not traverse this node or its children.
@ CONTINUE
Continue as usual.
void setAbortCallback(SoGLRenderAbortCB *funcArg, void *userData)
Sets callback to call during rendering to test for an abort condition.
void setCullTestResults(int b)
bool handleTransparency(bool isTransparent=FALSE)
Returns TRUE if render action handles processing of a transparent object (if it is to be sorted and r...
virtual void invalidateState()
Invalidate the state, forcing it to be recreated at the next apply.
TransparencyType getTransparencyType() const
Sets/returns transparency quality level to use when rendering.
bool isRenderingDelayedPaths() const
Returns TRUE if currently rendering delayed paths.
virtual void beginTraversal(SoNode *node)
Initiates action on graph.
bool setAllowDelayedPath(bool flag)
Sets if delayed paths are allowed while rendering.
bool abortNow()
Returns TRUE if render action should abort - checks user callback.
void setTransparencyType(TransparencyType type)
virtual ~SoGLRenderAction()
Destructor.
bool isPassUpdate() const
Sets/returns a flag indicating whether intermediate results are displayed after each antialiasing pas...
AbortCode SoGLRenderAbortCB(void *userData)
Callback functions for render abort should be of this type.
bool isDelaying() const
Returns TRUE if rendering is being delayed because of transparency sorting or delaying.
void setPassUpdate(bool flag)
static void initClass()
void setCacheContext(uint32_t context)
SoGLRenderAction(const SbViewportRegion &viewportRegion)
Constructor.
TransparencyType
Various levels of transparency rendering quality.
@ ADD
Use additive GL alpha blending.
@ SCREEN_DOOR
Use GL patterns for screen-door transparency.
@ BLEND
Use GL alpha blending.
@ DELAYED_ADD
Use additive blending, do transp objs last.
@ SORTED_OBJECT_ADD
Use additive blending, sort objects by bbox.
@ DELAYED_BLEND
Use GL alpha blending, do transp objs last.
uint32_t getCacheContext() const
Sets/returns the OpenGL cache context.
const SbViewportRegion & getViewportRegion() const
Returns viewport region to use for rendering.
bool getAllowDelayedPaths()
Returns if delayed paths are currently allowed.
void setSmoothing(bool smooth)
int getCurPass() const
Returns current rendering pass number.
void getUpdateArea(SbVec2f &origin, SbVec2f &size) const
Sets/returns the current update area, which is the rectangular area of the viewport region that will ...
bool isSmoothing() const
Sets/returns smoothing flag.
void setViewportRegion(const SbViewportRegion &newRegion)
Changes viewport region to use for rendering.
int getNumPasses() const
Sets/returns number of rendering passes for multipass rendering.
void setNumPasses(int num)
void setPassCallback(SoGLRenderPassCB *funcArg, void *userData)
Sets a callback function to invoke between passes when antialiasing.
void setUpdateArea(const SbVec2f &origin, const SbVec2f &size)
Computes bounding box of a scene.
Abstract base class for all database nodes.
Definition: SoNode.h:103
Maintains a list of pointers to paths.
Definition: SoLists.h:212
Path that points to a list of hierarchical nodes.
Definition: SoPath.h:109