-
Notifications
You must be signed in to change notification settings - Fork 1
/
RenderBuffer.hpp
61 lines (45 loc) · 1.14 KB
/
RenderBuffer.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
#pragma once
#include "Debug.hpp"
#include "Logger.hpp"
#include "incgraphics.h"
namespace gl {
template <GLenum StorageT>
struct Renderbuffer {
GLuint rbo = 0;
Renderbuffer()
{}
auto id() const { return rbo; }
static void init(GLuint &rbo) {
glGenRenderbuffers(1, &rbo); GLERROR
gl::Renderbuffer<StorageT>::bind(rbo);
glRenderbufferStorage(GL_RENDERBUFFER, StorageT, GL_RENDERBUFFER, rbo); GLERROR
}
static void init(gl::Renderbuffer<StorageT> &rb, size_t width, size_t height) {
rb.init(width, height);
}
void init(size_t width, size_t height) {
gl::Renderbuffer<StorageT>::init(rbo, width, height);
}
static void bind(GLuint rbo) {
glBindRenderbuffer(GL_RENDERBUFFER, rbo); GLERROR
}
static void bind(gl::Renderbuffer<StorageT> &rb) {
rb.bind();
}
void bind() {
gl::Renderbuffer<StorageT>::bind(rbo);
}
static void unbind() {
glBindRenderbuffer(GL_RENDERBUFFER, 0); GLERROR
}
static void clear(GLuint &rbo) {
glDeleteRenderbuffers(1, &rbo); GLERROR
}
static void clear(gl::Renderbuffer<StorageT> &rbo) {
rbo.clear();
}
void clear() {
clear(rbo);
}
};
}