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 SHADED_HIDDEN_LINES
89 };
90
91 enum StereoMode {
92 MONO,
93 ANAGLYPH,
94 SEPARATE_OUTPUT,
95 QUAD_BUFFER = SEPARATE_OUTPUT,
96 INTERLEAVED_ROWS,
97 INTERLEAVED_COLUMNS
98 };
99
100 enum BufferType {
101 BUFFER_SINGLE,
102 BUFFER_DOUBLE
103 };
104
105 enum AutoClippingStrategy {
106 NO_AUTO_CLIPPING,
107 FIXED_NEAR_PLANE,
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
196protected:
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
222private:
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
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
The SoRenderManager class is used for controlling the rendering of a scene graph.
Definition SoRenderManager.h:53
SoRenderManager::SoRenderManager
SoRenderManager(void)
Definition SoRenderManager.cpp:247
SoRenderManager::StereoMode
StereoMode
Definition SoRenderManager.h:91
SoRenderManager::ANAGLYPH
@ ANAGLYPH
Definition SoRenderManager.h:93
SoRenderManager::SEPARATE_OUTPUT
@ SEPARATE_OUTPUT
Definition SoRenderManager.h:94
SoRenderManager::QUAD_BUFFER
@ QUAD_BUFFER
Definition SoRenderManager.h:95
SoRenderManager::INTERLEAVED_COLUMNS
@ INTERLEAVED_COLUMNS
Definition SoRenderManager.h:97
SoRenderManager::INTERLEAVED_ROWS
@ INTERLEAVED_ROWS
Definition SoRenderManager.h:96
SoRenderManager::MONO
@ MONO
Definition SoRenderManager.h:92
SoRenderManager::RenderMode
RenderMode
Definition SoRenderManager.h:81
SoRenderManager::BOUNDING_BOX
@ BOUNDING_BOX
Definition SoRenderManager.h:87
SoRenderManager::SHADED_HIDDEN_LINES
@ SHADED_HIDDEN_LINES
Definition SoRenderManager.h:88
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:105
SoRenderManager::FIXED_NEAR_PLANE
@ FIXED_NEAR_PLANE
Definition SoRenderManager.h:107
SoRenderManager::VARIABLE_NEAR_PLANE
@ VARIABLE_NEAR_PLANE
Definition SoRenderManager.h:108
SoRenderManager::NO_AUTO_CLIPPING
@ NO_AUTO_CLIPPING
Definition SoRenderManager.h:106
SoRenderManager::BufferType
BufferType
Definition SoRenderManager.h:100
SoRenderManager::BUFFER_SINGLE
@ BUFFER_SINGLE
Definition SoRenderManager.h:101
SoRenderManager::BUFFER_DOUBLE
@ BUFFER_DOUBLE
Definition SoRenderManager.h:102
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