Created
March 28, 2020 19:15
-
-
Save PcChip/516749dbd0a62142d74cac88a3d3715b to your computer and use it in GitHub Desktop.
postProcessor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PostProcessor::PostProcessor(teShader* shader, GLuint width, GLuint height) | |
: myShader(shader), myTexture(), myWidth(width), myHeight(height), Confuse(GL_FALSE), Chaos(GL_FALSE), Shake(GL_FALSE) | |
{ | |
/* | |
Framebuffer MSFBO has: | |
- RenderBufferStorageMultisample RBO_Color | |
- RenderbufferStorageMultisample RBO_Depth | |
Framebuffer FBO has: | |
- FramebufferTexture2D myTexture.ID | |
*/ | |
// Initialize renderbuffer/framebuffer object | |
glGenFramebuffers(1, &this->myMSFBO); | |
glGenRenderbuffers(1, &this->myRBO_Color); | |
glGenRenderbuffers(1, &this->myRBO_Depth); | |
glGenFramebuffers(1, &this->myFBO); | |
// Initialize renderbuffer storage with a multisampled color buffer (don't need a depth/stencil buffer) | |
glBindFramebuffer(GL_FRAMEBUFFER, this->myMSFBO); | |
glBindRenderbuffer(GL_RENDERBUFFER, this->myRBO_Color); | |
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_RGB, width, height); // Allocate storage for render buffer object | |
glBindRenderbuffer(GL_RENDERBUFFER, this->myRBO_Depth); | |
glRenderbufferStorageMultisample(GL_RENDERBUFFER, 4, GL_DEPTH_COMPONENT24, width, height); | |
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, this->myRBO_Color); // Attach MS render buffer object to framebuffer | |
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, this->myRBO_Depth); // Attach MS render buffer object to framebuffer | |
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
std::cout << "ERROR::POSTPROCESSOR: Failed to initialize MSFBO" << std::endl; | |
else | |
std::cout << "PostProcessor MSFBO creation complete\n"; | |
// Also initialize the FBO/texture to blit multisampled color-buffer to; used for shader operations (for postprocessing effects) | |
glBindFramebuffer(GL_FRAMEBUFFER, this->myFBO); | |
this->myTexture.Generate(width, height, NULL); | |
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->myTexture.ID, 0); // Attach texture to framebuffer as its color attachment | |
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
std::cout << "ERROR::POSTPROCESSOR: Failed to initialize FBO" << std::endl; | |
else | |
std::cout << "PostProcessor FBO creation complete\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment