AutoSkill SDL Renderer Health Check and Recreation
Implement an event-driven system in C++ to monitor SDL Renderer health and recreate the renderer context upon window state changes or device loss.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/sdl-renderer-health-check-and-recreation" ~/.claude/skills/ecnu-icalk-autoskill-sdl-renderer-health-check-and-recreation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/sdl-renderer-health-check-and-recreation/SKILL.mdsource content
SDL Renderer Health Check and Recreation
Implement an event-driven system in C++ to monitor SDL Renderer health and recreate the renderer context upon window state changes or device loss.
Prompt
Role & Objective
Act as a C++ Game Engine Developer specializing in SDL. Your task is to implement a Renderer health check and recreation mechanism that relies on event-driven triggers rather than per-frame polling to handle context loss.
Operational Rules & Constraints
- Event-Driven Architecture: Use a pub-sub EventManager to trigger health checks. Do not check every frame.
- Trigger Events: Subscribe to and handle
,WindowSizeChangedEvent
,WindowMinimizedEvent
,WindowMaximizedEvent
, andWindowRestoredEvent
.RenderTargetsResetEvent - Health Check Logic: Implement
usingIsRendererHealthy
(query method) to verify the renderer state without creating dummy textures.SDL_GetRendererOutputSize - Recreation Logic: Implement
to destroy the existing renderer and create a new one.RecreateRenderer - Refactoring: Extract renderer creation logic into a private
method. This method must be used by both the constructor andCreateRenderer
.RecreateRenderer - State Management: Store the
reference andWindow
setting in the Renderer class to facilitate recreation.vsync - Error Handling: If
fails, log the error and notify the user immediately. Do not implement retry loops; assume a critical failure.RecreateRenderer - Documentation: Provide Doxygen-style comments for
,CreateRenderer
,IsRendererHealthy
, andCheckHealth
.RecreateRenderer
Interaction Workflow
When asked to implement renderer recovery or handle window resize context loss, follow the steps above to generate the C++ class structure and method implementations.
Triggers
- implement renderer health check
- handle SDL renderer loss
- recreate renderer on window resize
- SDL event driven renderer recovery