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-09 21:15:48 +00:00
|
|
|
VertexBuffer::VertexBuffer(int sizeInBytes) : mData(sizeInBytes)
|
2019-08-09 04:18:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer::SetBufferData(const void* data, int64_t size)
|
|
|
|
{
|
2019-08-09 21:15:48 +00:00
|
|
|
if (size > 0 && size < (int64_t)mData.size())
|
|
|
|
memcpy(mData.data(), data, size);
|
2019-08-09 04:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer::SetBufferSubdata(int64_t destOffset, const void* data, int64_t size)
|
|
|
|
{
|
2019-08-09 21:15:48 +00:00
|
|
|
if (destOffset >= 0 && size > 0 && size < (int64_t)mData.size() - destOffset)
|
|
|
|
memcpy(mData.data() + destOffset, data, size);
|
2019-08-09 04:18:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
VertexBuffer* VertexBuffer_New(int sizeInBytes)
|
|
|
|
{
|
|
|
|
return new VertexBuffer(sizeInBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer_Delete(VertexBuffer* buffer)
|
|
|
|
{
|
|
|
|
delete buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer_SetBufferData(VertexBuffer* handle, void* data, int64_t size)
|
|
|
|
{
|
|
|
|
handle->SetBufferData(data, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexBuffer_SetBufferSubdata(VertexBuffer* handle, int64_t destOffset, void* data, int64_t size)
|
|
|
|
{
|
|
|
|
handle->SetBufferSubdata(destOffset, data, size);
|
|
|
|
}
|