1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
Commit graph

396 commits

Author SHA1 Message Date
attila
a9779b4546 OpenGL: Fix missing buffered image after context detach
Prior to this commit a Component with setBufferedToImage (true) could
have its image buffer deleted when an OpenGL context was detached. This
meant that this Component continued to be rendered without buffering
even though it was previously requested that it use a buffer.
2025-11-19 14:07:59 +01:00
reuk
e465b71188
Docs: Update language to be more diplomatic 2025-11-18 15:47:42 +00:00
reuk
83e5264c86
Formatting: Remove double-dots from comments and other strings 2025-11-18 15:47:42 +00:00
reuk
a3f81eb2fb
OpenGL: Correctly restore blend mode when nested context goes out-of-scope
Fixes an issue where primitives such as text could end up with sharp
edges when creating temporary contexts:

    void paint (Graphics& g)
    {
        g.fillAll (Colours::white);
        const auto preferredType = g.getInternalContext().getPreferredImageTypeForTemporaryImages();
        Image img (Image::ARGB, getWidth(), getHeight(), false, *preferredType);
        {
            Graphics g2 (img);
        }
        g.setColour (Colours::black);
        g.setFont (32);
        g.drawText ("test", getLocalBounds(), Justification::centred);
    }
2025-11-14 13:36:03 +00:00
attila
cb34975457 Fix crash after OpenGL::detach in the presence of buffered child components
The crash fixed by this commit could be triggered by attaching an OpenGL
context to a component, calling setBufferedToImage (true) on one of its
child components, and then detaching the OpenGL context from the parent.

Since 4ba01a80a0 we are creating images
with the current rendering context's native image type, so the above
scenario would leave an image buffer that references the detached
context.
2025-10-28 15:33:13 +01:00
reuk
5eba9a6434
OpenGL: Clear bound texture after rendering transparency layer
A change introduced in 00836d1e94 meant
that GL renderers could sometimes assert in
StateHelpers::ActiveTextures::bindTexture() when ending a transparency
layer.

Specifically, the issue was provoked by adding the ScopedTextureBinding
in the constructor of OpenGLFrameBuffer. This reset the bound texture
after creating a new transparency layer.

I think the previous implementation worked by accident, not by design.
It so happens that when rendering multiple transparency layers within
the same frame (i.e. calling begin/end several times in that order,
*not* nesting the calls), the same texture ID will generally get reused.

From the graphics context's (GC's) perspective, we create a texture with
ID "2", then call bindTexture() to bind it, and the GC remembers that
this ID is bound. We draw the frame, and the texture gets destroyed. The
call to glDeleteTextures() will cause the default texture, "0", to be
bound if the texture being destroyed is bound at the point of
destruction. So, after the texture is destroyed, the GC's stored binding
no longer reflects reality, since texture "0" is now bound.

The next time we create a texture, that texture also gets created with
ID "2". Previously, we would leave this texture bound after
construction, but now we re-bind the previously-bound texture, "0". This
causes the assertion in bindTexture() to fire when we next attempt to
bind texture "2", since the actual bound texture is "0".

The solution added in this patch will bind texture "0" when the
transparency layer image is destroyed, in order to keep the GC's view of
the GL context consistent with the real state.
2025-08-14 14:13:09 +01:00
reuk
2712f63628
Graphics: Use unique_ptr instead of raw pointers in RenderingHelpers 2025-08-14 14:13:09 +01:00
Anthony Nicholls
36d07a6ce3 Docs: Replace doxygen preprocessor conditionals with @cond and @endconds 2025-07-21 18:11:43 +02:00
reuk
f5a6c510c0
OpenGLFrameBuffer: Add a row order parameter for reading and writing pixels
This also fixes a bug where saving and restoring the framebuffer state
could unexpectedly apply a vertical flip to the buffer content.
2025-07-10 16:16:12 +01:00
reuk
c77e8a73cc
OpenGLContext (Android): Avoid potentially enqueuing work after context has already stopped 2025-07-10 14:59:18 +01:00
reuk
c134ca5d76
OpenGL (Android): Use a simpler approach to register SurfaceHolder callbacks 2025-07-09 11:30:28 +01:00
reuk
90b89e92b2
OpenGL: Respect result of getDesktopScaleFactor() for component hosting OpenGLContext 2025-07-09 11:28:03 +01:00
reuk
ac65cc5434
OpenGLFrameBuffer: Add early-exit in ~TransientState 2025-07-09 11:27:48 +01:00
reuk
1900dd4e4a
OpenGLFrameBuffer: Use ScopeGuard to unbind framebuffer 2025-07-09 11:27:34 +01:00
reuk
c2d52a5499
OpenGLFrameBuffer: Automatically save/restore content when the context is paused/resumed
This addresses an issue where OpenGL-backed image content could get lost
when putting and Android app into an inactive state. This happens
because the GL context gets destroyed, freeing all associated resources.

