2019-08-09 04:18:08 +00:00
|
|
|
|
2019-08-10 00:32:08 +00:00
|
|
|
#include "Precomp.h"
|
2019-08-09 04:18:08 +00:00
|
|
|
#include "VertexBuffer.h"
|
|
|
|
|
2019-08-15 00:52:21 +00:00
|
|
|
VertexBuffer::VertexBuffer(int sizeInBytes) : mSize(sizeInBytes)
|
2019-08-09 04:18:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-08-10 05:46:29 +00:00
|
|
|
VertexBuffer::~VertexBuffer()
|
|
|
|
{
|
|
|
|
// To do: move mBuffer to a delete list as this might be called by a finalizer in a different thread
|
|
|
|
}
|
|
|
|
|
|
|
|
GLuint VertexBuffer::GetBuffer()
|
|
|
|
{
|
|
|
|
if (mBuffer == 0)
|
|
|
|
{
|
|
|
|
glGenBuffers(1, &mBuffer);
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
|
2019-08-15 00:52:21 +00:00
|
|
|
glBufferData(GL_ARRAY_BUFFER, mSize, nullptr, GL_STREAM_DRAW);
|
2019-08-10 05:46:29 +00:00
|
|
|
}
|
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
2019-08-09 04:18:08 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
VertexBuffer* VertexBuffer_New(int sizeInBytes)
|
|
|
|
{
|
|
|
|
return new VertexBuffer(sizeInBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer_Delete(VertexBuffer* buffer)
|
|
|
|
{
|
|
|
|
delete buffer;
|
|
|
|
}
|