From 98f0d51157fa2a2b8ccaae54ed4850a88d223d01 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 15:05:06 +0300 Subject: Simplify surface state, examples, and library installation --- README.md | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 5f0d4a6..358ee7c 100644 --- a/README.md +++ b/README.md @@ -47,28 +47,27 @@ one with `-Dwayland=enabled` or `-Dx11=enabled`; omit one with `disabled`. Runti selection chooses the native session and allows fallback, or you can request an explicit backend with `yasl_display_spec.backend`. -Include `` for the core. The complete [hello.c](examples/hello.c) -handles creation failures, drawing, dispatch, input draining, and cleanup. -Its drawing callback fills every pixel before presenting: +Include `` and pass application callbacks to `yasl_run()`. +The complete [hello.c](examples/hello.c) creates its window in `init`, handles +close requests in `event`, and fills every pixel in its frame callback: ```c -static void draw(struct yasl_surface *surface, struct yasl_frame *frame, void *ud) +static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_context *frame) { (void)ud; - size_t count = (size_t)frame->target.size.x * frame->target.size.y; + size_t count = (size_t)frame->size.x * frame->size.y; for (size_t i = 0; i < count; i++) - frame->target.pixels[i] = 0xff306090; - struct yasl_damage_list damage = {.n = -1}; - if (!yasl_surface_present(surface, &frame->target, &damage)) { - /* Arrange application error handling after returning. */ - } + frame->cpu.pixels[i] = 0xff306090; + if (!yasl_frame_present_cpu(frame, NULL, 0)) + yasl_surface_destroy(surface); } ``` Toplevel creation sizes are logical pixels; drawing and input use device pixels. -Targets are borrowed for one draw callback. Keep durable content in application -memory, dispatch events, drain input queues, then flush scheduled drawing. These -rules are explained with examples in the application guide. +Targets are borrowed for one frame callback. Keep durable content in application +memory; the runner handles dispatch, input polling, pacing, and cleanup. +Applications managing their own loop can use `` directly. Both +workflows are explained in the application guide. ## License -- cgit v1.2.3