Buffer - Horizon-NTH/HorizonGUI GitHub Wiki
The Buffer
class, located in the hgui::kernel
namespace, serves as a powerful tool for encapsulating
render buffers and frame buffers. It simplifies the process of applying visual effects with
shaders and displaying the content of frame buffers on the screen. This class is a fundamental component
for achieving advanced graphical rendering in your application. The class can be found in the header file Buffer.h
.
-
Buffer(const std::shared_ptr<Shader>& shader, const std::shared_ptr<kernel::Texture>& texture)
: Constructs aBuffer
object with the specified shader and texture. The constructor sets up the necessary components to encapsulate rendering processes effectively.
-
void bind() const
: Binds the frame buffers, allowing you to render in it. -
void unbind() const
: Unbinds the frame buffers. -
void show() const
: Displays the content of the frame buffers on the screen, enabling you to visualize the rendered output. -
void clear() const
: Clears the contents of the frame buffers, making it ready for subsequent rendering.
#include <hgui/header/Buffer.h>
// Example Usage of Buffer class
std::shared_ptr<hgui::kernel::Shader> shader = /* initialize shader */;
std::shared_ptr<hgui::kernel::Texture> texture = /* initialize texture */;
hgui::kernel::Buffer buffer(shader, texture);
// Bind the buffer
buffer.bind();
// (Render your scene here)
// Unbind the buffer to conclude rendering
buffer.unbind();
// Show the content of the frame buffer on the screen with some effect depending on your shader
buffer.show();
// Clear the buffer for subsequent rendering
buffer.clear();
Note: In the "Example Usage" section, we demonstrate how to create a
Buffer
object with a shader and texture. You can bind the buffer to render scene with visual effects or no, unbind it to complete the rendering process, show the content of the frame buffer on the screen, and clear the buffer to prepare for further rendering. TheBuffer
class is an indispensable tool for managing rendering operations and applying advanced visual effects within your graphical application.