UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
canvas.h
Go to the documentation of this file.
1 #ifndef UGDK_GRAPHIC_CANVAS_H_
2 #define UGDK_GRAPHIC_CANVAS_H_
3 
5 #include <ugdk/graphic/manager.h>
6 #include <ugdk/math/vector2D.h>
7 #include <ugdk/math/geometry.h>
9 #include <ugdk/structure/types.h>
10 
11 #include <ugdk/desktop.h>
12 #include <ugdk/graphic.h>
13 
14 #include <memory>
15 #include <vector>
16 
17 namespace ugdk {
18 namespace graphic {
19 
28 class Canvas {
29  public:
30  Canvas(RenderTarget* render_target);
31  ~Canvas();
32 
34 
36  bool IsActive() const;
37  math::Vector2D size() const;
38  const math::Geometry& current_geometry() const { return geometry_stack_.back(); }
39  const structure::VisualEffect& current_visualeffect() const { return visualeffect_stack_.back(); }
40  const ShaderProgram* shader_program() const { return shader_program_; }
41 
42  void PushAndCompose(const math::Geometry& geometry);
43  void PushAndCompose(const structure::VisualEffect& effect);
44 
45  void PopGeometry();
46  void PopVisualEffect();
47 
48  //
49  void Clear(structure::Color);
50 
51  // Shader variables.
52 
53  void SendUniform(const std::string& name, float t1);
54  void SendUniform(const std::string& name, float t1, float t2);
55  void SendUniform(const std::string& name, const math::Vector2D&);
56  void SendUniform(const std::string& name, float t1, float t2, float t3);
57  void SendUniform(const std::string& name, float t1, float t2, float t3, float t4);
58  void SendUniform(const std::string& name, const TextureUnit& unit);
59 
61  void SendVertexData(const VertexData& data, VertexType type, size_t offset, int size = 2,
62  int vertex_per_data = 1);
63 
64  // Drawing
65  void DrawArrays(DrawMode, int first_vertex, int vertex_count);
66 
67  private:
68  void Bind();
69  void Unbind();
70  void SendGeometry();
71  void SendEffect();
72 
73  RenderTarget* render_target_;
74  std::vector<math::Geometry> geometry_stack_;
75  std::vector<structure::VisualEffect> visualeffect_stack_;
76  const ShaderProgram* shader_program_;
77  Canvas* previous_canvas_;
78  Canvas* next_canvas_;
79 };
80 
81 } // namespace graphic
82 } // namespace ugdk
83 
84 #endif // UGDK_GRAPHIC_CANVAS_H_
Canvas(RenderTarget *render_target)
Definition: drawmode.h:7
Definition: canvas.h:28
VertexType
Definition: manager.h:33
void SendVertexData(const VertexData &data, VertexType type, size_t offset, int size=2, int vertex_per_data=1)
The VertexType should later be disabled using Manager::DisableVertexType.
Definition: vector2D.h:18
bool IsActive() const
Queries if this object is currently bound.
Definition: color.h:9
Definition: textureunit.h:10
Definition: animation.h:11
Definition: vertexdata.h:20
Definition: visualeffect.h:9
void Clear(structure::Color)
void DrawArrays(DrawMode, int first_vertex, int vertex_count)
const math::Geometry & current_geometry() const
Definition: canvas.h:38
const ShaderProgram * shader_program() const
Definition: canvas.h:40
void SendUniform(const std::string &name, float t1)
math::Vector2D size() const
Definition: shaderprogram.h:11
Definition: geometry.h:15
void PushAndCompose(const math::Geometry &geometry)
void ChangeShaderProgram(const ShaderProgram *shader_program)
Definition: rendertarget.h:12
const structure::VisualEffect & current_visualeffect() const
Definition: canvas.h:39