1#ifndef CHUNK_H
2#define CHUNK_H
3
4#include "types.h"
5#include "world/block.h"
6#include "renderer/renderer.h"
7
8#define CHUNK_WIDTH 16
9#define CHUNK_HEIGHT 32
10#define CHUNK_DEPTH 16
11
12#define WORLD_WIDTH 10
13#define WORLD_DEPTH 10
14
15typedef struct {
16 BlockType blocks[CHUNK_WIDTH][CHUNK_HEIGHT][CHUNK_DEPTH];
17 MGMesh meshes[BLOCK_LAST];
18} Chunk;
19
20/* create a new chunk
21 just stone and dirt with a hint of brick for now */
22void chunk_create(Chunk* chunk);
23
24/* get the block at specified position
25 TODO? should we use x, y, z or a vec3? c89 doesnt
26 have compound literals so it may be a pain in
27 the future? who knows */
28BlockType chunk_get(const Chunk* chunk, i32 x, i32 y, i32 z);
29
30/* set the block at specified position
31 TODO? should we use x, y, z or a vec3? c89 doesnt
32 have compound literals so it may be a pain in
33 the future? who knows */
34void chunk_set(Chunk* chunk, i32 x, i32 y, i32 z, BlockType block);
35
36/* create a mesh for chunk by generating vertices
37 and indices for each (visible) face */
38i8 chunk_mesh_create(Chunk* chunk);
39
40/* destroy a chunks mesh */
41void chunk_mesh_destroy(Chunk* chunk);
42
43#endif /* CHUNK_H */