4 active_(true), static_image_(false),
5 paint_entire_component_(true) {
13 setInterceptsMouseClicks(
false,
false);
22 int pixel_scale = Desktop::getInstance().getDisplays().findDisplayForPoint(getScreenPosition()).scale;
23 int width = component->getWidth() * pixel_scale;
24 int height = component->getHeight() * pixel_scale;
25 if (width <= 0 || height <= 0)
35 draw_image_ = std::make_unique<Image>(Image::ARGB, width, height,
false);
37 draw_image_->clear(Rectangle<int>(0, 0, width, height));
39 g.addTransform(AffineTransform::scale(pixel_scale));
46 float width_ratio = gl_width / width;
47 float height_ratio = gl_height / height;
49 float right = -1.0f + 2.0f * width_ratio;
50 float bottom = 1.0f - 2.0f * height_ratio;
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
static bool setViewPort(Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
Sets the OpenGL viewport to match a specified rectangle within a component.
Definition open_gl_component.cpp:42
OpenGlImage image_
The OpenGlImage used to upload and draw the cached image.
Definition open_gl_image_component.h:139
bool static_image_
Whether the image is static or updated on events.
Definition open_gl_image_component.h:136
virtual void init(OpenGlWrapper &open_gl) override
Initializes any OpenGL resources for rendering this component.
Definition open_gl_image_component.cpp:57
std::unique_ptr< Image > draw_image_
The cached image that stores the drawn component.
Definition open_gl_image_component.h:138
virtual void paintToImage(Graphics &g)
Renders the associated component (or itself) into the provided Graphics context.
Definition open_gl_image_component.h:46
virtual void destroy(OpenGlWrapper &open_gl) override
Destroys OpenGL-related resources used by this component.
Definition open_gl_image_component.cpp:69
Component * component_
The component being drawn into the image (if any).
Definition open_gl_image_component.h:134
OpenGlImageComponent(String name="")
Constructs an OpenGlImageComponent.
Definition open_gl_image_component.cpp:3
virtual void redrawImage(bool force)
Redraws the image if necessary, creating or updating the internal Image.
Definition open_gl_image_component.cpp:16
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the image using OpenGL.
Definition open_gl_image_component.cpp:61
bool active_
Whether this component is active and should render.
Definition open_gl_image_component.h:135
void unlock()
Unlocks the mutex previously locked with lock().
Definition open_gl_image.h:61
void init(OpenGlWrapper &open_gl)
Initializes the OpenGL buffers and shader attributes needed for rendering the image.
Definition open_gl_image.cpp:33
void setBottomLeft(float x, float y)
Sets the bottom-left corner position of the image quad.
Definition open_gl_image.h:116
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 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
force_inline int nextPowerOfTwo(mono_float value)
Finds the next power of two greater than or equal to a float value.
Definition utils.h:370
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174