RenderQueue.h
Go to the documentation of this file.
1 #ifndef B_RENDERQUEUE_H
2 #define B_RENDERQUEUE_H
3 
4 #include <memory>
5 #include <map>
6 
7 #include "Renderer_GL.h"
8 #include "Shader.h"
9 #include "Material.h"
10 #include "Properties.h"
11 #include "IDrawable.h"
12 
13 struct RenderCall
14 {
16  std::string instanceName;
18 };
19 
26 class RenderQueue : public IDrawable
27 {
28 public:
29  /* Typedefs */
30  typedef std::multimap< std::string, RenderCall> RenderCallsOpaque;
31  typedef std::multimap< GLfloat, RenderCall> RenderCallsTransparent;
32 
33  /* Functions */
34 
38 
41  virtual ~RenderQueue(){}
42 
54  virtual void submitToRenderQueue(GLuint programID, const std::string &materialName, const std::string &drawableName, const std::string &instanceName, DrawablePtr drawable, GLfloat distanceToCamera = 0.0, bool isTransparent = false, GLenum blendSfactor = GL_SRC_ALPHA, GLenum blendDfactor = GL_ONE_MINUS_SRC_ALPHA);
55 
58  virtual void draw(GLenum mode = GL_TRIANGLES) override;
59 
64  virtual void drawInstance(const std::string &instanceName, GLenum mode) override { draw(mode); }
65 
68  virtual void clear();
69 
70 
71 private:
72 
73  /* Variables */
74 
75  RenderCallsOpaque _renderCallsOpaque;
76  RenderCallsTransparent _renderCallsTransparent;
77 
78 };
79 
80 typedef std::shared_ptr<RenderQueue> RenderQueuePtr;
81 
82 #endif /* defined(B_RENDERQUEUE_H) */
DrawablePtr drawable
Definition: RenderQueue.h:15
A render queue stores render calls and performs drawing in sorted order.
Definition: RenderQueue.h:26
GLenum blendSfactor
Definition: RenderQueue.h:17
virtual ~RenderQueue()
Virtual destructor.
Definition: RenderQueue.h:41
std::multimap< std::string, RenderCall > RenderCallsOpaque
Definition: RenderQueue.h:30
An interface for drawable objects.
Definition: IDrawable.h:9
std::string instanceName
Definition: RenderQueue.h:16
GLenum blendDfactor
Definition: RenderQueue.h:17
virtual void drawInstance(const std::string &instanceName, GLenum mode) override
Draws an instance of the queue to the screen.
Definition: RenderQueue.h:64
RenderQueue()
Constructor.
Definition: RenderQueue.h:37
Definition: RenderQueue.h:13
virtual void clear()
Remove all render calls.
Definition: RenderQueue.cpp:33
std::shared_ptr< IDrawable > DrawablePtr
Definition: IDrawable.h:30
virtual void submitToRenderQueue(GLuint programID, const std::string &materialName, const std::string &drawableName, const std::string &instanceName, DrawablePtr drawable, GLfloat distanceToCamera=0.0, bool isTransparent=false, GLenum blendSfactor=GL_SRC_ALPHA, GLenum blendDfactor=GL_ONE_MINUS_SRC_ALPHA)
Add a render call to the queue.
Definition: RenderQueue.cpp:3
std::multimap< GLfloat, RenderCall > RenderCallsTransparent
Definition: RenderQueue.h:31
std::shared_ptr< RenderQueue > RenderQueuePtr
Definition: RenderQueue.h:80
virtual void draw(GLenum mode=GL_TRIANGLES) override
Draw all drawable in the queue in a sorted manner.
Definition: RenderQueue.cpp:16