Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Rendering.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Rendering_INCLUDE_ONCE
33 #define Rendering_INCLUDE_ONCE
34 
37 #include <vlGraphics/Actor.hpp>
39 #include <vlGraphics/Renderer.hpp>
40 #include <vlGraphics/Camera.hpp>
42 #include <vlCore/Transform.hpp>
43 #include <vlCore/Collection.hpp>
44 
45 namespace vl
46 {
69  {
71 
72  public:
74  Rendering();
75 
77  Rendering(const Rendering& other): RenderingAbstract(other) { *this = other; }
78 
80  Rendering& operator=(const Rendering& other);
81 
83  virtual void render();
84 
86  void setRenderQueueSorter(RenderQueueSorter* render_queue_sorter) { mRenderQueueSorter = render_queue_sorter; }
87 
89  RenderQueueSorter* renderQueueSorter() { return mRenderQueueSorter.get(); }
90 
94  const Collection<Renderer>& renderers() const { return mRenderers; }
95 
99  Collection<Renderer>& renderers() { return mRenderers; }
100 
102  void setRenderer(Renderer* renderer)
103  {
104  renderers().clear();
105  renderers().push_back(renderer);
106  }
107 
109  const Renderer* renderer() const
110  {
111  if (renderers().empty())
112  return NULL;
113  else
114  return renderers()[0].get();
115  }
116 
119  {
120  if (renderers().empty())
121  return NULL;
122  else
123  return renderers()[0].get();
124  }
125 
127  void setCamera(Camera* camera) { mCamera = camera; }
128 
130  const Camera* camera() const { return mCamera.get(); }
131 
133  Camera* camera() { return mCamera.get(); }
134 
136  Collection<SceneManager>* sceneManagers() { return mSceneManagers.get(); }
137 
139  const Collection<SceneManager>* sceneManagers() const { return mSceneManagers.get(); }
140 
143  void setTransform(Transform* transform) { mTransform = transform; }
144 
147  const Transform* transform() const { return mTransform.get(); }
148 
151  Transform* transform() { return mTransform.get(); }
152 
154  void setEvaluateLOD(bool evaluate_lod) { mEvaluateLOD = evaluate_lod; }
155 
157  bool evaluateLOD() const { return mEvaluateLOD; }
158 
162  void setShaderAnimationEnabled(bool animate_shaders) { mShaderAnimationEnabled = animate_shaders; }
163 
167  bool shaderAnimationEnabled() const { return mShaderAnimationEnabled; }
168 
170  void setCullingEnabled(bool enabled) { mCullingEnabled = enabled; }
171 
173  bool cullingEnabled() const { return mCullingEnabled; }
174 
178  void setAutomaticResourceInit(bool enable) { mAutomaticResourceInit = enable; }
179 
181  bool automaticResourceInit() const { return mAutomaticResourceInit; }
182 
184  bool nearFarClippingPlanesOptimized() const { return mNearFarClippingPlanesOptimized; }
185 
190  void setNearFarClippingPlanesOptimized(bool enabled) { mNearFarClippingPlanesOptimized = enabled; }
191 
196  const std::map<unsigned int, ref<Effect> >& effectOverrideMask() const { return mEffectOverrideMask; }
197 
202  std::map<unsigned int, ref<Effect> >& effectOverrideMask() { return mEffectOverrideMask; }
203 
204  protected:
205  // mic fixme: it would be nice to have a mechanism to request the visible actors at will and to
206  // compile and save the render-queue for later renderings to be reused without recomputing the culling.
207  // The user could be able to install actor-list or render-queue and use the flags READ|WRITE|TERMINATE
208  // to define wether the list should be used for reading, filled, cleaned up after rendering.
209  void fillRenderQueue( ActorCollection* actor_list );
210  RenderQueue* renderQueue() { return mRenderQueue.get(); }
211  ActorCollection* actorQueue() { return mActorQueue.get(); }
212 
213  protected:
221  std::map<unsigned int, ref<Effect> > mEffectOverrideMask;
222 
228  };
229 }
230 
231 #endif
void setCamera(Camera *camera)
The Camera that defines the point of view and viewport to be used when rendering the scene...
Definition: Rendering.hpp:127
ref< RenderQueueSorter > mRenderQueueSorter
Definition: Rendering.hpp:214
Collection< Renderer > & renderers()
The list of Renderers used to perform the rendering.
Definition: Rendering.hpp:99
void setAutomaticResourceInit(bool enable)
Whether OpenGL resources such as textures and GLSL programs should be automatically initialized when ...
Definition: Rendering.hpp:178
const Transform * transform() const
The root of the Transform tree updated at every rendering frame.
Definition: Rendering.hpp:147
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
bool mAutomaticResourceInit
Definition: Rendering.hpp:223
The Renderer class executes the actual rendering on the given RenderQueue.
Definition: Renderer.hpp:49
The RenderingAbstract class is the base of all the rendering related sub-classes. ...
std::map< unsigned int, ref< Effect > > & effectOverrideMask()
A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the follow...
Definition: Rendering.hpp:202
RenderQueueSorter * renderQueueSorter()
The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting i...
Definition: Rendering.hpp:89
ref< ActorCollection > mActorQueue
Definition: Rendering.hpp:215
Transform * transform()
The root of the Transform tree updated at every rendering frame.
Definition: Rendering.hpp:151
Renderer * renderer()
Utility function: returns the first renderer installed or NULL if none is found.
Definition: Rendering.hpp:118
const Camera * camera() const
The Camera that defines the point of view and viewport to be used when rendering the scene...
Definition: Rendering.hpp:130
Camera * camera()
The Camera that defines the point of view and viewport to be used when rendering the scene...
Definition: Rendering.hpp:133
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
void setTransform(Transform *transform)
The root of the Transform tree updated at every rendering frame.
Definition: Rendering.hpp:143
bool nearFarClippingPlanesOptimized() const
Returns whether near/far planes optimization is enabled.
Definition: Rendering.hpp:184
bool automaticResourceInit() const
Whether OpenGL resources such as textures and GLSL programs should be automatically initialized befor...
Definition: Rendering.hpp:181
ref< Camera > mCamera
Definition: Rendering.hpp:218
void setCullingEnabled(bool enabled)
Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the re...
Definition: Rendering.hpp:170
void setShaderAnimationEnabled(bool animate_shaders)
Whether Shader::shaderAnimator()->updateShader() should be called or not.
Definition: Rendering.hpp:162
Visualization Library main namespace.
const Collection< SceneManager > * sceneManagers() const
Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
Definition: Rendering.hpp:139
void setRenderer(Renderer *renderer)
Uitlity function: clears the renderers() list and adds the specified one.
Definition: Rendering.hpp:102
Collection< Renderer > mRenderers
Definition: Rendering.hpp:217
Rendering(const Rendering &other)
Copy constructor.
Definition: Rendering.hpp:77
ActorCollection * actorQueue()
Definition: Rendering.hpp:211
void setEvaluateLOD(bool evaluate_lod)
Whether the Level-Of-Detail should be evaluated or not.
Definition: Rendering.hpp:154
std::map< unsigned int, ref< Effect > > mEffectOverrideMask
Definition: Rendering.hpp:221
bool shaderAnimationEnabled() const
Whether Shader::shaderAnimator()->updateShader() should be called or not.
Definition: Rendering.hpp:167
#define NULL
Definition: OpenGLDefs.hpp:81
const Renderer * renderer() const
Utility function: returns the first renderer installed or NULL if none is found.
Definition: Rendering.hpp:109
The Rendering class collects all the information to perform the rendering of a scene.
Definition: Rendering.hpp:68
bool cullingEnabled() const
Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the re...
Definition: Rendering.hpp:173
ref< RenderQueue > mRenderQueue
Definition: Rendering.hpp:216
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
Definition: RenderQueue.hpp:45
void setRenderQueueSorter(RenderQueueSorter *render_queue_sorter)
The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting i...
Definition: Rendering.hpp:86
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
Definition: Actor.hpp:479
ref< Collection< SceneManager > > mSceneManagers
Definition: Rendering.hpp:220
bool mCullingEnabled
Definition: Rendering.hpp:224
It&#39;s basically an std::vector for Objects that is itself an Object so it can be reference counted and...
Definition: Collection.hpp:49
void setNearFarClippingPlanesOptimized(bool enabled)
Enabled/disables near/far planes optimization.
Definition: Rendering.hpp:190
ref< Transform > mTransform
Definition: Rendering.hpp:219
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
bool mShaderAnimationEnabled
Definition: Rendering.hpp:226
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49
bool evaluateLOD() const
Whether the Level-Of-Detail should be evaluated or not.
Definition: Rendering.hpp:157
bool mNearFarClippingPlanesOptimized
Definition: Rendering.hpp:227
The RenderQueueSorter class is the abstract base class of all the algorithms used to sort a set of Re...
RenderQueue * renderQueue()
Definition: Rendering.hpp:210
const Collection< Renderer > & renderers() const
The list of Renderers used to perform the rendering.
Definition: Rendering.hpp:94
Collection< SceneManager > * sceneManagers()
Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
Definition: Rendering.hpp:136
const std::map< unsigned int, ref< Effect > > & effectOverrideMask() const
A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the follow...
Definition: Rendering.hpp:196