get pointers instead of copying data

main
cosmonaut 2022-04-12 16:38:09 -07:00
parent b92b8da6e4
commit e93662f231
2 changed files with 19 additions and 27 deletions

View File

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

View File

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