-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVertexBuffer.cpp
31 lines (26 loc) · 899 Bytes
/
VertexBuffer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "VertexBuffer.h"
#include "VertexBufferLayout.h"
#include "Renderer.h"
VertexBuffer::VertexBuffer(const void* data, unsigned size)
{
// create vertex buffer and its id
glGenBuffers(1, &m_renderer_id);
// selecting the buffer with its id
glBindBuffer(GL_ARRAY_BUFFER, m_renderer_id);
// <- size of the buffer in bytes
// <- source
// <- STREAM -> modified once, used few times; STATIC -> modified once, used often, DYNAMIC -> modified repeatedly, used often
glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW);
}
VertexBuffer::~VertexBuffer()
{
glDeleteBuffers(1, &m_renderer_id);
}
void VertexBuffer::bind() const
{
glBindBuffer(GL_ARRAY_BUFFER, m_renderer_id);
}
void VertexBuffer::unbind() const
{
glBindBuffer(GL_ARRAY_BUFFER, 0);
}