A utility class for rendering a single image using OpenGL.
More...
#include <open_gl_image.h>
|
| OpenGlImage () |
| Constructs an OpenGlImage with default settings.
|
|
virtual | ~OpenGlImage () |
| Destructor.
|
|
void | init (OpenGlWrapper &open_gl) |
| Initializes the OpenGL buffers and shader attributes needed for rendering the image.
|
|
void | drawImage (OpenGlWrapper &open_gl) |
| Draws the image to the current OpenGL context.
|
|
void | destroy (OpenGlWrapper &open_gl) |
| Releases any OpenGL resources allocated by this object.
|
|
void | lock () |
| Locks the internal mutex for thread-safe operations.
|
|
void | unlock () |
| Unlocks the mutex previously locked with lock().
|
|
void | setOwnImage (Image &image) |
| Sets the image from an owned copy.
|
|
void | setImage (Image *image) |
| Sets the image to render without taking ownership.
|
|
void | setColor (Colour color) |
| Sets the color tint applied to the image.
|
|
void | setPosition (float x, float y, int index) |
| Sets a specific vertex position by index.
|
|
void | setTopLeft (float x, float y) |
| Sets the top-left corner position of the image quad.
|
|
void | setBottomLeft (float x, float y) |
| Sets the bottom-left corner position of the image quad.
|
|
void | setBottomRight (float x, float y) |
| Sets the bottom-right corner position of the image quad.
|
|
void | setTopRight (float x, float y) |
| Sets the top-right corner position of the image quad.
|
|
int | getImageWidth () |
| Gets the width of the currently set image.
|
|
int | getImageHeight () |
| Gets the height of the currently set image.
|
|
void | setAdditive (bool additive) |
| Enables or disables additive blending mode.
|
|
void | setUseAlpha (bool use_alpha) |
| Enables or disables alpha blending.
|
|
void | setScissor (bool scissor) |
| Enables or disables scissor test when drawing the image.
|
|
A utility class for rendering a single image using OpenGL.
The OpenGlImage class manages loading an Image into an OpenGL texture and provides methods for drawing that image in a specified position using OpenGL. It supports thread-safe image updates and can apply various blending modes.
◆ OpenGlImage()
OpenGlImage::OpenGlImage |
( |
| ) |
|
◆ ~OpenGlImage()
OpenGlImage::~OpenGlImage |
( |
| ) |
|
|
virtual |
Destructor.
Ensures that OpenGL resources are properly released if still allocated.
◆ destroy()
Releases any OpenGL resources allocated by this object.
- Parameters
-
◆ drawImage()
Draws the image to the current OpenGL context.
- Parameters
-
The image is drawn using the currently set vertex positions, color, and blending mode. If a new image was provided, it will load it before drawing.
◆ getImageHeight()
int OpenGlImage::getImageHeight |
( |
| ) |
|
|
inline |
Gets the height of the currently set image.
- Returns
- The image height in pixels.
◆ getImageWidth()
int OpenGlImage::getImageWidth |
( |
| ) |
|
|
inline |
Gets the width of the currently set image.
- Returns
- The image width in pixels.
◆ init()
Initializes the OpenGL buffers and shader attributes needed for rendering the image.
- Parameters
-
open_gl | The OpenGlWrapper that provides the OpenGL context and shaders. |
◆ lock()
void OpenGlImage::lock |
( |
| ) |
|
|
inline |
Locks the internal mutex for thread-safe operations.
Call unlock() to release the lock.
◆ setAdditive()
void OpenGlImage::setAdditive |
( |
bool | additive | ) |
|
|
inline |
Enables or disables additive blending mode.
- Parameters
-
additive | True for additive blending, false for normal blending. |
◆ setBottomLeft()
void OpenGlImage::setBottomLeft |
( |
float | x, |
|
|
float | y ) |
|
inline |
Sets the bottom-left corner position of the image quad.
◆ setBottomRight()
void OpenGlImage::setBottomRight |
( |
float | x, |
|
|
float | y ) |
|
inline |
Sets the bottom-right corner position of the image quad.
◆ setColor()
void OpenGlImage::setColor |
( |
Colour | color | ) |
|
|
inline |
Sets the color tint applied to the image.
- Parameters
-
◆ setImage()
void OpenGlImage::setImage |
( |
Image * | image | ) |
|
|
inline |
Sets the image to render without taking ownership.
- Parameters
-
image | Pointer to an Image, must remain valid during the usage. |
No copy is made. The provided image must remain valid while this object uses it.
◆ setOwnImage()
void OpenGlImage::setOwnImage |
( |
Image & | image | ) |
|
|
inline |
Sets the image from an owned copy.
- Parameters
-
image | The image to copy and use internally. |
A copy of the image is made and stored internally. This is thread-safe.
◆ setPosition()
void OpenGlImage::setPosition |
( |
float | x, |
|
|
float | y, |
|
|
int | index ) |
|
inline |
Sets a specific vertex position by index.
- Parameters
-
x | The x-coordinate in normalized device space. |
y | The y-coordinate in normalized device space. |
index | The starting index in the position vertex array (0, 4, 8, 12). |
◆ setScissor()
void OpenGlImage::setScissor |
( |
bool | scissor | ) |
|
|
inline |
Enables or disables scissor test when drawing the image.
- Parameters
-
scissor | True to enable scissor test, false to disable. |
◆ setTopLeft()
void OpenGlImage::setTopLeft |
( |
float | x, |
|
|
float | y ) |
|
inline |
Sets the top-left corner position of the image quad.
- Parameters
-
x | The x-coordinate in normalized device space. |
y | The y-coordinate in normalized device space. |
◆ setTopRight()
void OpenGlImage::setTopRight |
( |
float | x, |
|
|
float | y ) |
|
inline |
Sets the top-right corner position of the image quad.
◆ setUseAlpha()
void OpenGlImage::setUseAlpha |
( |
bool | use_alpha | ) |
|
|
inline |
Enables or disables alpha blending.
- Parameters
-
use_alpha | True to respect image alpha, false to ignore it. |
◆ unlock()
void OpenGlImage::unlock |
( |
| ) |
|
|
inline |
Unlocks the mutex previously locked with lock().
The documentation for this class was generated from the following files:
- /Users/davidvogel/repos/VitalHelp/src/interface/editor_components/open_gl_image.h
- /Users/davidvogel/repos/VitalHelp/src/interface/editor_components/open_gl_image.cpp