fix(effects): capture the acrylic backdrop at framebuffer size on HiDPI
The acrylic effect blits its backdrop from the default framebuffer using the logical viewport size as the source rectangle. On a HiDPI display the framebuffer is larger than the logical size, so the blur sampled only the lower-left corner of the screen and the glass showed the wrong region stretched across each panel. - The capture blit source now uses the real framebuffer pixel size (logical size times ImGui's DisplayFramebufferScale, truncated the same way the GL backend does), while the capture and blur targets stay at logical size. The framebuffer size is tracked separately from the viewport size so quality or buffer-lifetime resets cannot lose it, and moving the window between a Retina and a non-Retina display redoes the capture. DX11 is unaffected; its scale is one. - The debug screenshot sweep captures at framebuffer size too, so HiDPI captures are no longer cropped. Tests: the framebuffer-extent helper matches the GL backend's truncation and falls back to the logical size when the scale is unknown. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -125,6 +125,8 @@ namespace ImGuiAcrylic {
|
||||
static bool s_initialized = false;
|
||||
static int s_viewportWidth = 0;
|
||||
static int s_viewportHeight = 0;
|
||||
static int s_fbWidth = 0;
|
||||
static int s_fbHeight = 0;
|
||||
static bool s_backgroundCaptured = false;
|
||||
|
||||
// Track window state for acrylic rendering
|
||||
@@ -179,11 +181,24 @@ bool IsAvailable()
|
||||
// ============================================================================
|
||||
|
||||
void BeginFrame(int width, int height)
|
||||
{
|
||||
BeginFrame(width, height, width, height);
|
||||
}
|
||||
|
||||
void BeginFrame(int width, int height, int fbWidth, int fbHeight)
|
||||
{
|
||||
if (!s_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Moving the window between a Retina and a non-Retina display changes the framebuffer size while the
|
||||
// logical size stays put: the capture must be redone against the new pixel grid.
|
||||
if (fbWidth != s_fbWidth || fbHeight != s_fbHeight) {
|
||||
s_fbWidth = fbWidth;
|
||||
s_fbHeight = fbHeight;
|
||||
getAcrylicMaterial().setFramebufferSize(fbWidth, fbHeight);
|
||||
}
|
||||
|
||||
// Update viewport dimensions if changed
|
||||
if (width != s_viewportWidth || height != s_viewportHeight) {
|
||||
s_viewportWidth = width;
|
||||
@@ -670,6 +685,7 @@ void Shutdown() {}
|
||||
bool IsAvailable() { return false; }
|
||||
|
||||
void BeginFrame(int, int) {}
|
||||
void BeginFrame(int, int, int, int) {}
|
||||
void CaptureBackground() {}
|
||||
void InvalidateCapture() {}
|
||||
void ReleaseIdleBuffers() {}
|
||||
|
||||
Reference in New Issue
Block a user