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:
2026-05-05 23:48:05 +02:00
parent c3860cc1d3
commit 4a88c8cc06
5 changed files with 94 additions and 76 deletions
+2 -1
View File
@@ -17,6 +17,7 @@ find_package(glfw3 REQUIRED)
find_package(glad REQUIRED)
find_package(asio REQUIRED)
find_package(glm REQUIRED)
find_package(stb REQUIRED)
# OpenGL abstraction library
add_library(cbt_opengl STATIC
@@ -32,7 +33,7 @@ target_include_directories(cbt_opengl PRIVATE ".")
target_compile_features(cbt_opengl PRIVATE cxx_std_23)
target_compile_options(cbt_opengl PRIVATE ${BASE_OPTIONS})
target_compile_definitions(cbt_opengl PRIVATE ${BASE_DEFINITIONS})
target_link_libraries(cbt_opengl PUBLIC fmt::fmt glfw::glfw glad::glad)
target_link_libraries(cbt_opengl PUBLIC fmt::fmt glfw::glfw glad::glad stb::stb)
# Scene base library
add_library(cbt_scene STATIC