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
9
using namespace
brenta::types;
10
11
void
vao::init
()
12
{
13
glGenVertexArrays(1, &this->
vao_id
);
14
}
15
16
unsigned
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
26
void
vao::bind
()
27
{
28
if
(this->
get_vao
() == 0)
29
{
30
ERROR(
"vao: not initialized"
);
31
return
;
32
}
33
glBindVertexArray(this->
get_vao
());
34
}
35
36
void
vao::unbind
()
37
{
38
glBindVertexArray(0);
39
}
40
41
void
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
53
void
vao::destroy
()
54
{
55
if
(this->
get_vao
() == 0)
56
{
57
ERROR(
"vao: not initialized"
);
58
return
;
59
}
60
glDeleteVertexArrays(1, &this->
vao_id
);
61
}
brenta::types::buffer
Buffer wrapper around OpenGL buffer objects.
Definition
buffer.hpp:30
brenta::types::buffer::unbind
void unbind()
Unbind the buffer object.
Definition
buffer.cpp:49
brenta::types::buffer::bind
void bind()
Bind the buffer object.
Definition
buffer.cpp:39
brenta::types::vao::bind
void bind()
Bind the VAO.
Definition
vao.cpp:26
brenta::types::vao::set_vertex_data
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
brenta::types::vao::vao_id
unsigned int vao_id
Vertex Array Object (VAO)
Definition
vao.hpp:28
brenta::types::vao::get_vao
unsigned int get_vao()
Get the VAO.
Definition
vao.cpp:16
brenta::types::vao::unbind
void unbind()
Unbind the VAO.
Definition
vao.cpp:36
brenta::types::vao::init
void init()
Init Constructor.
Definition
vao.cpp:11
brenta::types::vao::destroy
void destroy()
Delete the VAO.
Definition
vao.cpp:53
src
vao.cpp
Generated by
1.12.0