95 lines
2.6 KiB
C
95 lines
2.6 KiB
C
|
|
#ifndef TC_BLOCK_H
|
|
#define TC_BLOCK_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#include <glad/glad.h>
|
|
|
|
#define TC_BLOCK_OPAQUE_BIT (1 << 31)
|
|
|
|
typedef struct tc_cube_side_mesh
|
|
{
|
|
uint32_t num_vertices;
|
|
|
|
float *allocation;
|
|
|
|
float *uv;
|
|
float *xyz;
|
|
|
|
} tc_cube_side_mesh_s;
|
|
|
|
typedef struct tc_block_attribute
|
|
{
|
|
char *name;
|
|
|
|
union {
|
|
void *pointer;
|
|
char *string;
|
|
int64_t integer;
|
|
} value;
|
|
|
|
} tc_block_attribute_s;
|
|
|
|
typedef struct tc_block_entry
|
|
{
|
|
char *name;
|
|
uint32_t identifier;
|
|
|
|
uint32_t attributes_capacity;
|
|
uint32_t num_attributes;
|
|
tc_block_attribute_s *attributes;
|
|
|
|
} tc_block_entry_s;
|
|
|
|
typedef struct tc_block_registry
|
|
{
|
|
uint32_t blocks_capacity;
|
|
uint32_t num_blocks;
|
|
tc_block_entry_s **blocks;
|
|
|
|
} tc_block_registry_s;
|
|
|
|
|
|
|
|
tc_block_entry_s * tc_new_block_entry (char *name);
|
|
void tc_add_attribute_to_block_entry
|
|
(tc_block_entry_s *entry, tc_block_attribute_s attribute);
|
|
tc_block_attribute_s * tc_block_resolve_name_to_attribute (tc_block_entry_s *block, char *name);
|
|
|
|
tc_block_entry_s * tc_get_block (char *name);
|
|
tc_block_entry_s * tc_resolve_id_to_block_entry (uint32_t id);
|
|
|
|
tc_block_registry_s tc_init_blocks ();
|
|
|
|
|
|
|
|
typedef struct tc_cube_info
|
|
{
|
|
char *name;
|
|
|
|
uint32_t identifier;
|
|
|
|
uint32_t texture_top;
|
|
uint32_t texture_bottom;
|
|
uint32_t texture_east;
|
|
uint32_t texture_west;
|
|
uint32_t texture_back;
|
|
uint32_t texture_front;
|
|
|
|
} tc_cube_info_s;
|
|
|
|
tc_cube_info_s tc_gen_unitexture_cube_info
|
|
(char *name, uint32_t identifier, uint32_t texture);
|
|
|
|
tc_block_entry_s * tc_new_cube_block (tc_cube_info_s info);
|
|
void tc_create_blocks ();
|
|
|
|
// tc_premesh_cube: Creates a cube's mesh in advance so it is faster when generating a chunk.
|
|
// This is already being done by tc_new_cube_block.
|
|
void tc_premesh_cube (tc_block_entry_s *entry);
|
|
|
|
#endif
|
|
|