Take the tutorial figures out of the games themselves
Both examples gain --screenshot PATH and --screenshot-frame N. The capture sits between the world being drawn and the frame being presented, because SDL_RenderPresent is where the target stops being readable, and it works under the dummy video driver and the software renderer like the rest of the headless path does. `cmake --build build --target docs_game_figures` regenerates docs/images/sidescroller.png and docs/images/jrpg.png by running each game to a chosen frame. Same contract as docs_screenshots: deliberate, never part of a build, because the PNGs are tracked. There is no --check counterpart, and the target says why -- the sidescroller drives its physics from the wall clock, so a byte comparison would fail for reasons that have nothing to do with the documentation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KzBDV2fqgnUAcqCKqKvc71
This commit is contained in:
@@ -807,6 +807,35 @@ add_custom_target(${AKGL_DOCS_SCREENSHOTS_TARGET}
|
||||
# examples/CMakeLists.txt, one game at a time, for the same reason.
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples/CMakeLists.txt")
|
||||
add_subdirectory(examples)
|
||||
|
||||
# The figures at the top of chapters 20 and 21 are frames out of the games
|
||||
# themselves, taken by --screenshot between the world being drawn and the
|
||||
# frame being presented. Same contract as docs_screenshots above: deliberate,
|
||||
# never part of a build, because the PNGs are tracked.
|
||||
#
|
||||
# There is no --check counterpart. docs_screenshots can compare because its
|
||||
# figures are one deterministic frame of drawing calls; a game frame is not.
|
||||
# The sidescroller drives its physics from the wall clock, so which pixel the
|
||||
# player occupies depends on how fast the machine ran, and a byte comparison
|
||||
# would fail for reasons that have nothing to do with the documentation.
|
||||
add_custom_target(docs_game_figures
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
SDL_VIDEODRIVER=dummy SDL_RENDER_DRIVER=software SDL_AUDIODRIVER=dummy
|
||||
$<TARGET_FILE:sidescroller>
|
||||
--assets "${CMAKE_CURRENT_SOURCE_DIR}/docs/tutorials/assets/sidescroller"
|
||||
--autoplay --frames 110
|
||||
--screenshot "${CMAKE_CURRENT_SOURCE_DIR}/docs/images/sidescroller.png"
|
||||
--screenshot-frame 100
|
||||
COMMAND ${CMAKE_COMMAND} -E env
|
||||
SDL_VIDEODRIVER=dummy SDL_RENDER_DRIVER=software SDL_AUDIODRIVER=dummy
|
||||
$<TARGET_FILE:jrpg>
|
||||
--demo --frames 240
|
||||
--screenshot "${CMAKE_CURRENT_SOURCE_DIR}/docs/images/jrpg.png"
|
||||
--screenshot-frame 230
|
||||
DEPENDS sidescroller jrpg
|
||||
COMMENT "Regenerating the tutorial figures in docs/images"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
# Mutation testing copies the repository to scratch space, applies one small
|
||||
|
||||
Reference in New Issue
Block a user