Visualization Library 2.0.0-b3

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-2017, 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>
41 #include <vlGraphics/Camera.hpp>
43 #include <vlCore/Transform.hpp>
44 #include <vlCore/Collection.hpp>
45 
46 namespace vl
47 {
70  {
72 
73  public:
75  Rendering();
76 
78  Rendering(const Rendering& other): RenderingAbstract(other) { *this = other; }
79 
81  Rendering& operator=(const Rendering& other);
82 
84  virtual void render();
85 
87  void setRenderQueueSorter(RenderQueueSorter* render_queue_sorter) { mRenderQueueSorter = render_queue_sorter; }
88 
90  RenderQueueSorter* renderQueueSorter() { return mRenderQueueSorter.get(); }
91 
95  const Collection<Renderer>& renderers() const { return mRenderers; }
96 
100  Collection<Renderer>& renderers() { return mRenderers; }
101 
103  void setRenderer(Renderer* renderer)
104  {
105  renderers().clear();
106  renderers().push_back(renderer);
107  }
108 
110  const Renderer* renderer() const
111  {
112  if (renderers().empty())
113  return NULL;
114  else
115  return renderers()[0].get();
116  }
117 
120  {
121  if (renderers().empty())
122  return NULL;
123  else
124  return renderers()[0].get();
125  }
126 
128  void setCamera(Camera* camera) { mCamera = camera; }
129 
131  const Camera* camera() const { return mCamera.get(); }
132 
134  Camera* camera() { return mCamera.get(); }
135 
137  Collection<SceneManager>* sceneManagers() { return mSceneManagers.get(); }
138 
140  const Collection<SceneManager>* sceneManagers() const { return mSceneManagers.get(); }
141 
144  void setTransform(Transform* transform) { mTransform = transform; }
145 
148  const Transform* transform() const { return mTransform.get(); }
149 
152  Transform* transform() { return mTransform.get(); }
153 
155  void setEvaluateLOD(bool evaluate_lod) { mEvaluateLOD = evaluate_lod; }
156 
158  bool evaluateLOD() const { return mEvaluateLOD; }
159 
163  void setShaderAnimationEnabled(bool animate_shaders) { mShaderAnimationEnabled = animate_shaders; }
164 
168  bool shaderAnimationEnabled() const { return mShaderAnimationEnabled; }
169 
171  void setCullingEnabled(bool enabled) { mCullingEnabled = enabled; }
172 
174  bool cullingEnabled() const { return mCullingEnabled; }
175 
179  void setAutomaticResourceInit(bool enable) { mAutomaticResourceInit = enable; }
180 
182  bool automaticResourceInit() const { return mAutomaticResourceInit; }
183 
185  bool nearFarClippingPlanesOptimized() const { return mNearFarClippingPlanesOptimized; }
186 
191  void setNearFarClippingPlanesOptimized(bool enabled) { mNearFarClippingPlanesOptimized = enabled; }
192 
197  const std::map<unsigned int, ref<Effect> >& effectOverrideMask() const { return mEffectOverrideMask; }
198 
203  std::map<unsigned int, ref<Effect> >& effectOverrideMask() { return mEffectOverrideMask; }
204 
205  protected:
206  // mic fixme: it would be nice to have a mechanism to request the visible actors at will and to
207  // compile and save the render-queue for later renderings to be reused without recomputing the culling.
208  // The user could be able to install actor-list or render-queue and use the flags READ|WRITE|TERMINATE
209  // to define wether the list should be used for reading, filled, cleaned up after rendering.
210  void fillRenderQueue( ActorCollection* actor_list );
211  RenderQueue* renderQueue() { return mRenderQueue.get(); }
212  ActorCollection* actorQueue() { return mActorQueue.get(); }
213 
214  protected:
222  std::map<unsigned int, ref<Effect> > mEffectOverrideMask;
223 
229  };
230 }
231 
232 #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:128
ref< RenderQueueSorter > mRenderQueueSorter
Definition: Rendering.hpp:215
Collection< Renderer > & renderers()
The list of Renderers used to perform the rendering.
Definition: Rendering.hpp:100
void setAutomaticResourceInit(bool enable)
Whether OpenGL resources such as textures and GLSL programs should be automatically initialized when ...
Definition: Rendering.hpp:179
const Transform * transform() const
The root of the Transform tree updated at every rendering frame.
Definition: Rendering.hpp:148
Implements a 4x4 matrix transform used to define the position and orientation of an Actor...
Definition: Transform.hpp:72
bool mAutomaticResourceInit
Definition: Rendering.hpp:224
The Renderer class executes the actual rendering on the given RenderQueue.
Definition: Renderer.hpp:48
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:203
RenderQueueSorter * renderQueueSorter()
The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting i...
Definition: Rendering.hpp:90
ref< ActorCollection > mActorQueue
Definition: Rendering.hpp:216
Transform * transform()
The root of the Transform tree updated at every rendering frame.
Definition: Rendering.hpp:152
Renderer * renderer()
Utility function: returns the first renderer installed or NULL if none is found.
Definition: Rendering.hpp:119
const Camera * camera() const
The Camera that defines the point of view and viewport to be used when rendering the scene...
Definition: Rendering.hpp:131
Camera * camera()
The Camera that defines the point of view and viewport to be used when rendering the scene...
Definition: Rendering.hpp:134
#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:144
bool nearFarClippingPlanesOptimized() const
Returns whether near/far planes optimization is enabled.
Definition: Rendering.hpp:185
bool automaticResourceInit() const
Whether OpenGL resources such as textures and GLSL programs should be automatically initialized befor...
Definition: Rendering.hpp:182
ref< Camera > mCamera
Definition: Rendering.hpp:219
void setCullingEnabled(bool enabled)
Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the re...
Definition: Rendering.hpp:171
void setShaderAnimationEnabled(bool animate_shaders)
Whether Shader::shaderAnimator()->updateShader() should be called or not.
Definition: Rendering.hpp:163
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:140
void setRenderer(Renderer *renderer)
Uitlity function: clears the renderers() list and adds the specified one.
Definition: Rendering.hpp:103
Collection< Renderer > mRenderers
Definition: Rendering.hpp:218
Rendering(const Rendering &other)
Copy constructor.
Definition: Rendering.hpp:78
ActorCollection * actorQueue()
Definition: Rendering.hpp:212
void setEvaluateLOD(bool evaluate_lod)
Whether the Level-Of-Detail should be evaluated or not.
Definition: Rendering.hpp:155
std::map< unsigned int, ref< Effect > > mEffectOverrideMask
Definition: Rendering.hpp:222
bool shaderAnimationEnabled() const
Whether Shader::shaderAnimator()->updateShader() should be called or not.
Definition: Rendering.hpp:168
#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:110
The Rendering class collects all the information to perform the rendering of a scene.
Definition: Rendering.hpp:69
bool cullingEnabled() const
Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the re...
Definition: Rendering.hpp:174
ref< RenderQueue > mRenderQueue
Definition: Rendering.hpp:217
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:87
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
Definition: Actor.hpp:479
ref< Collection< SceneManager > > mSceneManagers
Definition: Rendering.hpp:221
bool mCullingEnabled
Definition: Rendering.hpp:225
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:191
ref< Transform > mTransform
Definition: Rendering.hpp:220
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
bool mShaderAnimationEnabled
Definition: Rendering.hpp:227
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
bool evaluateLOD() const
Whether the Level-Of-Detail should be evaluated or not.
Definition: Rendering.hpp:158
bool mNearFarClippingPlanesOptimized
Definition: Rendering.hpp:228
The RenderQueueSorter class is the abstract base class of all the algorithms used to sort a set of Re...
RenderQueue * renderQueue()
Definition: Rendering.hpp:211
const Collection< Renderer > & renderers() const
The list of Renderers used to perform the rendering.
Definition: Rendering.hpp:95
Collection< SceneManager > * sceneManagers()
Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
Definition: Rendering.hpp:137
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:197