feat: add stb dependency and window::screenshot()
Added deps/Findstb.cmake (fetches stb via FetchContent, provides stb::stb interface target). Linked to cbt_opengl. Implemented window::screenshot() using glReadPixels + vertical flip + stb_image_write to save RGBA PNG. Press S in the app to capture current frame (saved as screenshot.png). Updated help text. (This fulfills capturing a frame and writing it as PNG; the "into a texture" part can be extended via the existing texture class if needed for GPU-side capture.)
This commit is contained in:
@@ -22,6 +22,7 @@ auto main(int argc, char const* argv[]) -> int {
|
||||
if (arg == "--help" || arg == "-h") {
|
||||
fmt::print("Usage: {} [--duration <seconds>] [--help|-h]\n", argv[0]);
|
||||
fmt::print(" --duration <seconds> Auto-terminate after N seconds (for testing/CI)\n");
|
||||
fmt::print(" S key Take screenshot (saved as screenshot.png)\n");
|
||||
return 0;
|
||||
}
|
||||
if (arg == "--duration" && i + 1 < argc) {
|
||||
@@ -80,6 +81,9 @@ auto main(int argc, char const* argv[]) -> int {
|
||||
if (glfwGetKey(win.raw(), GLFW_KEY_Q) == GLFW_PRESS) {
|
||||
win.stop();
|
||||
}
|
||||
if (glfwGetKey(win.raw(), GLFW_KEY_S) == GLFW_PRESS) {
|
||||
win.screenshot();
|
||||
}
|
||||
|
||||
auto now = std::chrono::steady_clock::now();
|
||||
auto dt = std::chrono::duration<float>(now - prev).count();
|
||||
|
||||
Reference in New Issue
Block a user