aboutsummaryrefslogtreecommitdiff
path: root/src/graphics/VertexBuffer.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-28 17:33:57 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-29 14:31:31 +0200
commit8d525bc1c3506f15a5f68672245f845cebe18eef (patch)
tree243376e2cae0be40b6870ec8fe0082845996df87 /src/graphics/VertexBuffer.cpp
parenta80bf6bb6cb8ab8c5a1430f9f9dbc214f71bdddf (diff)
More, todo interfaces
Diffstat (limited to 'src/graphics/VertexBuffer.cpp')
-rw-r--r--src/graphics/VertexBuffer.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/graphics/VertexBuffer.cpp b/src/graphics/VertexBuffer.cpp
index 2eb06a8..a821a5d 100644
--- a/src/graphics/VertexBuffer.cpp
+++ b/src/graphics/VertexBuffer.cpp
@@ -6,8 +6,8 @@ extern "C" {
}
namespace mgl {
- VertexBuffer::VertexBuffer(PrimitiveType primitive_type, Usage usage) : texture(nullptr), primitive_type(primitive_type), usage(usage) {
- vertex_buffer.id = 0;
+ VertexBuffer::VertexBuffer() : texture(nullptr) {
+ mgl_vertex_buffer_init(&vertex_buffer);
}
VertexBuffer::~VertexBuffer() {
@@ -35,13 +35,12 @@ namespace mgl {
return texture;
}
- bool VertexBuffer::update(const Vertex *vertices, size_t vertex_count) {
- if(vertex_buffer.id == 0) {
- int res = mgl_vertex_buffer_init(&vertex_buffer, (mgl_primitive_type)primitive_type, (mgl_vertex_buffer_usage)usage);
- if(res != 0)
- return false;
- }
- return mgl_vertex_buffer_update(&vertex_buffer, (const mgl_vertex*)vertices, vertex_count) == 0;
+ size_t VertexBuffer::size() const {
+ return vertex_buffer.vertex_count;
+ }
+
+ bool VertexBuffer::update(const Vertex *vertices, size_t vertex_count, PrimitiveType primitive_type, Usage usage) {
+ return mgl_vertex_buffer_update(&vertex_buffer, (const mgl_vertex*)vertices, vertex_count, (mgl_primitive_type)primitive_type, (mgl_vertex_buffer_usage)usage) == 0;
}
void VertexBuffer::draw(Window&) {