summaryrefslogtreecommitdiff
path: root/examples/game.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 21:23:03 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 21:23:03 +0300
commitdd1775a9927922c14f8679ccbc4d3ca8d5917e20 (patch)
tree3acc442bb4a3470364b74aa82ff67cb84d555c45 /examples/game.c
parentecb81aeea4c0c880b3a60a0dc8418c4bf2a7cf85 (diff)
public api refactor
Diffstat (limited to 'examples/game.c')
-rw-r--r--examples/game.c18
1 files changed, 10 insertions, 8 deletions
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)