Gawain : Added Batch_init()
to init a batch without allocating memory
This commit is contained in:
parent
af2df36248
commit
b97864203e
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue