PeriDyno
1.0.0
Loading...
Searching...
No Matches
D:
Peridyno
peridyno
src
Rendering
Engine
OpenGL
GraphicsObject
VertexArray.cpp
Go to the documentation of this file.
1
#include "
VertexArray.h
"
2
3
#include <glad/glad.h>
4
#include <vector>
5
6
namespace
dyno
7
{
8
void
VertexArray::create
()
9
{
10
glGenVertexArrays(1, &
id
);
11
}
12
13
void
VertexArray::release
()
14
{
15
glDeleteVertexArrays(1, &
id
);
16
17
// reset object id
18
id
= GL_INVALID_INDEX;
19
}
20
21
void
VertexArray::bind
()
22
{
23
glBindVertexArray(
id
);
24
}
25
26
void
VertexArray::unbind
()
27
{
28
glBindVertexArray(0);
29
}
30
31
void
VertexArray::bindIndexBuffer
(
Buffer
* buffer)
32
{
33
this->
bind
();
34
if
(buffer == 0)
35
{
36
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
37
}
38
else
39
{
40
buffer->
bind
();
41
}
42
this->
unbind
();
43
}
44
45
46
void
VertexArray::bindVertexBuffer
(
Buffer
* buffer,
int
index,
47
int
size,
int
type,
int
stride,
int
offset,
int
divisor)
48
{
49
this->
bind
();
50
if
(buffer == 0)
51
{
52
glDisableVertexAttribArray(index);
53
}
54
else
55
{
56
buffer->
bind
();
57
glEnableVertexAttribArray(index);
58
glVertexAttribPointer(index, size, type, GL_FALSE, stride, (
void
*)offset);
59
glVertexAttribDivisor(index, divisor);
60
}
61
this->
unbind
();
62
}
63
64
}
VertexArray.h
dyno::Buffer
Definition
Buffer.h:24
dyno::Buffer::bind
void bind()
Definition
Buffer.cpp:31
dyno::VertexArray::unbind
virtual void unbind()
Definition
VertexArray.cpp:26
dyno::VertexArray::bindIndexBuffer
virtual void bindIndexBuffer(Buffer *buffer)
Definition
VertexArray.cpp:31
dyno::VertexArray::release
virtual void release() override
Definition
VertexArray.cpp:13
dyno::VertexArray::bind
virtual void bind()
Definition
VertexArray.cpp:21
dyno::VertexArray::bindVertexBuffer
virtual void bindVertexBuffer(Buffer *buffer, int index, int size, int type, int stride, int offset, int divisor)
Definition
VertexArray.cpp:46
dyno::VertexArray::create
virtual void create() override
Definition
VertexArray.cpp:8
dyno
This is an implementation of AdditiveCCD based on peridyno.
Definition
Array.h:25
Generated by
1.13.2