initial commit
This commit is contained in:
commit
5e83dec47d
7 changed files with 5731 additions and 0 deletions
39
buffers.c
Normal file
39
buffers.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "buffers.h"
|
||||
#include <stdint.h>
|
||||
#include "include/glad/gl.h"
|
||||
|
||||
// Vertex Array
|
||||
void cw_vertex_array_init(struct cw_vertex_array *self) {
|
||||
glCreateVertexArrays(1, &self->id);
|
||||
}
|
||||
|
||||
void cw_vertex_array_deinit(struct cw_vertex_array *self) {
|
||||
glDeleteVertexArrays(1, &self->id);
|
||||
}
|
||||
|
||||
void cw_vertex_array_bind(struct cw_vertex_array *self) {
|
||||
glBindVertexArray(self->id);
|
||||
}
|
||||
|
||||
void cw_vertex_array_unbind(struct cw_vertex_array *self) {
|
||||
glBindVertexArray(0);
|
||||
}
|
||||
|
||||
// Vertex Buffer
|
||||
void cw_vertex_buffer_init(struct cw_vertex_buffer *self) {
|
||||
glCreateBuffers(1, &self->id);
|
||||
}
|
||||
|
||||
void cw_vertex_buffer_deinit(struct cw_vertex_buffer *self) {
|
||||
glDeleteBuffers(1, &self->id);
|
||||
}
|
||||
|
||||
// Index Buffer
|
||||
void cw_index_buffer_init(struct cw_index_buffer *self, uint32_t* indices, uint32_t count) {
|
||||
glCreateBuffers(1, &self->id);
|
||||
glNamedBufferData(self->id, sizeof(GLuint) * count, indices, GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
void cw_index_buffer_deinit(struct cw_index_buffer *self) {
|
||||
glDeleteBuffers(1, &self->id);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue