2021-05-28 05:12:23 +04:30
|
|
|
#include "ltpch.h"
|
2021-05-28 13:13:45 +04:30
|
|
|
#include "glBuffers.h"
|
2021-05-28 05:12:23 +04:30
|
|
|
|
|
|
|
#include <glad/glad.h>
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
|
|
|
glVertexBuffer::glVertexBuffer(unsigned int count, float* vertices)
|
|
|
|
{
|
|
|
|
glCreateBuffers(1, &m_BufferID);
|
2021-06-13 19:35:48 +04:30
|
|
|
glNamedBufferData(m_BufferID, count * sizeof(float), vertices, GL_DYNAMIC_DRAW);
|
2021-05-28 05:12:23 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
glVertexBuffer::~glVertexBuffer()
|
|
|
|
{
|
|
|
|
glDeleteBuffers(1, &m_BufferID);
|
|
|
|
}
|
|
|
|
|
2021-06-13 19:35:48 +04:30
|
|
|
void* glVertexBuffer::Map()
|
|
|
|
{
|
|
|
|
return glMapNamedBuffer(m_BufferID, GL_WRITE_ONLY);
|
|
|
|
}
|
|
|
|
|
|
|
|
void glVertexBuffer::UnMap()
|
|
|
|
{
|
|
|
|
glUnmapNamedBuffer(m_BufferID);
|
|
|
|
}
|
|
|
|
|
2021-05-28 05:12:23 +04:30
|
|
|
void glVertexBuffer::Bind()
|
|
|
|
{
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_BufferID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void glVertexBuffer::UnBind()
|
|
|
|
{
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, NULL);
|
|
|
|
}
|
|
|
|
|
2021-05-28 13:13:45 +04:30
|
|
|
glIndexBuffer::glIndexBuffer(unsigned int count, unsigned int* indices)
|
|
|
|
{
|
|
|
|
glCreateBuffers(1, &m_BufferID);
|
2021-06-13 19:35:48 +04:30
|
|
|
glNamedBufferData(m_BufferID, count * sizeof(unsigned int), indices, GL_STATIC_DRAW);
|
2021-05-28 13:13:45 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
glIndexBuffer::~glIndexBuffer()
|
|
|
|
{
|
|
|
|
glDeleteBuffers(1, &m_BufferID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void glIndexBuffer::Bind()
|
|
|
|
{
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BufferID);
|
|
|
|
}
|
|
|
|
|
|
|
|
void glIndexBuffer::UnBind()
|
|
|
|
{
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, NULL);
|
|
|
|
}
|
|
|
|
|
2021-05-28 05:12:23 +04:30
|
|
|
}
|