Visualization Library 2.0.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Renderer.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 Renderer_INCLUDE_ONCE
33 #define Renderer_INCLUDE_ONCE
34 
37 #include <vlGraphics/Shader.hpp>
38 #include <vlGraphics/Actor.hpp>
39 #include <map>
40 
41 namespace vl
42 {
43  //-----------------------------------------------------------------------------
44  // Renderer
45  //-----------------------------------------------------------------------------
49  {
51 
52  public:
53  Renderer();
54 
55  virtual ~Renderer() {}
56 
59  virtual const RenderQueue* render(const RenderQueue* in_render_queue, Camera* camera, real frame_clock);
60 
64  const RenderQueue* renderRaw(const RenderQueue* in_render_queue, Camera* camera, real frame_clock);
65 
66  void setProjViewTransfCallback(ProjViewTransfCallback* callback) { mProjViewTransfCallback = callback; }
67 
68  const ProjViewTransfCallback* projViewTransfCallback() const { return mProjViewTransfCallback.get(); }
69 
70  ProjViewTransfCallback* projViewTransfCallback() { return mProjViewTransfCallback.get(); }
71 
76  const std::map<unsigned int, ref<Shader> >& shaderOverrideMask() const { return mShaderOverrideMask; }
77 
82  std::map<unsigned int, ref<Shader> >& shaderOverrideMask() { return mShaderOverrideMask; }
83 
86  std::vector<RenderStateSlot>& overriddenDefaultRenderStates() { return mOverriddenDefaultRenderStates; }
87 
90  const std::vector<RenderStateSlot>& overriddenDefaultRenderStates() const { return mOverriddenDefaultRenderStates; }
91 
92  bool isEnabled(unsigned int mask) { return (mask & mEnableMask) != 0; }
93  bool isEnabled(const Actor* actor) { return actor->isEnabled() && (actor->enableMask() & mEnableMask) != 0; }
94 
96  void setFramebuffer(Framebuffer* framebuffer) { mFramebuffer = framebuffer; }
97 
99  const Framebuffer* framebuffer() const { return mFramebuffer.get(); }
100 
102  Framebuffer* framebuffer() { return mFramebuffer.get(); }
103 
104  protected:
106 
107  // used to reset the OpenGL states & enables at the end of the rendering.
110 
111  std::map<unsigned int, ref<Shader> > mShaderOverrideMask;
112 
113  std::vector<RenderStateSlot> mOverriddenDefaultRenderStates;
114 
116  };
117  //------------------------------------------------------------------------------
118 }
119 
120 #endif
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
Callback class to update the state of the projection, view, transform and normal matrices of a GLSLPr...
bool isEnabled() const
Whether an Actor should be considered for rendering, picking, scene bounding box calculation etc...
Definition: Actor.hpp:277
const ProjViewTransfCallback * projViewTransfCallback() const
Definition: Renderer.hpp:68
const Framebuffer * framebuffer() const
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:99
The Renderer class executes the actual rendering on the given RenderQueue.
Definition: Renderer.hpp:48
ref< ProjViewTransfCallback > mProjViewTransfCallback
Definition: Renderer.hpp:115
vl::ref< EnableSet > mDummyEnables
Definition: Renderer.hpp:108
void setFramebuffer(Framebuffer *framebuffer)
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:96
bool isEnabled(const Actor *actor)
Definition: Renderer.hpp:93
std::map< unsigned int, ref< Shader > > mShaderOverrideMask
Definition: Renderer.hpp:111
std::map< unsigned int, ref< Shader > > & shaderOverrideMask()
A bitmask/Shader map used to everride the Shader of those Actors whose enable mask satisfy the follow...
Definition: Renderer.hpp:82
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
unsigned int enableMask() const
The enable mask of an Actor is usually used to defines whether the actor should be rendered or not de...
Definition: Actor.hpp:270
Visualization Library main namespace.
Framebuffer * framebuffer()
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:102
std::vector< RenderStateSlot > & overriddenDefaultRenderStates()
Render states that will be used as default by the opengl context by this renderer.
Definition: Renderer.hpp:86
void setProjViewTransfCallback(ProjViewTransfCallback *callback)
Definition: Renderer.hpp:66
vl::ref< RenderStateSet > mDummyStateSet
Definition: Renderer.hpp:109
Base class providing all the basic funtionalities of a Renderer.
const std::map< unsigned int, ref< Shader > > & shaderOverrideMask() const
A bitmask/Shader map used to everride the Shader of those Actors whose enable mask satisfy the follow...
Definition: Renderer.hpp:76
virtual ~Renderer()
Definition: Renderer.hpp:55
bool isEnabled(unsigned int mask)
Definition: Renderer.hpp:92
ref< Framebuffer > mFramebuffer
Definition: Renderer.hpp:105
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
Definition: RenderQueue.hpp:45
const std::vector< RenderStateSlot > & overriddenDefaultRenderStates() const
Render states that will be used as default by the opengl context by this renderer.
Definition: Renderer.hpp:90
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ProjViewTransfCallback * projViewTransfCallback()
Definition: Renderer.hpp:70
std::vector< RenderStateSlot > mOverriddenDefaultRenderStates
Definition: Renderer.hpp:113
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:50
The Framebuffer class defines an abstract &#39;surface&#39; where OpenGL can render into. ...
Definition: Framebuffer.hpp:49