FixedOrder_Camera.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Camera.hpp"
4 
6 
7 #include <map>
8 #include <vector>
9 
10 namespace iv
11 {
12 
21 class FixedOrder_Camera : public Camera
22 {
23 public:
26 
27  virtual void FrameStart() override;
28  virtual void AddRenderable_Solid( Renderable *, GLuint shader_id, GLuint primary_texture_id ) override;
29  virtual void AddRenderable_Translucent( Renderable *, GLuint shader_id, GLuint primary_texture_id ) override;
30  virtual void RunRender( CameraState const & state ) override;
31 
32 private:
33  struct RenderId
34  {
35  // primary identity
36  Renderable * renderable;
37 
38  // sorting
39  GLuint shader_id;
40  GLuint primary_texture_id;
41 
42  RenderId() : renderable( nullptr ), shader_id( 0 ), primary_texture_id( 0 ){}
43  };
44 
45  struct SolidInfo
46  {
47  unsigned frame_id;
48  unsigned depth;
49  };
50 
51  struct TranslucentInfo
52  {
53  RenderId id;
54  unsigned depth;
55 
56  TranslucentInfo() : id(), depth( 0 ){}
57  TranslucentInfo( RenderId id, unsigned depth ) : id( id ), depth( depth ){}
58  };
59 
60  struct RenderIdComparator
61  {
62  bool operator()( RenderId const & left, RenderId const & right ) const;
63  };
64 
65 private:
66  unsigned _depth_next;
67  std::map< RenderId, SolidInfo, RenderIdComparator > solids;
68  std::vector< TranslucentInfo > translucents;
69 };
70 
71 }