-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfbo.cpp
More file actions
60 lines (46 loc) · 1.39 KB
/
Copy pathfbo.cpp
File metadata and controls
60 lines (46 loc) · 1.39 KB
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
#include "fbo.h"
#include <iostream>
FBO::FBO(GLenum tempAttachment, GLenum tempKind, GLuint textureID)
{
activeRBO = false;
attachment = tempAttachment;
kind = tempKind;
glGenFramebuffers(1, &frameBufferID);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferID);
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, kind, textureID, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void FBO::updateFBO(GLenum tempAttachment, GLuint textureID)
{
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferID);
glFramebufferTexture2D(GL_FRAMEBUFFER, tempAttachment, kind, textureID, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void FBO::updateRBO(GLint width, GLint height)
{
glGenRenderbuffers(1, &renderBufferID);
glBindRenderbuffer(GL_RENDERBUFFER, renderBufferID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, width, height);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferID);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_COMPONENT, GL_RENDERBUFFER, renderBufferID);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
activeRBO = true;
}
void FBO::bindFBO()
{
glBindFramebuffer(GL_FRAMEBUFFER, frameBufferID);
}
void FBO::unbindFBO()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void FBO::bindRBO()
{
glBindRenderbuffer(GL_RENDERBUFFER, renderBufferID);
}
void FBO::unbindRBO()
{
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}