diff options
| author | raysan5 <[email protected]> | 2021-10-06 11:44:57 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2021-10-06 11:44:57 +0200 |
| commit | 8722ff7043a1c6844d59a9448e48aa5345c27058 (patch) | |
| tree | da3152b60c7e744b315a8e82d2ba2ab007c59189 /src | |
| parent | 8d7f97ee04c1908caf703771bd3576ef5f26b3c1 (diff) | |
| download | raylib-8722ff7043a1c6844d59a9448e48aa5345c27058.tar.gz raylib-8722ff7043a1c6844d59a9448e48aa5345c27058.zip | |
REVIEWED: `RLGL.State.vertexCounter` (See detailed comment)
`RLGL.State.vertexCounter` is a generic counter and it's reused for all `rlRenderBatch`, actually, once render batch is filled, required vertex count is provided through the draw calls, so, the total accumulated count of vertices is not directly registered inside the rlRenderBatch.
`RLGL.State.vertexCounter` keeps that count but one possible improvement(?) could be moving the `vertexCounter` inside `rlRenderBatch` to always keep a register of the total accumulated vertices in that batch (despite that info is provided by the accumulated `draws[i].vertexCount`.
Simplifying, `RLGL.State.vertexCounter = SUM(draws[i].vertexCount)`
The decision to move the counter out of `rlVertexBuffer` is to keep only the data that I think should belong to `rlVertexBuffer` and make it more generic, aligned with raylib `Mesh` structure.
The decision to not add it to `rlRenderBatch` is because it could contain multiple `rlVertexBuffer` and it would be confusing (because it would only register the count of the last filled one).
Diffstat (limited to 'src')
| -rw-r--r-- | src/rlgl.h | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -319,7 +319,7 @@ typedef struct rlDrawCall { // rlRenderBatch type typedef struct rlRenderBatch { - int bufferCount; // Number of vertex buffers (multi-buffering support) + int bufferCount; // Number of vertex buffers (multi-buffering support) int currentBuffer; // Current buffer tracking in case of multi-buffering rlVertexBuffer *vertexBuffer; // Dynamic buffer(s) for vertex data @@ -847,10 +847,10 @@ typedef struct rlglData { rlRenderBatch defaultBatch; // Default internal render batch struct { - int vertexCounter; // Vertex counter to process (and draw) from full buffer - float texcoordx, texcoordy; // Current active texture coordinate - float normalx, normaly, normalz; // Current active normal - unsigned char colorr, colorg, colorb, colora; // Current active color + int vertexCounter; // Current active render batch vertex counter (generic, used for all batches) + float texcoordx, texcoordy; // Current active texture coordinate (added on glVertex*()) + float normalx, normaly, normalz; // Current active normal (added on glVertex*()) + unsigned char colorr, colorg, colorb, colora; // Current active color (added on glVertex*()) int currentMatrixMode; // Current matrix mode Matrix *currentMatrix; // Current matrix pointer @@ -2468,7 +2468,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch) // Reset batch buffers //------------------------------------------------------------------------------------------------------------ - // Reset vertex counters for next frame + // Reset vertex counter for next frame RLGL.State.vertexCounter = 0; // Reset depth for next draw @@ -2534,7 +2534,7 @@ bool rlCheckRenderBatchLimit(int vCount) overflow = true; rlDrawRenderBatch(RLGL.currentBatch); // NOTE: Stereo rendering is checked inside - // restore state of last batch so we can continue adding vertices + // Restore state of last batch so we can continue adding vertices RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = currentMode; RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture; } |
