Brenta Engine 1.2
Loading...
Searching...
No Matches
vao.cpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#include <brenta/logger.hpp>
7#include <brenta/vao.hpp>
8
9using namespace brenta::types;
10
12{
13 glGenVertexArrays(1, &this->vao_id);
14}
15
16unsigned int vao::get_vao()
17{
18 if (vao_id == 0)
19 {
20 ERROR("vao: not initialized");
21 return 0;
22 }
23 return vao_id;
24}
25
27{
28 if (this->get_vao() == 0)
29 {
30 ERROR("vao: not initialized");
31 return;
32 }
33 glBindVertexArray(this->get_vao());
34}
35
37{
38 glBindVertexArray(0);
39}
40
41void vao::set_vertex_data(buffer buffer, unsigned int index, GLint size,
42 GLenum type, GLboolean normalized, GLsizei stride,
43 const void *pointer)
44{
45 bind();
46 buffer.bind();
47 glVertexAttribPointer(index, size, type, normalized, stride, pointer);
48 glEnableVertexAttribArray(index);
49 buffer.unbind();
50 unbind();
51}
52
54{
55 if (this->get_vao() == 0)
56 {
57 ERROR("vao: not initialized");
58 return;
59 }
60 glDeleteVertexArrays(1, &this->vao_id);
61}
Buffer wrapper around OpenGL buffer objects.
Definition buffer.hpp:30
void unbind()
Unbind the buffer object.
Definition buffer.cpp:49
void bind()
Bind the buffer object.
Definition buffer.cpp:39
void bind()
Bind the VAO.
Definition vao.cpp:26
void set_vertex_data(buffer buffer, unsigned int index, GLint size, GLenum type, GLboolean is_normalized, GLsizei stride, const void *pointer)
Set the vertex data.
Definition vao.cpp:41
unsigned int vao_id
Vertex Array Object (VAO)
Definition vao.hpp:28
unsigned int get_vao()
Get the VAO.
Definition vao.cpp:16
void unbind()
Unbind the VAO.
Definition vao.cpp:36
void init()
Init Constructor.
Definition vao.cpp:11
void destroy()
Delete the VAO.
Definition vao.cpp:53