Gawain : Added Batch_init()

to init a batch without allocating memory
This commit is contained in:
Clément Foucault 2017-02-10 22:43:25 +01:00 committed by Julian Eisel
parent af2df36248
commit b97864203e
2 changed files with 10 additions and 4 deletions

View File

@ -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)

View File

@ -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