diff options
Diffstat (limited to 'src/draw.h')
| -rw-r--r-- | src/draw.h | 55 |
1 files changed, 55 insertions, 0 deletions
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 |
