blob: 38a0cac630092ec893d564af02c1bd93f2dad64f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* A complete CPU-rendered window. Build instructions: docs/getting-started.md. */
#include <yasl/app.h>
#include <stdio.h>
static bool failed;
static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_context *frame)
{
(void)ud;
size_t count = (size_t)frame->size.x * frame->size.y;
for (size_t i = 0; i < count; i++)
frame->cpu.pixels[i] = 0xff306090; /* Opaque premultiplied ARGB. */
if (!yasl_frame_present_cpu(frame, NULL, 0)) {
fprintf(stderr, "Could not present the draw target\n");
failed = true;
}
if (failed) yasl_surface_destroy(surface);
}
int main(void)
{
struct yasl_window_spec window = {.title = "Hello YASL", .size = {640, 480}};
struct yasl_app_desc desc = {
.app_id = "org.example.hello",
.window = &window,
.frame = draw,
};
int result = yasl_run(&desc);
if (result) fprintf(stderr, "Could not run the application\n");
return result || failed ? 1 : 0;
}
|