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).
This commit is contained in:
parent
8d7f97ee04
commit
8722ff7043
1 changed files with 7 additions and 7 deletions
14
src/rlgl.h
14
src/rlgl.h
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue