Coin: SoRenderManager.h Source File

| 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
40class SbViewportRegion;
41class SoEvent;
42class SoGLRenderAction;
43class SoAudioRenderAction;
44class SoNode;
45class SoCamera;
46class SoNodeSensor;
47class SoOneShotSensor;
48class SoSensor;
49class SoRenderManagerP;
50
51typedef void SoRenderManagerRenderCB(void * userdata, class SoRenderManager * mgr);
52
53 class COIN_DLL_API SoRenderManager {
54public:
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 {
82 AS_IS,
83 WIREFRAME,
84 POINTS,
85 WIREFRAME_OVERLAY,
86 HIDDEN_LINE,
87 BOUNDING_BOX
88 };
89
90 enum StereoMode {
91 MONO,
92 ANAGLYPH,
93 SEPARATE_OUTPUT,
94 QUAD_BUFFER = SEPARATE_OUTPUT,
95 INTERLEAVED_ROWS,
96 INTERLEAVED_COLUMNS
97 };
98
99 enum BufferType {
100 BUFFER_SINGLE,
101 BUFFER_DOUBLE
102 };
103
104 enum AutoClippingStrategy {
105 NO_AUTO_CLIPPING,
106 FIXED_NEAR_PLANE,
107 VARIABLE_NEAR_PLANE
108 };
109
110 SoRenderManager(void);
111 virtual ~SoRenderManager();
112
113 virtual void render(const SbBool clearwindow = TRUE,
114 const SbBool clearzbuffer = TRUE);
115
116 virtual void render(SoGLRenderAction * action,
117 const SbBool initmatrices = TRUE,
118 const SbBool clearwindow = TRUE,
119 const SbBool clearzbuffer = TRUE);
120
121 Superimposition * addSuperimposition(SoNode * scene,
122 uint32_t flags =
123 Superimposition::AUTOREDRAW |
124 Superimposition::ZBUFFERON |
125 Superimposition::CLEARZBUFFER);
126 void removeSuperimposition(Superimposition * s);
127
128 virtual void setSceneGraph(SoNode * const sceneroot);
129 virtual SoNode * getSceneGraph(void) const;
130
131 void setCamera(SoCamera * camera);
132 SoCamera * getCamera(void) const;
133
134 void setAutoClipping(AutoClippingStrategy autoclipping);
135 AutoClippingStrategy getAutoClipping(void) const;
136 void setNearPlaneValue(float value);
137 float getNearPlaneValue(void) const;
138 void setTexturesEnabled(const SbBool onoff);
139 SbBool isTexturesEnabled(void) const;
140 void setDoubleBuffer(const SbBool enable);
141 SbBool isDoubleBuffer(void) const;
142 void setRenderMode(const RenderMode mode);
143 RenderMode getRenderMode(void) const;
144 void setStereoMode(const StereoMode mode);
145 StereoMode getStereoMode(void) const;
146 void setStereoOffset(const float offset);
147 float getStereoOffset(void) const;
148
149 void setRenderCallback(SoRenderManagerRenderCB * f,
150 void * const userData = NULL);
151
152 SbBool isAutoRedraw(void) const;
153 void setRedrawPriority(const uint32_t priority);
154 uint32_t getRedrawPriority(void) const;
155
156 void scheduleRedraw(void);
157 void setWindowSize(const SbVec2s & newsize);
158 const SbVec2s & getWindowSize(void) const;
159 void setSize(const SbVec2s & newsize);
160 const SbVec2s & getSize(void) const;
161 void setOrigin(const SbVec2s & newOrigin);
162 const SbVec2s & getOrigin(void) const;
163 void setViewportRegion(const SbViewportRegion & newRegion);
164 const SbViewportRegion & getViewportRegion(void) const;
165 void setBackgroundColor(const SbColor4f & color);
166 const SbColor4f & getBackgroundColor(void) const;
167 void setOverlayColor(const SbColor4f & color);
168 SbColor4f getOverlayColor(void) const;
169 void setBackgroundIndex(const int index);
170 int getBackgroundIndex(void) const;
171 void setRGBMode(const SbBool onOrOff);
172 SbBool isRGBMode(void) const;
173 virtual void activate(void);
174 virtual void deactivate(void);
175
176 void setAntialiasing(const SbBool smoothing, const int numPasses);
177 void getAntialiasing(SbBool & smoothing, int & numPasses) const;
178 void setGLRenderAction(SoGLRenderAction * const action);
179 SoGLRenderAction * getGLRenderAction(void) const;
180 void setAudioRenderAction(SoAudioRenderAction * const action);
181 SoAudioRenderAction * getAudioRenderAction(void) const;
182
183 static void enableRealTimeUpdate(const SbBool flag);
184 static SbBool isRealTimeUpdateEnabled(void);
185 static uint32_t getDefaultRedrawPriority(void);
186
187 void addPreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
188 void removePreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
189
190 void addPostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
191 void removePostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
192
193 void reinitialize(void);
194
195protected:
196 int isActive(void) const;
197 void redraw(void);
198
199 void renderScene(SoGLRenderAction * action,
200 SoNode * scene,
201 uint32_t clearmask);
202
203 void actuallyRender(SoGLRenderAction * action,
204 const SbBool initmatrices = TRUE,
205 const SbBool clearwindow = TRUE,
206 const SbBool clearzbuffer = TRUE);
207
208 void renderSingle(SoGLRenderAction * action,
209 SbBool initmatrices,
210 SbBool clearwindow,
211 SbBool clearzbuffer);
212
213 void renderStereo(SoGLRenderAction * action,
214 SbBool initmatrices,
215 SbBool clearwindow,
216 SbBool clearzbuffer);
217
218 void initStencilBufferForInterleavedStereo(void);
219 void clearBuffers(SbBool color, SbBool depth);
220
221private:
222 void attachRootSensor(SoNode * const sceneroot);
223 void attachClipSensor(SoNode * const sceneroot);
224 void detachRootSensor(void);
225 void detachClipSensor(void);
226 static void nodesensorCB(void * data, SoSensor *);
227 static void prerendercb(void * userdata, SoGLRenderAction * action);
228
229 SoRenderManagerP * pimpl;
230 friend class SoRenderManagerP;
231 friend class SoSceneManager;
232 friend class Superimposition;
233
234}; // SoRenderManager
235
236#endif // !COIN_SORENDERMANAGER_H
SbColor4f
The SbColor4f class contains the red, green, blue and alpha components which make up a color value.
Definition SbColor4f.h:42
SbVec2s
The SbVec2s class is a 2 dimensional vector with short integer coordinates.
Definition SbVec2s.h:51
SbViewportRegion
The SbViewportRegion class is a viewport within a full window.
Definition SbViewportRegion.h:40
SoAudioRenderAction
The SoAudioRenderAction class renders the aural parts of the scene graph.
Definition SoAudioRenderAction.h:42
SoCamera
The SoCamera class is the abstract base class for camera definition nodes.
Definition SoCamera.h:64
SoEvent
The SoEvent class is the base class for all Coin events.
Definition SoEvent.h:45
SoGLRenderAction
The SoGLRenderAction class renders the scene graph with OpenGL calls.
Definition SoGLRenderAction.h:50
SoGLRenderAction::TransparencyType
TransparencyType
Definition SoGLRenderAction.h:61
SoNodeSensor
The SoNodeSensor class detects changes to nodes.
Definition SoNodeSensor.h:38
SoNode
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
SoOneShotSensor
The SoOneShotSensor class is a sensor which will trigger once.
Definition SoOneShotSensor.h:38
SoRenderManager::Superimposition
Definition SoRenderManager.h:56
SoRenderManager
The SoRenderManager class is used for controlling the rendering of a scene graph.
Definition SoRenderManager.h:53
SoRenderManager::StereoMode
StereoMode
Definition SoRenderManager.h:90
SoRenderManager::ANAGLYPH
@ ANAGLYPH
Definition SoRenderManager.h:92
SoRenderManager::SEPARATE_OUTPUT
@ SEPARATE_OUTPUT
Definition SoRenderManager.h:93
SoRenderManager::INTERLEAVED_ROWS
@ INTERLEAVED_ROWS
Definition SoRenderManager.h:95
SoRenderManager::MONO
@ MONO
Definition SoRenderManager.h:91
SoRenderManager::RenderMode
RenderMode
Definition SoRenderManager.h:81
SoRenderManager::WIREFRAME
@ WIREFRAME
Definition SoRenderManager.h:83
SoRenderManager::AS_IS
@ AS_IS
Definition SoRenderManager.h:82
SoRenderManager::HIDDEN_LINE
@ HIDDEN_LINE
Definition SoRenderManager.h:86
SoRenderManager::WIREFRAME_OVERLAY
@ WIREFRAME_OVERLAY
Definition SoRenderManager.h:85
SoRenderManager::POINTS
@ POINTS
Definition SoRenderManager.h:84
SoRenderManager::AutoClippingStrategy
AutoClippingStrategy
Definition SoRenderManager.h:104
SoRenderManager::FIXED_NEAR_PLANE
@ FIXED_NEAR_PLANE
Definition SoRenderManager.h:106
SoRenderManager::NO_AUTO_CLIPPING
@ NO_AUTO_CLIPPING
Definition SoRenderManager.h:105
SoRenderManager::BufferType
BufferType
Definition SoRenderManager.h:99
SoRenderManager::BUFFER_SINGLE
@ BUFFER_SINGLE
Definition SoRenderManager.h:100
SoSceneManager
The SoSceneManager class provides the main interface between the scene graph and the GUI toolkit.
Definition SoSceneManager.h:53
SoSensor
The SoSensor class is the abstract base class for all sensors.
Definition SoSensor.h:43