2021-12-05 18:14:55 +01:00
|
|
|
#include "gfx/gl/vertex_array.h"
|
2021-12-04 23:26:58 +01:00
|
|
|
|
2023-09-10 17:26:09 +02:00
|
|
|
#include "gfx/gl/utils.h"
|
|
|
|
|
2021-12-04 23:26:58 +01:00
|
|
|
#include <assert.h>
|
|
|
|
|
2021-12-05 18:14:55 +01:00
|
|
|
void GFX_GL_VertexArray_Init(GFX_GL_VertexArray *array)
|
2021-12-04 23:26:58 +01:00
|
|
|
{
|
|
|
|
assert(array);
|
|
|
|
glGenVertexArrays(1, &array->id);
|
2023-09-10 17:26:09 +02:00
|
|
|
GFX_GL_CheckError();
|
2021-12-04 23:26:58 +01:00
|
|
|
}
|
|
|
|
|
2021-12-05 18:14:55 +01:00
|
|
|
void GFX_GL_VertexArray_Close(GFX_GL_VertexArray *array)
|
2021-12-04 23:26:58 +01:00
|
|
|
{
|
|
|
|
assert(array);
|
|
|
|
glDeleteVertexArrays(1, &array->id);
|
2023-09-10 17:26:09 +02:00
|
|
|
GFX_GL_CheckError();
|
2021-12-04 23:26:58 +01:00
|
|
|
}
|
|
|
|
|
2021-12-05 18:14:55 +01:00
|
|
|
void GFX_GL_VertexArray_Bind(GFX_GL_VertexArray *array)
|
2021-12-04 23:26:58 +01:00
|
|
|
{
|
|
|
|
assert(array);
|
|
|
|
glBindVertexArray(array->id);
|
2023-09-10 17:26:09 +02:00
|
|
|
GFX_GL_CheckError();
|
2021-12-04 23:26:58 +01:00
|
|
|
}
|
|
|
|
|
2021-12-05 18:14:55 +01:00
|
|
|
void GFX_GL_VertexArray_Attribute(
|
|
|
|
GFX_GL_VertexArray *array, GLuint index, GLint size, GLenum type,
|
2021-12-04 23:26:58 +01:00
|
|
|
GLboolean normalized, GLsizei stride, GLsizei offset)
|
|
|
|
{
|
|
|
|
assert(array);
|
|
|
|
glEnableVertexAttribArray(index);
|
2023-09-10 17:26:09 +02:00
|
|
|
GFX_GL_CheckError();
|
|
|
|
|
2021-12-04 23:26:58 +01:00
|
|
|
glVertexAttribPointer(
|
|
|
|
index, size, type, normalized, stride, (void *)offset);
|
2023-09-10 17:26:09 +02:00
|
|
|
GFX_GL_CheckError();
|
2021-12-04 23:26:58 +01:00
|
|
|
}
|