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);
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, m_BufferID);
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, count * sizeof(float), vertices, GL_STATIC_DRAW);
|
|
|
|
}
|
|
|
|
|
|
|
|
glVertexBuffer::~glVertexBuffer()
|
|
|
|
{
|
|
|
|
glDeleteBuffers(1, &m_BufferID);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_BufferID);
|
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, count * sizeof(unsigned int), indices, GL_STATIC_DRAW);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|