Skip to content

Commit

Permalink
Add FinalAppWindowScreenshotFramebufferScale
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Oct 16, 2024
1 parent f3fdec8 commit f388190
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hello_imgui/hello_imgui_screenshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ namespace HelloImGui
ImageBuffer AppWindowScreenshotRgbBuffer();

ImageBuffer FinalAppWindowScreenshotRgbBuffer();
float FinalAppWindowScreenshotFramebufferScale();
}
10 changes: 10 additions & 0 deletions src/hello_imgui/impl/hello_imgui_screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ namespace HelloImGui
}

ImageBuffer gFinalAppWindowScreenshotRgbBuffer;
float gFinalAppWindowScreenshotFramebufferScale = 1.0f;

void setFinalAppWindowScreenshotRgbBuffer(const ImageBuffer& b)
{
gFinalAppWindowScreenshotRgbBuffer = b;
}
void setFinalAppWindowScreenshotFramebufferScale(float scale)
{
gFinalAppWindowScreenshotFramebufferScale = scale;
}

ImageBuffer FinalAppWindowScreenshotRgbBuffer()
{
return gFinalAppWindowScreenshotRgbBuffer;
}

float FinalAppWindowScreenshotFramebufferScale()
{
return gFinalAppWindowScreenshotFramebufferScale;
}

}
3 changes: 3 additions & 0 deletions src/hello_imgui/internal/backend_impls/abstract_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ namespace HelloImGui
{
// Encapsulated inside hello_imgui_screenshot.cpp
void setFinalAppWindowScreenshotRgbBuffer(const ImageBuffer& b);
void setFinalAppWindowScreenshotFramebufferScale(float scale);

// Encapsulated inside hello_imgui_font.cpp
bool _reloadAllDpiResponsiveFonts();
Expand Down Expand Up @@ -1436,6 +1437,8 @@ void AbstractRunner::TearDown(bool gotException)
{
ImageBuffer b = ScreenshotRgb();
setFinalAppWindowScreenshotRgbBuffer(b);
float scale = (ImGui::GetIO().DisplayFramebufferScale.x + ImGui::GetIO().DisplayFramebufferScale.y) / 2.f;
setFinalAppWindowScreenshotFramebufferScale(scale);
}
if (params.appWindowParams.restorePreviousGeometry)
HelloImGuiIniSettings::SaveLastRunWindowBounds(IniSettingsLocation(params),
Expand Down

0 comments on commit f388190

Please sign in to comment.