From e5af28536bfb0f4c9131df56d2009ba5196f5e3a Mon Sep 17 00:00:00 2001 From: Lizzy Fleckenstein Date: Sun, 12 Apr 2026 20:57:06 +0200 Subject: init --- src/draw.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/draw.h (limited to 'src/draw.h') diff --git a/src/draw.h b/src/draw.h new file mode 100644 index 0000000..1282563 --- /dev/null +++ b/src/draw.h @@ -0,0 +1,55 @@ +#ifndef ANIMTOOL_DRAW_H_ +#define ANIMTOOL_DRAW_H_ + +#include "util/container.h" + +typedef void *rgba_data; +typedef uint64_t texture_id; +typedef uint64_t mesh_id; + +#define PRItexture_id PRIu64 +#define PRImesh_id PRIu64 + +enum texture_type +{ + TEXTURE_2D, + TEXTURE_CUBEMAP, +}; + +struct draw_vertex +{ + float pos[3]; + float tex[2]; + // float normal[3]; +}; + +struct draw_surface +{ + option(texture_id) texture; + float color[3]; +}; + +struct draw_call +{ + mesh_id mesh; + struct draw_surface surface; + float model[4][4]; +}; + +struct draw_frame +{ + option(struct draw_surface) bg; + array(struct draw_call) calls; + float view_proj[4][4]; +}; + +struct draw_backend +{ + void (*init)(unsigned int size[2]); + bool (*create_mesh)(size_t n_verts, const struct draw_vertex verts[n_verts], mesh_id *id); + bool (*create_texture)(enum texture_type type, unsigned int size[2], const rgba_data faces[], texture_id *id); + void (*draw_frame)(struct draw_frame *frame, rgba_data out_data); + void (*cleanup)(); +}; + +#endif -- cgit v1.2.3