56 void lock() { mutex_.lock(); }
71 owned_image_ = std::make_unique<Image>(image);
84 image_width_ = image->getWidth();
85 image_height_ = image->getHeight();
92 void setColor(Colour color) { color_ = color; }
101 position_vertices_[index] = x;
102 position_vertices_[index + 1] = y;
165 std::unique_ptr<Image> owned_image_;
168 OpenGLTexture texture_;
173 OpenGLShaderProgram* image_shader_;
174 std::unique_ptr<OpenGLShaderProgram::Uniform> image_color_;
175 std::unique_ptr<OpenGLShaderProgram::Attribute> image_position_;
176 std::unique_ptr<OpenGLShaderProgram::Attribute> texture_coordinates_;
178 std::unique_ptr<float[]> position_vertices_;
179 std::unique_ptr<int[]> position_triangles_;
180 GLuint vertex_buffer_;
181 GLuint triangle_buffer_;
183 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
OpenGlImage)
A utility class for rendering a single image using OpenGL.
Definition open_gl_image.h:16
virtual ~OpenGlImage()
Destructor.
Definition open_gl_image.cpp:31
void setPosition(float x, float y, int index)
Sets a specific vertex position by index.
Definition open_gl_image.h:100
void unlock()
Unlocks the mutex previously locked with lock().
Definition open_gl_image.h:61
void setOwnImage(Image &image)
Sets the image from an owned copy.
Definition open_gl_image.h:69
void setAdditive(bool additive)
Enables or disables additive blending mode.
Definition open_gl_image.h:144
void init(OpenGlWrapper &open_gl)
Initializes the OpenGL buffers and shader attributes needed for rendering the image.
Definition open_gl_image.cpp:33
OpenGlImage()
Constructs an OpenGlImage with default settings.
Definition open_gl_image.cpp:12
void setBottomLeft(float x, float y)
Sets the bottom-left corner position of the image quad.
Definition open_gl_image.h:116
int getImageWidth()
Gets the width of the currently set image.
Definition open_gl_image.h:132
void drawImage(OpenGlWrapper &open_gl)
Draws the image to the current OpenGL context.
Definition open_gl_image.cpp:59
void setImage(Image *image)
Sets the image to render without taking ownership.
Definition open_gl_image.h:82
void setScissor(bool scissor)
Enables or disables scissor test when drawing the image.
Definition open_gl_image.h:156
int getImageHeight()
Gets the height of the currently set image.
Definition open_gl_image.h:138
void setUseAlpha(bool use_alpha)
Enables or disables alpha blending.
Definition open_gl_image.h:150
void setBottomRight(float x, float y)
Sets the bottom-right corner position of the image quad.
Definition open_gl_image.h:121
void setTopLeft(float x, float y)
Sets the top-left corner position of the image quad.
Definition open_gl_image.h:111
void destroy(OpenGlWrapper &open_gl)
Releases any OpenGL resources allocated by this object.
Definition open_gl_image.cpp:128
void setTopRight(float x, float y)
Sets the top-right corner position of the image quad.
Definition open_gl_image.h:126
void setColor(Colour color)
Sets the color tint applied to the image.
Definition open_gl_image.h:92
void lock()
Locks the internal mutex for thread-safe operations.
Definition open_gl_image.h:56
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174