From 6a86f5b53346ea62e2203f1ec3b3bc6818a5725d Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 12 Apr 2022 17:03:59 -0700 Subject: [PATCH] more tweaks to batch API --- include/Wellspring.h | 12 ++++-------- src/Wellspring.c | 22 ++++++++-------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/include/Wellspring.h b/include/Wellspring.h index 0357050..c12831c 100644 --- a/include/Wellspring.h +++ b/include/Wellspring.h @@ -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, diff --git a/src/Wellspring.c b/src/Wellspring.c index 921555e..1f1d7a3 100644 --- a/src/Wellspring.c +++ b/src/Wellspring.c @@ -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,