1#ifndef WORLD_BLOCK_H
2#define WORLD_BLOCK_H
3
4#include "types.h"
5#include "renderer/renderer.h"
6
7typedef u16 BlockType;
8
9#define BLOCK_AIR ((BlockType)0)
10#define BLOCK_STONE ((BlockType)(1 << 4))
11#define BLOCK_DIRT ((BlockType)(3 << 4))
12#define BLOCK_BRICK ((BlockType)(45 << 4))
13
14#define BLOCK_FACE_COUNT 6
15#define BLOCK_TEXTURE_COUNT 512
16
17typedef struct {
18 MGVertex vertices[4];
19 i32 texture;
20 i32 cullface;
21} BlockFace;
22
23/* create block textures from resource pack
24 returns 1 on success, 0 on failure */
25i8 block_textures_create(const char* path);
26
27/* destroy block textures */
28void block_textures_destroy(void);
29
30/* get model faces for block
31 returns block face array */
32const BlockFace* block_model_faces(BlockType block, i32* count);
33
34/* check whether block model occludes all cube faces
35 returns 1 if block occludes, 0 otherwise */
36i8 block_model_occludes(BlockType block);
37
38/* get block texture by index
39 returns texture handle, or MGTEXTURE_INVALID on failure */
40MGTexture block_texture_get(i32 index);
41
42#endif /* WORLD_BLOCK_H */