-
Notifications
You must be signed in to change notification settings - Fork 0
/
framebuffers.hpp
61 lines (53 loc) · 1.15 KB
/
framebuffers.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef FRAMEBUFFERS_HPP
#define FRAMEBUFFERS_HPP
#include <headers.hpp>
#include <set>
#include <types.hpp>
namespace buffers {
/*
* Internal rappresentation
* of a framebuffer
*/
struct Buffer {
Buffer() = default;
Buffer( const GLuint fbo ) :
FBO{ fbo } {}
GLuint FBO{ GL_INVALID_INDEX };
GLuint texture{ GL_INVALID_INDEX };
GLuint RBO{ GL_INVALID_INDEX };
operator GLuint() const
{
return FBO;
}
bool operator < ( const Buffer& other ) const
{
return FBO < other.FBO;
}
};
/*
* Handle the creation and destruction
* of framebuffers
*/
class Framebuffers
{
public:
using pointer = std::shared_ptr< Framebuffers >;
using buffer_id_t = GLuint;
Framebuffers( const types::win_size& window );
GLuint create_buffer();
GLenum bind( const GLuint fbo );
void unbind();
~Framebuffers();
/*
* Clear all the buffers or just the
* selected one.
*/
long clear( GLuint buffer_id = 0 );
private:
GLuint create_renderbuffer();
GLuint create_texture();
std::set<Buffer> buffers;
types::win_size window_size;
};
}
#endif //FRAMEBUFFERS_HPP