diff options
Diffstat (limited to 'src/graphics/VertexBuffer.cpp')
-rw-r--r-- | src/graphics/VertexBuffer.cpp | 17 |
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&) { |