diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-07-12 17:28:18 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-07-12 18:48:52 +0300 |
commit | 95a7a0a06ebc7c88bc56c90bb4edfeef302694b7 (patch) | |
tree | 4701b01a2ce7b9a81409dd981a2dd229c564300c /intern | |
parent | 5ee5c595bac34c9f914724ba1212210e8b821821 (diff) |
Gawain: add GWN_vertbuf_clear
Needed to clear the buffer without freeing.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/gawain/gawain/vertex_buffer.h | 1 | ||||
-rw-r--r-- | intern/gawain/src/vertex_buffer.c | 19 |
2 files changed, 20 insertions, 0 deletions
diff --git a/intern/gawain/gawain/vertex_buffer.h b/intern/gawain/gawain/vertex_buffer.h index a66154d06e3..9aee8e05877 100644 --- a/intern/gawain/gawain/vertex_buffer.h +++ b/intern/gawain/gawain/vertex_buffer.h @@ -31,6 +31,7 @@ typedef struct { Gwn_VertBuf* GWN_vertbuf_create(void); Gwn_VertBuf* GWN_vertbuf_create_with_format(const Gwn_VertFormat*); +void GWN_vertbuf_clear(Gwn_VertBuf* verts); void GWN_vertbuf_discard(Gwn_VertBuf*); void GWN_vertbuf_init(Gwn_VertBuf*); diff --git a/intern/gawain/src/vertex_buffer.c b/intern/gawain/src/vertex_buffer.c index a9b481261f3..364e16a1a68 100644 --- a/intern/gawain/src/vertex_buffer.c +++ b/intern/gawain/src/vertex_buffer.c @@ -51,6 +51,25 @@ void GWN_vertbuf_init_with_format(Gwn_VertBuf* verts, const Gwn_VertFormat* form VertexFormat_pack(&verts->format); } +/** + * Like #GWN_vertbuf_discard but doesn't free. + */ +void GWN_vertbuf_clear(Gwn_VertBuf* verts) + { + if (verts->vbo_id) { + GWN_buf_id_free(verts->vbo_id); + vbo_memory_usage -= GWN_vertbuf_size_get(verts); + } +#if KEEP_SINGLE_COPY + else +#endif + if (verts->data) + { + free(verts->data); + verts->data = NULL; + } + } + void GWN_vertbuf_discard(Gwn_VertBuf* verts) { if (verts->vbo_id) { |