39 lines
1,015 B
C
39 lines
1,015 B
C
#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);
|
|
}
|