diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-02-11 00:43:25 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2017-02-11 02:43:03 +0300 |
commit | b97864203ecd4df2b7b5d297c2e0203705c8f431 (patch) | |
tree | 0769c25805c983f5b890d61124f4900913e0c08a /source/blender | |
parent | af2df3624842cf1a8c2c98d51ca0b82ed0920295 (diff) |
Gawain : Added Batch_init()
to init a batch without allocating memory
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/gawain/batch.c | 13 | ||||
-rw-r--r-- | source/blender/gpu/gawain/batch.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/gpu/gawain/batch.c b/source/blender/gpu/gawain/batch.c index 99c13301177..3ddc6c7f639 100644 --- a/source/blender/gpu/gawain/batch.c +++ b/source/blender/gpu/gawain/batch.c @@ -19,20 +19,25 @@ extern bool gpuMatricesDirty(void); // how best to use this here? Batch* Batch_create(PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem) { + Batch* batch = calloc(1, sizeof(Batch)); + + Batch_init(batch, prim_type, verts, elem); + + return batch; + } + +void Batch_init(Batch* batch, PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem) + { #if TRUST_NO_ONE assert(verts != NULL); assert(prim_type == PRIM_POINTS || prim_type == PRIM_LINES || prim_type == PRIM_TRIANGLES); // we will allow other primitive types in a future update #endif - Batch* batch = calloc(1, sizeof(Batch)); - batch->verts = verts; batch->elem = elem; batch->prim_type = prim_type; batch->phase = READY_TO_DRAW; - - return batch; } void Batch_discard(Batch* batch) diff --git a/source/blender/gpu/gawain/batch.h b/source/blender/gpu/gawain/batch.h index 8b5c48cca79..a328d649663 100644 --- a/source/blender/gpu/gawain/batch.h +++ b/source/blender/gpu/gawain/batch.h @@ -38,6 +38,7 @@ typedef struct Batch{ } Batch; Batch* Batch_create(PrimitiveType, VertexBuffer*, ElementList*); +void Batch_init(Batch* batch, PrimitiveType prim_type, VertexBuffer* verts, ElementList* elem); void Batch_discard(Batch*); // verts & elem are not discarded void Batch_discard_all(Batch*); // including verts & elem |