ElementRenderer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../Rendering/CameraState.hpp"
4 #include "../OpenGL/gl.h"
6 #include <map>
7 #include <vector>
8 
9 namespace iv
10 {
11 
12 class Elem;
13 
17 {
18 public:
19  virtual void render( CameraState const & camera, std::optional< float > depth_override ) = 0;
20 };
21 
25 {
26 public:
28  ElementRenderer( Instance * inst );
29  Instance * instance() const;
30 
31  //----------------- root control -----------------------------------
34  void init_frame();
35  void end_frame();
36 
37  //----------------- first pass --------------------------------
45  virtual void AddRenderable_Solid( Renderable *, GLuint shader_id, GLuint primary_texture_id ) = 0;
46  virtual void AddRenderable_Translucent( Renderable *, GLuint shader_id, GLuint primary_texture_id ) = 0;
47 
48 
49  //----------------- second pass --------------------------------
53  void QueueSecondPass( Elem * );
54 
60  void DequeueSecondPass( Elem * );
61 
62 //--------------------- stats -----------------------------------------
67 
72 
73 protected:
74  void RunSecondPasses();
75  virtual void FrameStart() = 0;
76  virtual void RunRender( CameraState const & state ) = 0;
77 
78 private:
79  Instance * inst;
80  std::vector< Elem * > second_pass;
81 
82  // stats
83  unsigned _first_passes;
84  unsigned _second_passes;
85 };
86 
87 }