Simulant  21.12-574
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
pipeline.h
1 #pragma once
2 
3 #include <map>
4 
5 #include "generic/managed.h"
6 #include "generic/identifiable.h"
7 #include "generic/property.h"
8 #include "nodes/stage_node.h"
9 #include "generic/manual_object.h"
10 #include "types.h"
11 #include "interfaces/nameable.h"
12 #include "viewport.h"
13 
14 namespace smlt {
15 
16 class Compositor;
17 class RenderableStore;
18 
19 class Pipeline:
20  public TypedDestroyableObject<Pipeline, Compositor>,
21  public RefCounted<Pipeline> {
22 
23 public:
24  Pipeline(
25  Compositor* render_sequence,
26  const std::string& name,
27  StagePtr stage, CameraPtr camera
28  );
29 
30  virtual ~Pipeline();
31 
32  CameraPtr camera() const;
33  StagePtr stage() const;
34  TexturePtr target() const;
35  uint32_t clear_flags() const;
36 
37  int32_t priority() const;
38  PipelinePtr set_priority(int32_t priority);
39 
40  void deactivate();
41  void activate();
42  bool is_active() const { return is_active_; }
43 
44  PipelinePtr set_viewport(const Viewport& v) {
45  viewport_ = v;
46  return this;
47  }
48 
49  PipelinePtr set_target(TextureID t) {
50  target_ = t;
51  return this;
52  }
53 
54  PipelinePtr set_clear_flags(uint32_t viewport_clear_flags) {
55  clear_mask_ = viewport_clear_flags;
56  return this;
57  }
58 
59  PipelinePtr set_detail_level_distances(
60  float nearest_cutoff,
61  float near_cutoff,
62  float mid_cutoff,
63  float far_cutoff
64  );
65 
66  DetailLevel detail_level_at_distance(float dist) const;
67 
68  PipelinePtr set_name(const std::string& name) {
69  name_ = name;
70  return this;
71  }
72 
73  std::string name() const {
74  return name_;
75  }
76 
77  PipelinePtr set_camera(CameraPtr c);
78 
80  bool is_complete() const {
81  return stage_ && camera_;
82  }
83 private:
84  uint32_t id_ = 0;
85 
86  void set_stage(StagePtr s);
87 
88  sig::Connection stage_destroy_;
89  sig::Connection camera_destroy_;
90 
91  Compositor* sequence_ = nullptr;
92  int32_t priority_ = 0;
93  StagePtr stage_;
94  CameraPtr camera_;
95 
96  TextureID target_;
97  Viewport viewport_;
98 
99  uint32_t clear_mask_ = 0;
100  bool is_active_ = false;
101  std::string name_;
102 
103  float detail_level_end_distances_[DETAIL_LEVEL_MAX];
104 
105  friend class Compositor;
106 
107 public:
108  Property<decltype(&Pipeline::viewport_)> viewport = { this, &Pipeline::viewport_ };
109 };
110 
111 }
smlt::Property
Definition: property.h:202
smlt::sig::Connection
Definition: signal.h:65
smlt::RefCounted
Definition: managed.h:65
smlt
Definition: animation.cpp:25
smlt::Pipeline::is_complete
bool is_complete() const
Definition: pipeline.h:80
smlt::Compositor
Definition: compositor.h:38
smlt::UniqueID< TexturePtr >
smlt::TypedDestroyableObject
Definition: manual_object.h:34
smlt::Pipeline
Definition: pipeline.h:21
smlt::default_init_ptr< Stage >
smlt::Viewport
Definition: viewport.h:44