1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

LibGL: Add simple implementation of buffer objects

For now, buffers are only implemented on the LibGL side, however in the
future buffer objects should be stored in LibGPU.
This commit is contained in:
cflip 2022-11-13 15:08:24 -07:00 committed by Andreas Kling
parent 892006218a
commit 59df2e62ee
6 changed files with 170 additions and 10 deletions

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2022, cflip <cflip@cflip.net>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Buffer.h"
namespace GL {
ErrorOr<void> Buffer::set_data(void const* data, size_t size)
{
if (!data) {
m_data = TRY(ByteBuffer::create_uninitialized(size));
return {};
}
m_data = TRY(ByteBuffer::copy(data, size));
return {};
}
void Buffer::replace_data(void const* data, size_t offset, size_t size)
{
m_data.overwrite(offset, data, size);
}
size_t Buffer::size()
{
return m_data.size();
}
void* Buffer::data()
{
return m_data.data();
}
void* Buffer::offset_data(size_t offset)
{
return m_data.offset_pointer(offset);
}
}