diff --git a/include/Wellspring.h b/include/Wellspring.h index bdb43b4..0357050 100644 --- a/include/Wellspring.h +++ b/include/Wellspring.h @@ -103,14 +103,13 @@ WELLSPRINGAPI uint32_t Wellspring_PackFontRanges( uint32_t numRanges ); -/* Copies pixel data into the given byte array. +/* Returns a pointer to an array of rasterized pixels of the packed font. * This data must be uploaded to a texture before you render! - * The pixel data also becomes outdated if you call PackFontRanges. + * The pixel data becomes outdated if you call PackFontRanges. * Length is width * height. */ -WELLSPRINGAPI void Wellspring_GetPixels( - Wellspring_Packer *packer, - uint8_t *pData +WELLSPRINGAPI uint8_t* Wellspring_GetPixelDataPointer( + Wellspring_Packer *packer ); /* Batches are not thread-safe, recommend one batch per thread. */ @@ -138,8 +137,10 @@ WELLSPRINGAPI void Wellspring_GetBufferLengths( WELLSPRINGAPI void Wellspring_GetBufferData( Wellspring_TextBatch *textBatch, - Wellspring_Vertex *pVertexBuffer, - uint32_t *pIndexBuffer + Wellspring_Vertex **pVertexBuffer, + uint32_t *pVertexBufferLengthInBytes, + uint32_t **pIndexBuffer, + uint32_t *pIndexBufferLengthInBytes ); WELLSPRINGAPI void Wellspring_DestroyTextBatch(Wellspring_TextBatch *textBatch); diff --git a/src/Wellspring.c b/src/Wellspring.c index c5f5758..921555e 100644 --- a/src/Wellspring.c +++ b/src/Wellspring.c @@ -214,16 +214,11 @@ uint32_t Wellspring_PackFontRanges( return 1; } -void Wellspring_GetPixels( - Wellspring_Packer *packer, - uint8_t *pData +uint8_t* Wellspring_GetPixelDataPointer( + Wellspring_Packer *packer ) { Packer* myPacker = (Packer*) packer; - Wellspring_memcpy( - pData, - myPacker->pixels, - sizeof(uint8_t) * myPacker->width * myPacker->height - ); + return myPacker->pixels; } Wellspring_TextBatch* Wellspring_CreateTextBatch() @@ -389,20 +384,16 @@ void Wellspring_GetBufferLengths( void Wellspring_GetBufferData( Wellspring_TextBatch *textBatch, - Wellspring_Vertex *pVertexBuffer, - uint32_t *pIndexBuffer + Wellspring_Vertex **pVertexBuffer, + uint32_t *pVertexBufferLengthInBytes, + uint32_t **pIndexBuffer, + uint32_t *pIndexBufferLengthInBytes ) { Batch *batch = (Batch*) textBatch; - Wellspring_memcpy( - pVertexBuffer, - batch->vertices, - sizeof(Wellspring_Vertex) * batch->vertexCount - ); - Wellspring_memcpy( - pIndexBuffer, - batch->indices, - sizeof(uint32_t) * batch->indexCount - ); + *pVertexBuffer = batch->vertices; + *pVertexBufferLengthInBytes = batch->vertexCount * sizeof(Wellspring_Vertex); + *pIndexBuffer = batch->indices; + *pIndexBufferLengthInBytes = batch->indexCount * sizeof(uint32_t); } void Wellspring_DestroyTextBatch(Wellspring_TextBatch *textBatch)