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]
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 
38 #include <vlGraphics/Shader.hpp>
39 #include <vlGraphics/Actor.hpp>
40 #include <map>
41 
42 namespace vl
43 {
44  //-----------------------------------------------------------------------------
45  // Renderer
46  //-----------------------------------------------------------------------------
50  {
52 
53  public:
54  Renderer();
55 
56  virtual ~Renderer() {}
57 
60  virtual const RenderQueue* render(const RenderQueue* in_render_queue, Camera* camera, real frame_clock);
61 
65  const RenderQueue* renderRaw(const RenderQueue* in_render_queue, Camera* camera, real frame_clock);
66 
67  void setProjViewTransfCallback(ProjViewTransfCallback* callback) { mProjViewTransfCallback = callback; }
68 
69  const ProjViewTransfCallback* projViewTransfCallback() const { return mProjViewTransfCallback.get(); }
70 
71  ProjViewTransfCallback* projViewTransfCallback() { return mProjViewTransfCallback.get(); }
72 
77  const std::map<unsigned int, ref<Shader> >& shaderOverrideMask() const { return mShaderOverrideMask; }
78 
83  std::map<unsigned int, ref<Shader> >& shaderOverrideMask() { return mShaderOverrideMask; }
84 
87  std::vector<RenderStateSlot>& overriddenDefaultRenderStates() { return mOverriddenDefaultRenderStates; }
88 
91  const std::vector<RenderStateSlot>& overriddenDefaultRenderStates() const { return mOverriddenDefaultRenderStates; }
92 
93  bool isEnabled(unsigned int mask) { return (mask & mEnableMask) != 0; }
94  bool isEnabled(const Actor* actor) { return actor->isEnabled() && (actor->enableMask() & mEnableMask) != 0; }
95 
97  void setFramebuffer(FramebufferObject* framebuffer) { mFramebuffer = framebuffer; }
98 
100  const FramebufferObject* framebuffer() const { return mFramebuffer.get(); }
101 
103  FramebufferObject* framebuffer() { return mFramebuffer.get(); }
104 
105  protected:
107 
108  // used to reset the OpenGL states & enables at the end of the rendering.
111 
112  std::map<unsigned int, ref<Shader> > mShaderOverrideMask;
113 
114  std::vector<RenderStateSlot> mOverriddenDefaultRenderStates;
115 
117  };
118  //------------------------------------------------------------------------------
119 }
120 
121 #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...
ref< FramebufferObject > mFramebuffer
Definition: Renderer.hpp:106
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:69
The Renderer class executes the actual rendering on the given RenderQueue.
Definition: Renderer.hpp:49
ref< ProjViewTransfCallback > mProjViewTransfCallback
Definition: Renderer.hpp:116
vl::ref< EnableSet > mDummyEnables
Definition: Renderer.hpp:109
const FramebufferObject * framebuffer() const
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:100
bool isEnabled(const Actor *actor)
Definition: Renderer.hpp:94
FramebufferObject * framebuffer()
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:103
std::map< unsigned int, ref< Shader > > mShaderOverrideMask
Definition: Renderer.hpp:112
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:83
#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.
std::vector< RenderStateSlot > & overriddenDefaultRenderStates()
Render states that will be used as default by the opengl context by this renderer.
Definition: Renderer.hpp:87
void setProjViewTransfCallback(ProjViewTransfCallback *callback)
Definition: Renderer.hpp:67
vl::ref< RenderStateSet > mDummyStateSet
Definition: Renderer.hpp:110
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:77
virtual ~Renderer()
Definition: Renderer.hpp:56
bool isEnabled(unsigned int mask)
Definition: Renderer.hpp:93
void setFramebuffer(FramebufferObject *framebuffer)
The Framebuffer on which the rendering is performed.
Definition: Renderer.hpp:97
The RenderQueue class collects a list of RenderToken objects to be sorted and rendered.
Definition: RenderQueue.hpp:45
Implements a framebuffer object to be used as a rendering target as specified by the ARB_framebuffer_...
const std::vector< RenderStateSlot > & overriddenDefaultRenderStates() const
Render states that will be used as default by the opengl context by this renderer.
Definition: Renderer.hpp:91
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
ProjViewTransfCallback * projViewTransfCallback()
Definition: Renderer.hpp:71
std::vector< RenderStateSlot > mOverriddenDefaultRenderStates
Definition: Renderer.hpp:114
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49