From dd1775a9927922c14f8679ccbc4d3ca8d5917e20 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 21:23:03 +0300 Subject: public api refactor --- examples/game.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'examples/game.c') diff --git a/examples/game.c b/examples/game.c index 4517519..33c2f6e 100644 --- a/examples/game.c +++ b/examples/game.c @@ -147,13 +147,14 @@ static enum yasl_app_result on_init(void *ud, struct yasl_display *d) struct yasl_window_spec spec = { .title = "YASL 3D Game Loop (Approach A)", - .size = {800, 600}, + .size_logical = {800, 600}, }; game->surface = yasl_surface_create_toplevel(d, &spec); - if (!game->surface) return YASL_APP_QUIT; + if (!game->surface) return YASL_APP_ERROR; /* Drive continuous 60/144Hz ticks */ - yasl_surface_set_pacing(game->surface, YASL_PACING_CONTINUOUS); + if (!yasl_surface_set_pacing(game->surface, YASL_PACING_CONTINUOUS)) + return YASL_APP_ERROR; game->cam_z = 3.5f; game->relative_mouse = false; @@ -237,13 +238,13 @@ static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) return YASL_APP_CONTINUE; } -static void on_frame(void *ud, struct yasl_surface *s, struct yasl_frame_context *ctx) +static void on_frame(void *ud, struct yasl_surface *s, struct yasl_frame *ctx) { (void)s; struct game_state *game = ud; - int w = ctx->size.x; - int h = ctx->size.y; - uint32_t *pix = ctx->cpu.pixels; + int w = ctx->target.size.x; + int h = ctx->target.size.y; + uint32_t *pix = ctx->target.pixels; if (!pix || w <= 0 || h <= 0) return; /* Update game simulation */ @@ -339,7 +340,8 @@ static void on_frame(void *ud, struct yasl_surface *s, struct yasl_frame_context draw_number(pix, w, h, 16 * scale, 16 * scale, (int)game->current_fps, 0xff00ff00, scale); /* Submit frame */ - yasl_frame_present_cpu(ctx, NULL, 0); + if (!yasl_frame_present(ctx, NULL, 0)) + yasl_app_exit(yasl_surface_display(s), YASL_APP_ERROR); } int main(void) -- cgit v1.2.3