The FBORenderer represents and manages an entire FrameBufferObject. This allows one to draw entire scenes first to a texture, then perform some operations on that texture, then draw that texture to the screen. Shaders have uniforms projectionMatrix (mat4), colourTexture (sampler2D), and depthTexture (sampler2D) More...
#include <FBORenderer.hpp>
Inheritance diagram for BARE2D::FBORenderer:
Collaboration diagram for BARE2D::FBORenderer:Public Member Functions | |
| FBORenderer (std::string &fragShader, std::string &vertShader, unsigned int windowWidth, unsigned int windowHeight, unsigned int numColourAttachments=1) | |
| virtual | ~FBORenderer () |
| virtual void | init () override |
| Initializes all necessary bits of the renderer. More... | |
| virtual void | initUniforms () override |
| Initializes all uniforms, such as colour attachments, depth attachments, etc. More... | |
| void | setCamera (std::shared_ptr< Camera2D > &cam) |
| std::shared_ptr< Camera2D > | getCamera () |
| void | disableAttachment (unsigned int index) |
| void | enableAttachment (unsigned int index) |
| void | disableAttachments () |
| void | enableAttachments () |
| virtual void | render () override |
| Actually renders the contents to the screen! More... | |
| virtual void | begin () override |
| Clears the necessary vectors, etc. to prepare for draw() calls, etc. More... | |
| virtual void | end () override |
| Creates the renderbatches, does necessary stuff before render() call. More... | |
| virtual void | destroy () override |
| Frees all necessary memory. More... | |
Public Member Functions inherited from BARE2D::Renderer | |
| Renderer () | |
| virtual | ~Renderer () |
| ShaderProgram * | getShader () |
Protected Member Functions | |
| virtual void | preRender () override |
| Does stuff inside of the render function, within the shader's use. More... | |
| virtual void | createRenderBatches () override |
| Constructs all of the render batches from data given by, say, draw() calls. More... | |
| virtual void | bind () |
| Binds the FBO and appropriate texture attachments. More... | |
| virtual void | unbind () |
| Unbinds the FBO + textures. More... | |
| virtual void | createTextures () |
| Creates all of the OpenGL textures, and takes their handles into m_colourTextureID, and m_depthTextureID. More... | |
| virtual void | createFBO () |
| Creates the OpenGL FBO instance and holds its handle in m_fboID;. More... | |
Protected Member Functions inherited from BARE2D::Renderer | |
| virtual void | link (std::initializer_list< std::string > attributes) |
Protected Attributes | |
| GLuint | m_fboID |
| GLuint * | m_textureIDs = nullptr |
| unsigned int | m_numTextures |
| std::shared_ptr< Camera2D > | m_camera |
| std::string | m_fragmentShaderPath |
| std::string | m_vertexShaderPath |
| bool | m_shaderHasDepth = false |
Protected Attributes inherited from BARE2D::Renderer | |
| ShaderProgram | m_shader |
| VAO | m_vertexArrayObject |
| std::vector< RenderBatch > | m_batches |
The FBORenderer represents and manages an entire FrameBufferObject. This allows one to draw entire scenes first to a texture, then perform some operations on that texture, then draw that texture to the screen. Shaders have uniforms projectionMatrix (mat4), colourTexture (sampler2D), and depthTexture (sampler2D)
Definition at line 17 of file FBORenderer.hpp.
| BARE2D::FBORenderer::FBORenderer | ( | std::string & | fragShader, |
| std::string & | vertShader, | ||
| unsigned int | windowWidth, | ||
| unsigned int | windowHeight, | ||
| unsigned int | numColourAttachments = 1 |
||
| ) |
Definition at line 15 of file FBORenderer.cpp.
References m_camera, and m_numTextures.
|
virtual |
Definition at line 30 of file FBORenderer.cpp.
References m_textureIDs.
|
overridevirtual |
Clears the necessary vectors, etc. to prepare for draw() calls, etc.
Reimplemented from BARE2D::Renderer.
Definition at line 134 of file FBORenderer.cpp.
References BARE2D::Renderer::begin(), bind(), BARE2D::Renderer::m_shader, and BARE2D::ShaderProgram::use().
Here is the call graph for this function:
|
protectedvirtual |
Binds the FBO and appropriate texture attachments.
Definition at line 363 of file FBORenderer.cpp.
References BARE2D::GLContext::bindTexture(), BARE2D::GLContextManager::getContext(), m_fboID, m_numTextures, m_textureIDs, and BARE2D::GLContext::setActiveTexture().
Referenced by begin(), and init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedvirtual |
Creates the OpenGL FBO instance and holds its handle in m_fboID;.
Definition at line 341 of file FBORenderer.cpp.
References createTextures(), BARE2D::FBO_FAILURE, m_fboID, and BARE2D::throwFatalError().
Referenced by init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overrideprotectedvirtual |
Constructs all of the render batches from data given by, say, draw() calls.
Implements BARE2D::Renderer.
Definition at line 192 of file FBORenderer.cpp.
References BARE2D::VAO::bindVBO(), BARE2D::Glyph::bottomLeft, BARE2D::Glyph::bottomRight, BARE2D::Renderer::m_batches, m_textureIDs, BARE2D::Renderer::m_vertexArrayObject, BARE2D::Glyph::texture, BARE2D::Glyph::topLeft, BARE2D::Glyph::topRight, and BARE2D::VAO::unbindVBO().
Referenced by render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedvirtual |
Creates all of the OpenGL textures, and takes their handles into m_colourTextureID, and m_depthTextureID.
Definition at line 267 of file FBORenderer.cpp.
References BARE2D::GLContext::bindTexture(), BARE2D::GLContextManager::getContext(), m_camera, m_numTextures, m_shaderHasDepth, m_textureIDs, and BARE2D::GLContext::setActiveTexture().
Referenced by createFBO().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Frees all necessary memory.
Reimplemented from BARE2D::Renderer.
Definition at line 124 of file FBORenderer.cpp.
References BARE2D::Renderer::destroy(), m_fboID, m_numTextures, and m_textureIDs.
Here is the call graph for this function:| void BARE2D::FBORenderer::disableAttachment | ( | unsigned int | index | ) |
Definition at line 42 of file FBORenderer.cpp.
| void BARE2D::FBORenderer::disableAttachments | ( | ) |
Definition at line 50 of file FBORenderer.cpp.
References m_numTextures.
| void BARE2D::FBORenderer::enableAttachment | ( | unsigned int | index | ) |
Definition at line 46 of file FBORenderer.cpp.
| void BARE2D::FBORenderer::enableAttachments | ( | ) |
Definition at line 56 of file FBORenderer.cpp.
References m_numTextures.
|
overridevirtual |
Creates the renderbatches, does necessary stuff before render() call.
Reimplemented from BARE2D::Renderer.
Definition at line 165 of file FBORenderer.cpp.
References BARE2D::Renderer::m_shader, unbind(), and BARE2D::ShaderProgram::unuse().
Here is the call graph for this function:| std::shared_ptr< Camera2D > BARE2D::FBORenderer::getCamera | ( | ) |
Definition at line 38 of file FBORenderer.cpp.
References m_camera.
|
overridevirtual |
Initializes all necessary bits of the renderer.
Reimplemented from BARE2D::Renderer.
Definition at line 62 of file FBORenderer.cpp.
References BARE2D::VAO::addVertexAttribute(), bind(), BARE2D::ShaderProgram::compileShaders(), createFBO(), BARE2D::Renderer::init(), initUniforms(), BARE2D::Renderer::link(), m_fboID, m_fragmentShaderPath, m_numTextures, BARE2D::Renderer::m_shader, BARE2D::Renderer::m_vertexArrayObject, m_vertexShaderPath, unbind(), BARE2D::ShaderProgram::unuse(), and BARE2D::ShaderProgram::use().
Here is the call graph for this function:
|
overridevirtual |
Initializes all uniforms, such as colour attachments, depth attachments, etc.
Reimplemented from BARE2D::Renderer.
Definition at line 110 of file FBORenderer.cpp.
References BARE2D::ShaderProgram::doesUniformExist(), m_numTextures, BARE2D::Renderer::m_shader, m_shaderHasDepth, and BARE2D::ShaderProgram::setUniform().
Referenced by init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overrideprotectedvirtual |
Does stuff inside of the render function, within the shader's use.
The camera should only be used to actually draw the FBO.
Reimplemented from BARE2D::Renderer.
Definition at line 172 of file FBORenderer.cpp.
References BARE2D::GLContext::bindTexture(), BARE2D::GLContextManager::getContext(), m_camera, m_numTextures, BARE2D::Renderer::m_shader, m_textureIDs, BARE2D::GLContext::setActiveTexture(), and BARE2D::ShaderProgram::setUniformMatrix().
Referenced by render().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Actually renders the contents to the screen!
Reimplemented from BARE2D::Renderer.
Definition at line 232 of file FBORenderer.cpp.
References BARE2D::VAO::bind(), createRenderBatches(), BARE2D::GLContextManager::getContext(), BARE2D::Renderer::m_batches, BARE2D::Renderer::m_shader, BARE2D::Renderer::m_vertexArrayObject, preRender(), BARE2D::GLContext::setActiveTexture(), BARE2D::VAO::unbind(), BARE2D::ShaderProgram::unuse(), and BARE2D::ShaderProgram::use().
Here is the call graph for this function:| void BARE2D::FBORenderer::setCamera | ( | std::shared_ptr< Camera2D > & | cam | ) |
Definition at line 34 of file FBORenderer.cpp.
References m_camera.
|
protectedvirtual |
Unbinds the FBO + textures.
Definition at line 375 of file FBORenderer.cpp.
References BARE2D::GLContextManager::getContext(), m_numTextures, and BARE2D::GLContext::unbindTexture().
Referenced by end(), and init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Definition at line 78 of file FBORenderer.hpp.
Referenced by createTextures(), FBORenderer(), getCamera(), preRender(), and setCamera().
|
protected |
Definition at line 69 of file FBORenderer.hpp.
Referenced by bind(), createFBO(), destroy(), and init().
|
protected |
Definition at line 81 of file FBORenderer.hpp.
Referenced by init().
|
protected |
Definition at line 74 of file FBORenderer.hpp.
Referenced by bind(), createTextures(), destroy(), disableAttachments(), enableAttachments(), FBORenderer(), init(), initUniforms(), preRender(), and unbind().
|
protected |
Definition at line 84 of file FBORenderer.hpp.
Referenced by createTextures(), and initUniforms().
|
protected |
Definition at line 71 of file FBORenderer.hpp.
Referenced by bind(), createRenderBatches(), createTextures(), destroy(), preRender(), and ~FBORenderer().
|
protected |
Definition at line 81 of file FBORenderer.hpp.
Referenced by init().