Render Buffer - Horizon-NTH/HorizonGUI GitHub Wiki

RenderBuffer

Overview

The RenderBuffer class in the hgui::kernel namespace provides a mechanism for creating and managing OpenGL Render Buffers. Render Buffers are commonly used in off-screen rendering, such as frame buffers, for storing depth and stencil information. This class facilitates the creation, binding, updating, and management of Render Buffers. The class is designed to work with OpenGL for rendering and requires an active OpenGL context. This class is defined in the header file RenderBuffer.h.

Constructors

  • RenderBuffer(): Constructs a RenderBuffer by generating a new Render Buffer ID.

Member Functions

  • void bind() const: Binds the Render Buffer to the current OpenGL context, making it the active Render Buffer for subsequent operations.

  • void unbind() const: Unbinds the currently bound Render Buffer, restoring the default state for operations.

  • void create_depth_stencil() const: Creates a depth and stencil attachment for the Render Buffer, making it suitable for depth and stencil information storage.

  • GLuint get_id() const: Retrieves the ID of the Render Buffer.

Example Usage

#include <hgui/header/RenderBuffer.h>

// Example Usage of RenderBuffer class
hgui::kernel::RenderBuffer rbo;

// Bind the Render Buffer
rbo.bind();

// Create depth and stencil attachment
rbo.create_depth_stencil();

// Perform rendering operations using the Render Buffer

// Don't forget to unbind the Render Buffer when done
rbo.unbind();

Note: In the "Example Usage" section, you should bind the Render Buffer and create a depth and stencil attachment if required. Make sure to unbind the Render Buffer when finished to avoid interfering with subsequent operations.