Vital
Loading...
Searching...
No Matches
OpenGlBackground Class Reference

A class that manages and renders a background image using OpenGL. More...

#include <open_gl_background.h>

Public Member Functions

 OpenGlBackground ()
 Constructs an OpenGlBackground with no initial image.
 
virtual ~OpenGlBackground ()
 Destructor. Frees OpenGL resources if allocated.
 
void updateBackgroundImage (Image background)
 Updates the background image to a new one.
 
virtual void init (OpenGlWrapper &open_gl)
 Initializes OpenGL buffers and shader resources.
 
virtual void render (OpenGlWrapper &open_gl)
 Renders the background image.
 
virtual void destroy (OpenGlWrapper &open_gl)
 Cleans up OpenGL resources when the background is no longer needed.
 
void lock ()
 Locks the mutex for thread-safe operations.
 
void unlock ()
 Unlocks the mutex previously locked by lock().
 
OpenGLShaderProgram * shader ()
 Gets the shader used to render the image.
 
OpenGLShaderProgram::Uniform * texture_uniform ()
 Gets the shader uniform for the texture.
 
void bind (OpenGLContext &open_gl_context)
 Binds the vertex and element arrays, and the background texture.
 
void enableAttributes (OpenGLContext &open_gl_context)
 Enables vertex attribute arrays for position and texture coordinates.
 
void disableAttributes (OpenGLContext &open_gl_context)
 Disables vertex attribute arrays for position and texture coordinates.
 

Detailed Description

A class that manages and renders a background image using OpenGL.

The OpenGlBackground class is responsible for loading, updating, and displaying a background image with OpenGL. It provides thread-safe updating of the background image, manages vertex buffers, and sets up shader attributes for rendering the image.

Constructor & Destructor Documentation

◆ OpenGlBackground()

OpenGlBackground::OpenGlBackground ( )

Constructs an OpenGlBackground with no initial image.

◆ ~OpenGlBackground()

OpenGlBackground::~OpenGlBackground ( )
virtual

Destructor. Frees OpenGL resources if allocated.

Member Function Documentation

◆ bind()

void OpenGlBackground::bind ( OpenGLContext & open_gl_context)

Binds the vertex and element arrays, and the background texture.

Parameters
open_gl_contextThe OpenGL context.

◆ destroy()

void OpenGlBackground::destroy ( OpenGlWrapper & open_gl)
virtual

Cleans up OpenGL resources when the background is no longer needed.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context.

◆ disableAttributes()

void OpenGlBackground::disableAttributes ( OpenGLContext & open_gl_context)

Disables vertex attribute arrays for position and texture coordinates.

Parameters
open_gl_contextThe OpenGL context.

◆ enableAttributes()

void OpenGlBackground::enableAttributes ( OpenGLContext & open_gl_context)

Enables vertex attribute arrays for position and texture coordinates.

Parameters
open_gl_contextThe OpenGL context.

◆ init()

void OpenGlBackground::init ( OpenGlWrapper & open_gl)
virtual

Initializes OpenGL buffers and shader resources.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context and shader resources.

◆ lock()

void OpenGlBackground::lock ( )
inline

Locks the mutex for thread-safe operations.

Call unlock() afterwards to release the lock.

◆ render()

void OpenGlBackground::render ( OpenGlWrapper & open_gl)
virtual

Renders the background image.

Parameters
open_glThe OpenGlWrapper providing the OpenGL context.

This method locks a mutex to ensure thread safety when updating or rendering the background.

◆ shader()

OpenGLShaderProgram * OpenGlBackground::shader ( )
inline

Gets the shader used to render the image.

Returns
Pointer to the OpenGLShaderProgram for the image.

◆ texture_uniform()

OpenGLShaderProgram::Uniform * OpenGlBackground::texture_uniform ( )
inline

Gets the shader uniform for the texture.

Returns
Pointer to the Uniform object for the texture.

◆ unlock()

void OpenGlBackground::unlock ( )
inline

Unlocks the mutex previously locked by lock().

◆ updateBackgroundImage()

void OpenGlBackground::updateBackgroundImage ( Image background)

Updates the background image to a new one.

Parameters
backgroundThe new background Image to display.

This method is thread-safe. It sets a flag so the image will be loaded and updated on the next render call.


The documentation for this class was generated from the following files: