RenderTarget.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "gl.h"
5 #include <array>
6 
7 namespace iv
8 {
9 
11 {
12 public:
17  static const constexpr int MaxTexturingUnits = 2;
18 
19  struct Geometry
20  {
26 
31  float density;
32 
33  Geometry();
34  Geometry( float2 size, float density );
35  };
36 
37 public:
38  RenderTarget();
39  virtual ~RenderTarget(){}
40 
41  // depth buffer
42  void DepthBufferClear( float value );
43  void DepthBufferMode( GLenum test_condition, bool write_enabled );
44 
45  // blending
46  void Blending( bool enabled );
47 
48  // geometry
49  Geometry geometry() const;
50 
51  // state control
52  void bind_texture( int texture_unit, GLuint texture_id );
53  void bind_shader( GLuint program_id );
54 
55 protected:
61  void frame_setup();
62 
68  void frame_close();
69 
73  void set_geometry( Geometry geometry );
74 
75 private:
76  void ClearDepthBuffer();
77 
78 private:
79  Geometry _geometry;
80 
81  // state cache
82  int _texture_unit;
83  std::array< GLuint, MaxTexturingUnits > _texture_ids;
84  GLuint _program_id;
85 };
86 
87 }