A class that manages and renders a background image using OpenGL.
More...
#include <open_gl_background.h>
|
| 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.
|
|
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.
◆ OpenGlBackground()
OpenGlBackground::OpenGlBackground |
( |
| ) |
|
◆ ~OpenGlBackground()
OpenGlBackground::~OpenGlBackground |
( |
| ) |
|
|
virtual |
Destructor. Frees OpenGL resources if allocated.
◆ bind()
void OpenGlBackground::bind |
( |
OpenGLContext & | open_gl_context | ) |
|
Binds the vertex and element arrays, and the background texture.
- Parameters
-
open_gl_context | The OpenGL context. |
◆ destroy()
Cleans up OpenGL resources when the background is no longer needed.
- Parameters
-
◆ disableAttributes()
void OpenGlBackground::disableAttributes |
( |
OpenGLContext & | open_gl_context | ) |
|
Disables vertex attribute arrays for position and texture coordinates.
- Parameters
-
open_gl_context | The OpenGL context. |
◆ enableAttributes()
void OpenGlBackground::enableAttributes |
( |
OpenGLContext & | open_gl_context | ) |
|
Enables vertex attribute arrays for position and texture coordinates.
- Parameters
-
open_gl_context | The OpenGL context. |
◆ init()
Initializes OpenGL buffers and shader resources.
- Parameters
-
open_gl | The 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()
Renders the background image.
- Parameters
-
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
-
background | The 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: