42c14fae59
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
23 lines
674 B
C++
23 lines
674 B
C++
#pragma once
|
|
|
|
// game_loop — fixed-timestep game loop (Glenn Fiedler) for SDL3 + WASM.
|
|
// Issue 0072b. Decouples physics/sim (fixed dt) from rendering (interp).
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
namespace fn::game {
|
|
|
|
struct LoopCfg {
|
|
float fixed_dt = 1.0f / 60.0f;
|
|
int max_steps_per_frame = 5;
|
|
void (*on_fixed_update)(void* user, float dt) = nullptr;
|
|
void (*on_render)(void* user, float interp) = nullptr;
|
|
bool (*should_quit)(void* user) = nullptr; // optional poll
|
|
void* user = nullptr;
|
|
};
|
|
|
|
// Blocking on desktop. On WASM uses emscripten_set_main_loop and returns immediately.
|
|
void loop_run(SDL_Window* win, const LoopCfg& cfg);
|
|
|
|
} // namespace fn::game
|