diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-22 23:26:21 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-22 23:26:21 +0100 |
commit | 8ed1362368dc064fa35bf879c1f905165b990de8 (patch) | |
tree | f8369b0332b760d5c5b20a8b919be155c5b9464c /stage3/cheese3d.h | |
parent | 13293ec3238b62c66d323b82e595e860e193b6ed (diff) | |
download | cuddles-8ed1362368dc064fa35bf879c1f905165b990de8.tar.xz |
add rotating cheese
This adds the Cheese3D graphics api and makes the cheese command display a cheese rotating in 3d as a demo
Diffstat (limited to 'stage3/cheese3d.h')
-rw-r--r-- | stage3/cheese3d.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/stage3/cheese3d.h b/stage3/cheese3d.h new file mode 100644 index 0000000..f93872f --- /dev/null +++ b/stage3/cheese3d.h @@ -0,0 +1,37 @@ +#ifndef CHEESE3D_H +#define CHEESE3D_H + +// Cheese3D is the cuddlesOS 3d graphics API + +#include "def.h" + +typedef struct { + float pos[3]; + float tex[2]; +} vertex; + +typedef struct { + u32 w, h; + u32 *data; +} texture; + +typedef struct { + u32 width; + u32 height; + u32 pitch; + u32 bgcolor; + float *depth_buffer; + void *color_buffer; +} cheese3d_ctx; + +#define VERT(x, y, z, s, t) { { x, y, z }, { s, t } } // this exists to work with the QUAD macro +#define QUAD(a, b, c, d) a, b, c, a, c, d + +cheese3d_ctx cheese3d_create(u32 width, u32 height, u32 pitch, u32 bgcolor); +cheese3d_ctx cheese3d_create_default(u32 bgcolor); +void cheese3d_destroy(cheese3d_ctx ctx); +void cheese3d_clear(cheese3d_ctx ctx, bool color, bool depth); +void cheese3d_render(cheese3d_ctx ctx, usize num, vertex *vertices, texture *textures, float transform[4][4]); +void cheese3d_display(cheese3d_ctx ctx); + +#endif |