4a88c8cc06
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.)
50 lines
1.4 KiB
CMake
50 lines
1.4 KiB
CMake
# ==============================================================================
|
|
# Find stb
|
|
# ==============================================================================
|
|
# This module fetches the stb single-file public domain libraries
|
|
# (stb_image_write.h for PNG writing, etc.).
|
|
#
|
|
# Targets provided:
|
|
# stb::stb - Interface library (add #define STB_IMAGE_WRITE_IMPLEMENTATION
|
|
# in exactly one .cpp before including "stb_image_write.h")
|
|
#
|
|
# Variables set:
|
|
# stb_FOUND - TRUE if stb is available
|
|
# stb_INCLUDE_DIR - Include directories for stb
|
|
# stb_VERSION - Version of stb (commit)
|
|
# ==============================================================================
|
|
|
|
if (DEFINED _FINDSTB_INCLUDED)
|
|
return()
|
|
endif()
|
|
set(_FINDSTB_INCLUDED TRUE)
|
|
|
|
# Pin to a recent stable commit
|
|
set(STB_VERSION "master")
|
|
|
|
message(STATUS "Fetching stb ${STB_VERSION}")
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
stb
|
|
GIT_REPOSITORY https://github.com/nothings/stb.git
|
|
GIT_TAG ${STB_VERSION}
|
|
)
|
|
|
|
FetchContent_MakeAvailable(stb)
|
|
|
|
add_library(stb INTERFACE)
|
|
target_include_directories(stb INTERFACE "${stb_SOURCE_DIR}")
|
|
|
|
add_library(stb::stb ALIAS stb)
|
|
|
|
set(stb_FOUND TRUE)
|
|
set(stb_INCLUDE_DIR "${stb_SOURCE_DIR}")
|
|
set(stb_VERSION "${STB_VERSION}")
|
|
|
|
# Mark as SYSTEM includes
|
|
set_target_properties(stb PROPERTIES
|
|
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${stb_SOURCE_DIR}"
|
|
)
|