74 void lock() { mutex_.lock(); }
87 owned_image_ = std::make_unique<Image>(image);
98 image_width_ = image->getWidth();
99 image_height_ = image->getHeight();
122 inline void setQuad(
int i,
float x,
float y,
float w,
float h) {
125 data_[index + 1] = y;
126 data_[index + 4] = x;
127 data_[index + 5] = y + h;
128 data_[index + 8] = x + w;
129 data_[index + 9] = y + h;
130 data_[index + 12] = x + w;
131 data_[index + 13] = y;
151 void setAdditive(
bool additive) { additive_blending_ = additive; }
158 std::unique_ptr<Image> owned_image_;
160 OpenGLTexture texture_;
166 bool additive_blending_;
168 std::unique_ptr<float[]> data_;
169 std::unique_ptr<int[]> indices_;
171 OpenGLShaderProgram* image_shader_;
172 std::unique_ptr<OpenGLShaderProgram::Uniform> color_uniform_;
173 std::unique_ptr<OpenGLShaderProgram::Attribute> position_;
174 std::unique_ptr<OpenGLShaderProgram::Attribute> texture_coordinates_;
176 GLuint vertex_buffer_;
177 GLuint indices_buffer_;
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
virtual void resized() override
Called when the component is resized.
Definition open_gl_component.cpp:121
A component for rendering multiple image quads using OpenGL.
Definition open_gl_multi_image.h:16
void setOwnImage(Image &image)
Sets an owned image by making a copy and uses it for rendering.
Definition open_gl_multi_image.h:85
int getImageWidth()
Gets the width of the current image.
Definition open_gl_multi_image.h:139
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the set of image quads using OpenGL.
Definition open_gl_multi_image.cpp:79
static constexpr int kNumFloatsPerQuad
Number of floats per quad (4 vertices * 4 floats each).
Definition open_gl_multi_image.h:23
static constexpr int kNumIndicesPerQuad
Number of indices per quad (2 triangles * 3 indices each).
Definition open_gl_multi_image.h:25
void setNumQuads(int num_quads)
Sets the number of quads currently drawn.
Definition open_gl_multi_image.h:106
void setQuad(int i, float x, float y, float w, float h)
Sets the position and size of a quad.
Definition open_gl_multi_image.h:122
virtual void init(OpenGlWrapper &open_gl) override
Initializes OpenGL buffers and shader attributes for rendering.
Definition open_gl_multi_image.cpp:44
virtual ~OpenGlMultiImage()
Destructor. Frees any allocated OpenGL resources.
Definition open_gl_multi_image.cpp:42
void setColor(Colour color)
Sets the color tint applied to all image quads.
Definition open_gl_multi_image.h:112
void setAdditive(bool additive)
Enables or disables additive blending for the image quads.
Definition open_gl_multi_image.h:151
void lock()
Locks the internal mutex for thread-safe image updates.
Definition open_gl_multi_image.h:74
virtual void destroy(OpenGlWrapper &open_gl) override
Destroys the OpenGL resources used by this class.
Definition open_gl_multi_image.cpp:64
void unlock()
Unlocks the mutex locked by lock().
Definition open_gl_multi_image.h:79
void resized() override
Called when the component is resized, marks vertex data as dirty to recalculate.
Definition open_gl_multi_image.h:66
static constexpr int kNumVertices
Number of vertices per quad (2 triangles forming a rectangle).
Definition open_gl_multi_image.h:19
OpenGlMultiImage(int max_images)
Constructs an OpenGlMultiImage with a given maximum number of quads.
Definition open_gl_multi_image.cpp:6
static constexpr int kNumFloatsPerVertex
Number of floats per vertex (x, y, u, v).
Definition open_gl_multi_image.h:21
void paintBackground(Graphics &g) override
Override to suppress default background painting.
Definition open_gl_multi_image.h:61
int getImageHeight()
Gets the height of the current image.
Definition open_gl_multi_image.h:145
void setImage(Image *image)
Sets the image to render without ownership.
Definition open_gl_multi_image.h:96
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174