#ifndef CHUNK_H #define CHUNK_H #include #include #include #include #include "utils.h" typedef struct { GLuint tid; SDL_Surface *surface; int type; } Type_surface; typedef enum { BLOCKTYPE_AIR, BLOCKTYPE_GRASS, BLOCKTYPE_DIRT, BLOCKTYPE_STONE, BLOCKTYPE_COUNT, } Block_type; typedef struct { Block_type type; bool visible; } Block; typedef struct { vec3f start_pos; Block blocks[CHUNK_MAX_X][CHUNK_MAX_Y][CHUNK_MAX_Z]; GLuint id; } Chunk; typedef struct { unsigned int chunk_count; Chunk *chunks; Type_surface *textures; unsigned int texture_count; } ChunkManager; bool chunk_is_block_neighboring_block(Chunk* chunk, vec3i pos); void chunk_set_blocks_visibility(Chunk* chunk); void chunk_create_displayl(ChunkManager *cm, Chunk *chunk); void chunk_render(Chunk* chunk); void chunk_update(ChunkManager* cm, Chunk *chunk); void draw_cube(ChunkManager *cm, Block_type type, float x, float y, float z); bool is_block(Block b); int chunk_get_current_chunk_index(ChunkManager *cm, vec3f pos); #endif