diff options
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); +} |
