diff options
| author | Aaditya Dhruv <[email protected]> | 2026-01-30 00:42:50 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2026-01-30 00:42:50 -0600 |
| commit | 839e04c5b583b51726207fc2508dce5c3afb3f04 (patch) | |
| tree | 70da713f51c513b47ece6b8db1b9bfb28e0b3da8 /src/block.c | |
| parent | 8150b91d4076d15f8df5cd66acc1b8076a2ee1a9 (diff) | |
Add chunk_unloading on chunk Changes
If we change a chunk, unload all chunks. This removes block GPU data
(vbo, ebo, vao). We anyways redraw so we don't lose anything
Diffstat (limited to 'src/block.c')
| -rw-r--r-- | src/block.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/block.c b/src/block.c index 2197b2a..56db3f4 100644 --- a/src/block.c +++ b/src/block.c @@ -22,6 +22,12 @@ int block_init(vec3 pos, struct block* blk) { // Store buffer data into struct // Initialize vbo and ebo for block memcpy(blk->coords, pos, sizeof(vec3)); + block_load_gpu(blk); + block_update(blk); + return 0; +} + +void block_load_gpu(struct block* blk) { // ========== Constants of a block ================ // Local world coordinates float vertices[] = { @@ -122,8 +128,6 @@ int block_init(vec3 pos, struct block* blk) { //call is create_vbo. Since VAO is already bound, it gets bound to the OLD //VAO!! Always clear before use. glBindVertexArray(0); - block_update(blk); - return 0; } void block_update(struct block* blk) { @@ -172,3 +176,12 @@ void block_debug(struct block *blk) { glm_mat4_print(blk->model, stderr); } + +void block_unload(struct block *blk) { + // Clear VBO data + glDeleteBuffers(1, &blk->_vbo); + // Clear EBO data + glDeleteBuffers(1, &blk->_ebo); + // Clear VAO + glDeleteVertexArrays(1, &blk->_vao); +} |
