Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoRenderManager.h
1 #ifndef COIN_SORENDERMANAGER_H
2 #define COIN_SORENDERMANAGER_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #include <Inventor/SbColor4f.h>
37 #include <Inventor/SbVec2s.h>
38 #include <Inventor/actions/SoGLRenderAction.h>
39 
40 class SbViewportRegion;
41 class SoEvent;
42 class SoGLRenderAction;
44 class SoNode;
45 class SoCamera;
46 class SoNodeSensor;
47 class SoOneShotSensor;
48 class SoSensor;
49 class SoRenderManagerP;
50 
51 typedef void SoRenderManagerRenderCB(void * userdata, class SoRenderManager * mgr);
52 
53 class COIN_DLL_API SoRenderManager {
54 public:
55 
56  class COIN_DLL_API Superimposition {
57  public:
58  enum StateFlags {
59  ZBUFFERON = 0x0001,
60  CLEARZBUFFER = 0x0002,
61  AUTOREDRAW = 0x0004,
62  BACKGROUND = 0x0008
63  };
64 
65  Superimposition(SoNode * scene,
66  SbBool enabled,
67  SoRenderManager * manager,
68  uint32_t flags);
69  ~Superimposition();
70 
71  void render(SoGLRenderAction * action, SbBool clearcolorbuffer = FALSE);
72  void setEnabled(SbBool yes);
73  int getStateFlags(void) const;
74  void setTransparencyType(SoGLRenderAction::TransparencyType transparencytype);
75 
76  private:
77  static void changeCB(void * data, SoSensor * sensor);
78  class SuperimpositionP * pimpl;
79  };
80 
81  enum RenderMode {
88  SHADED_HIDDEN_LINES
89  };
90 
91  enum StereoMode {
95  QUAD_BUFFER = SEPARATE_OUTPUT,
97  INTERLEAVED_COLUMNS
98  };
99 
100  enum BufferType {
102  BUFFER_DOUBLE
103  };
104 
108  VARIABLE_NEAR_PLANE
109  };
110 
111  SoRenderManager(void);
112  virtual ~SoRenderManager();
113 
114  virtual void render(const SbBool clearwindow = TRUE,
115  const SbBool clearzbuffer = TRUE);
116 
117  virtual void render(SoGLRenderAction * action,
118  const SbBool initmatrices = TRUE,
119  const SbBool clearwindow = TRUE,
120  const SbBool clearzbuffer = TRUE);
121 
122  Superimposition * addSuperimposition(SoNode * scene,
123  uint32_t flags =
124  Superimposition::AUTOREDRAW |
125  Superimposition::ZBUFFERON |
126  Superimposition::CLEARZBUFFER);
127  void removeSuperimposition(Superimposition * s);
128 
129  virtual void setSceneGraph(SoNode * const sceneroot);
130  virtual SoNode * getSceneGraph(void) const;
131 
132  void setCamera(SoCamera * camera);
133  SoCamera * getCamera(void) const;
134 
135  void setAutoClipping(AutoClippingStrategy autoclipping);
136  AutoClippingStrategy getAutoClipping(void) const;
137  void setNearPlaneValue(float value);
138  float getNearPlaneValue(void) const;
139  void setTexturesEnabled(const SbBool onoff);
140  SbBool isTexturesEnabled(void) const;
141  void setDoubleBuffer(const SbBool enable);
142  SbBool isDoubleBuffer(void) const;
143  void setRenderMode(const RenderMode mode);
144  RenderMode getRenderMode(void) const;
145  void setStereoMode(const StereoMode mode);
146  StereoMode getStereoMode(void) const;
147  void setStereoOffset(const float offset);
148  float getStereoOffset(void) const;
149 
150  void setRenderCallback(SoRenderManagerRenderCB * f,
151  void * const userData = NULL);
152 
153  SbBool isAutoRedraw(void) const;
154  void setRedrawPriority(const uint32_t priority);
155  uint32_t getRedrawPriority(void) const;
156 
157  void scheduleRedraw(void);
158  void setWindowSize(const SbVec2s & newsize);
159  const SbVec2s & getWindowSize(void) const;
160  void setSize(const SbVec2s & newsize);
161  const SbVec2s & getSize(void) const;
162  void setOrigin(const SbVec2s & newOrigin);
163  const SbVec2s & getOrigin(void) const;
164  void setViewportRegion(const SbViewportRegion & newRegion);
165  const SbViewportRegion & getViewportRegion(void) const;
166  void setBackgroundColor(const SbColor4f & color);
167  const SbColor4f & getBackgroundColor(void) const;
168  void setOverlayColor(const SbColor4f & color);
169  SbColor4f getOverlayColor(void) const;
170  void setBackgroundIndex(const int index);
171  int getBackgroundIndex(void) const;
172  void setRGBMode(const SbBool onOrOff);
173  SbBool isRGBMode(void) const;
174  virtual void activate(void);
175  virtual void deactivate(void);
176 
177  void setAntialiasing(const SbBool smoothing, const int numPasses);
178  void getAntialiasing(SbBool & smoothing, int & numPasses) const;
179  void setGLRenderAction(SoGLRenderAction * const action);
180  SoGLRenderAction * getGLRenderAction(void) const;
181  void setAudioRenderAction(SoAudioRenderAction * const action);
182  SoAudioRenderAction * getAudioRenderAction(void) const;
183 
184  static void enableRealTimeUpdate(const SbBool flag);
185  static SbBool isRealTimeUpdateEnabled(void);
186  static uint32_t getDefaultRedrawPriority(void);
187 
188  void addPreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
189  void removePreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
190 
191  void addPostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
192  void removePostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
193 
194  void reinitialize(void);
195 
196 protected:
197  int isActive(void) const;
198  void redraw(void);
199 
200  void renderScene(SoGLRenderAction * action,
201  SoNode * scene,
202  uint32_t clearmask);
203 
204  void actuallyRender(SoGLRenderAction * action,
205  const SbBool initmatrices = TRUE,
206  const SbBool clearwindow = TRUE,
207  const SbBool clearzbuffer = TRUE);
208 
209  void renderSingle(SoGLRenderAction * action,
210  SbBool initmatrices,
211  SbBool clearwindow,
212  SbBool clearzbuffer);
213 
214  void renderStereo(SoGLRenderAction * action,
215  SbBool initmatrices,
216  SbBool clearwindow,
217  SbBool clearzbuffer);
218 
219  void initStencilBufferForInterleavedStereo(void);
220  void clearBuffers(SbBool color, SbBool depth);
221 
222 private:
223  void attachRootSensor(SoNode * const sceneroot);
224  void attachClipSensor(SoNode * const sceneroot);
225  void detachRootSensor(void);
226  void detachClipSensor(void);
227  static void nodesensorCB(void * data, SoSensor *);
228  static void prerendercb(void * userdata, SoGLRenderAction * action);
229 
230  SoRenderManagerP * pimpl;
231  friend class SoRenderManagerP;
232  friend class SoSceneManager;
233  friend class Superimposition;
234 
235 }; // SoRenderManager
236 
237 #endif // !COIN_SORENDERMANAGER_H
Definition: SoRenderManager.h:106
StereoMode
Definition: SoRenderManager.h:91
The SoCamera class is the abstract base class for camera definition nodes.
Definition: SoCamera.h:64
Definition: SoRenderManager.h:56
Definition: SoRenderManager.h:83
The SbColor4f class contains the red, green, blue and alpha components which make up a color value...
Definition: SbColor4f.h:42
Definition: SoRenderManager.h:96
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
AutoClippingStrategy
Definition: SoRenderManager.h:105
The SoNodeSensor class detects changes to nodes.
Definition: SoNodeSensor.h:38
Definition: SoRenderManager.h:94
Definition: SoRenderManager.h:107
BufferType
Definition: SoRenderManager.h:100
The SoSensor class is the abstract base class for all sensors.
Definition: SoSensor.h:43
The SoRenderManager class is used for controlling the rendering of a scene graph. ...
Definition: SoRenderManager.h:53
Definition: SoRenderManager.h:84
TransparencyType
Definition: SoGLRenderAction.h:61
The SoAudioRenderAction class renders the aural parts of the scene graph.
Definition: SoAudioRenderAction.h:42
Definition: SoRenderManager.h:92
The SoOneShotSensor class is a sensor which will trigger once.
Definition: SoOneShotSensor.h:38
Definition: SoRenderManager.h:93
Definition: SoRenderManager.h:85
Definition: SoRenderManager.h:82
The SoEvent class is the base class for all Coin events.
Definition: SoEvent.h:45
The SoSceneManager class provides the main interface between the scene graph and the GUI toolkit...
Definition: SoSceneManager.h:53
RenderMode
Definition: SoRenderManager.h:81
Definition: SoRenderManager.h:87
The SbViewportRegion class is a viewport within a full window.
Definition: SbViewportRegion.h:40
Definition: SoRenderManager.h:86
Definition: SoRenderManager.h:101
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition: SbVec2s.h:51
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition: SoGLRenderAction.h:50