The workaround introduced here will listen for OpenGL state-change
events, and attempt to save and restore framebuffer content into main
memory, so that the content can be restored once the app is reactivated.
2025-07-09 11:24:43 +01:00
reuk
fc2caf0a4d
OpenGLFrameBuffer: Refactor to move stored OpenGLContext out of TransientState 2025-07-09 11:24:43 +01:00
reuk
29af89c72a
OpenGLFrameBuffer: Refactor pimpl to represent mutually exclusive states with std::variant 2025-07-09 11:24:43 +01:00
reuk
80c4268a5d
OpenGLFrameBuffer: Refactor SavedState in implementation to allow copying and moving 2025-07-09 11:24:43 +01:00
reuk
3991089409
OpenGLFrameBuffer: Refactor pimpl to completely hide SavedState 2025-07-09 11:24:43 +01:00
reuk
0da5827f72
OpenGLFrameBuffer: Remove unused members in implementation 2025-07-09 11:24:43 +01:00
reuk
416da229f2
OpenGLFrameBuffer: Remove outdated info from docs 2025-07-09 11:24:43 +01:00
Anthony Nicholls
0181f52c48 OpenGL: Document blend parameter for copyTexture method 2025-06-10 16:13:33 +01:00
reuk
1fcdd29bf9
OpenGL: Return image BitmapData in JUCE order rather than native order
JUCE convention is that BitmapData holds the lines of the image ordered
from top to bottom, but OpenGL orders lines in the reverse direction.
By returning a negative line stride, we can iterate lines in the
expected order as long as we always increment the current pointer
position by the line stride after processing each line.
2025-05-19 13:32:52 +01:00
reuk
fb4159c436
OpenGL: Fix state restoration when drawing into a temporary nested context
Fixes a regression introduced in
bd26d79b17

The issue was observed in the DemoRunner when enabling the OpenGL
renderer and then switching to the LookAndFeel V1.

The cause of the problem was the creation of a secondary OpenGL-backed
Graphics instance in the DropShadowEffect. This temporary context could
modify the OpenGL context state without restoring the state
appropriately on destruction. As a result, when the outer long-lived
OpenGL context resumed drawing, properties such as the viewport, bound
shader, shader uniform values, and bound framebuffer could all be
incorrect.
2025-05-19 13:30:27 +01:00
reuk
00836d1e94
OpenGLFrameBuffer: Keep track of the previously-bound framebuffer 2025-05-19 13:30:27 +01:00
Oli
250abe9cf4 LowLevelGraphicsContext: Add preferred image type for temporary images
Co-authored-by: Matt Gonzalez <matt@echoaudio.com>
2025-04-24 13:58:23 +01:00
reuk
2fbb72d960
OpenGLFrameBufferImage: Refactor and simplify BitmapData releaser 2025-01-23 12:21:33 +00:00
reuk
01821b5811
OpenGLFrameBuffer: Fix writePixels implementation, which previously blended instead of replacing existing pixels 2025-01-23 12:20:27 +00:00
reuk
21357f26b5 OpenGLTexture: Respect pixelStride when loading Image to texture 2024-12-13 14:42:26 +00:00
reuk
dcca72484f Image: Update return type of getPixelData to avoid dangling pointers 2024-12-13 14:42:26 +00:00
reuk
93640b63ff
Compatibility: Add new macros for straightforward checking of minimum deployment target
This also fixes a bug introduced in f7c7225f5c
where the condition guarding the definition of traitCollectionDidChange
was incorrect. This function is never required if the deployment target
is at least 17.0.
2024-11-05 13:28:10 +00:00
attila
d9a3efd3cb ComponentPeer::VBlankListener: Add timestamp parameter to the vblank callback 2024-10-25 15:44:34 +02:00
reuk
10680f9bf7
OpenGL: Detach OpenGL context after initialisation 2024-10-24 20:43:10 +01:00
reuk
e2e3d949c7
OpenGL: Use C++ thread_local instead of JUCE ThreadLocal 2024-10-24 20:43:10 +01:00
reuk
90f37e27ea Windows: Fix DLL build
There were a few "ambiguous operator new/delete" errors that were due to
inheriting from a private base class that used the leak detector. These
errors are resolved by adding the leak detector to the derived classes.

JUCE_API was missing from a few useful types, notably the ARA hosting
types.
2024-10-22 13:24:46 +01:00
reuk
8754d87900 Windows: Fix build warnings when JUCE_DISABLE_ASSERTIONS is set 2024-09-13 13:57:10 +01:00
Anthony Nicholls
cddd43891d OpenGL: Stop calling disableScreenUpdatesUntilFlush on macOS 2024-08-14 15:35:50 +00:00
reuk
4f2c287f9b
Font: Deprecate old Font constructors 2024-04-18 14:16:00 +01:00
reuk
72819437e7
RenderingHelpers: Move drawGlyph to a common location 2024-04-18 14:15:59 +01:00
reuk
bc654f8007
RenderingHelpers: Reduce templating of GlyphCache 2024-04-18 14:15:58 +01:00
Tom Poole
94d98a2b10 Update licensing information 2024-04-16 11:39:35 +01:00
reuk
047448fbce
Warnings: Add missing overrides 2024-01-30 11:37:30 +00:00
reuk
76b9b28658
OpenGL: Update compatibility headers
This also adds missing KHRONOS_APIENTRY qualifications to the debug
callback type, which fixes potential crashes when running debug Win32
builds.
2024-01-16 15:34:10 +00:00
attila
b0167985b4 OpenGLContext: Make getRenderingScale() sensitive to Component transforms
This also reverts commit c456f67c3f.
2024-01-03 14:02:42 +01:00
attila
c456f67c3f Windows: Make OpenGLContext::getRenderingScale() insensitive to Component transforms
This makes it consistent between Windows and MacOS. This is restoring
the behaviour prior to 7e404118b5.
2023-11-02 09:16:08 +00:00
reuk
8a9cb49c96
OpenGLContext: Add missing explicit keywords 2023-10-11 14:24:17 +01:00
reuk
9bf785f221
OpenGLContext: Re-bind previous program after copying texture 2023-10-11 14:24:17 +01:00
Tom Poole
6bf9bb9a2e Add final specifiers in implementation files 2023-10-10 16:12:38 +01:00
Anthony Nicholls
158220ddfa Formatting: Use nested namespace definitions 2023-10-09 14:49:18 +01:00
Tom Poole
4153d59e39 Formatting 2023-10-02 15:42:20 +01:00