more tweaks to batch API

main
cosmonaut 2022-04-12 17:03:59 -07:00
parent e93662f231
commit 6a86f5b533
2 changed files with 12 additions and 22 deletions

View File

@ -116,11 +116,13 @@ WELLSPRINGAPI uint8_t* Wellspring_GetPixelDataPointer(
WELLSPRINGAPI Wellspring_TextBatch* Wellspring_CreateTextBatch();
/* Also restarts the batch */
WELLSPRINGAPI void Wellspring_StartTextBatch(Wellspring_TextBatch *textBatch);
WELLSPRINGAPI void Wellspring_StartTextBatch(
Wellspring_TextBatch *textBatch,
Wellspring_Packer *packer
);
WELLSPRINGAPI uint8_t Wellspring_Draw(
Wellspring_TextBatch *textBatch,
Wellspring_Packer *packer,
float x,
float y,
float depth,
@ -129,12 +131,6 @@ WELLSPRINGAPI uint8_t Wellspring_Draw(
uint32_t strLengthInBytes
);
WELLSPRINGAPI void Wellspring_GetBufferLengths(
Wellspring_TextBatch *textBatch,
uint32_t *pVertexCount,
uint32_t *pIndexCount
);
WELLSPRINGAPI void Wellspring_GetBufferData(
Wellspring_TextBatch *textBatch,
Wellspring_Vertex **pVertexBuffer,

View File

@ -89,6 +89,8 @@ typedef struct Batch
uint32_t *indices;
uint32_t indexCount;
uint32_t indexCapacity;
Packer *currentPacker;
} Batch;
/* UTF-8 Decoder */
@ -236,16 +238,18 @@ Wellspring_TextBatch* Wellspring_CreateTextBatch()
return (Wellspring_TextBatch*) batch;
}
void Wellspring_StartTextBatch(Wellspring_TextBatch *textBatch)
{
void Wellspring_StartTextBatch(
Wellspring_TextBatch *textBatch,
Wellspring_Packer *packer
) {
Batch *batch = (Batch*) textBatch;
batch->currentPacker = (Packer*) packer;
batch->vertexCount = 0;
batch->indexCount = 0;
}
uint8_t Wellspring_Draw(
Wellspring_TextBatch *textBatch,
Wellspring_Packer *packer,
float x,
float y,
float depth,
@ -254,7 +258,7 @@ uint8_t Wellspring_Draw(
uint32_t strLength
) {
Batch *batch = (Batch*) textBatch;
Packer *myPacker = (Packer*) packer;
Packer *myPacker = batch->currentPacker;
uint32_t decodeState = 0;
uint32_t codepoint;
int32_t glyphIndex;
@ -372,16 +376,6 @@ uint8_t Wellspring_Draw(
return 1;
}
void Wellspring_GetBufferLengths(
Wellspring_TextBatch *textBatch,
uint32_t *pVertexCount,
uint32_t *pIndexCount
) {
Batch *batch = (Batch*) textBatch;
*pVertexCount = batch->vertexCount;
*pIndexCount = batch->indexCount;
}
void Wellspring_GetBufferData(
Wellspring_TextBatch *textBatch,
Wellspring_Vertex **pVertexBuffer,