Techneck/code/source-c/blocks.h

95 lines
2.6 KiB
C
Raw Normal View History

2023-10-10 19:23:07 +00:00
#ifndef TC_BLOCK_H
#define TC_BLOCK_H
#include <stdbool.h>
#include <stdint.h>
#include <glad/glad.h>
2023-10-13 10:23:26 +00:00
#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;
2023-10-10 19:23:07 +00:00
typedef struct tc_block_attribute
{
char *name;
2023-10-12 06:18:43 +00:00
union {
void *pointer;
char *string;
int64_t integer;
} value;
2023-10-10 19:23:07 +00:00
} tc_block_attribute_s;
typedef struct tc_block_entry
{
char *name;
2023-10-11 08:10:06 +00:00
uint32_t identifier;
2023-10-10 19:23:07 +00:00
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;
2023-10-12 06:18:43 +00:00
tc_block_entry_s **blocks;
2023-10-10 19:23:07 +00:00
} tc_block_registry_s;
2023-10-12 06:18:43 +00:00
tc_block_entry_s * tc_new_block_entry (char *name);
void tc_add_attribute_to_block_entry
2023-10-10 19:23:07 +00:00
(tc_block_entry_s *entry, tc_block_attribute_s attribute);
2023-10-12 06:18:43 +00:00
tc_block_attribute_s * tc_block_resolve_name_to_attribute (tc_block_entry_s *block, char *name);
2023-10-10 19:23:07 +00:00
tc_block_entry_s * tc_get_block (char *name);
2023-10-12 06:18:43 +00:00
tc_block_entry_s * tc_resolve_id_to_block_entry (uint32_t id);
2023-10-10 19:23:07 +00:00
tc_block_registry_s tc_init_blocks ();
2023-10-12 06:18:43 +00:00
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 ();
2023-10-13 10:23:26 +00:00
// 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);
2023-10-10 19:23:07 +00:00
#endif