Skip to content

Commit 6aff001

Browse files
committed
add more sane rlgl state helper functions
1 parent 3c227c1 commit 6aff001

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Source/Renderer/raylib/rlgl.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ RLAPI void rlDrawRenderBatchActive(void); // Update and draw inter
731731
RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex
732732

733733
RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits
734+
RLAPI void rlClearActiveTextures();
735+
RLAPI void rlResetDrawDepth();
734736

735737
//------------------------------------------------------------------------------------------------------------------------
736738

@@ -781,7 +783,6 @@ RLAPI void rlSetUniformMatrices(int locIndex, const RLMatrix *mat, int count);
781783
RLAPI void rlSetUniformSampler(int locIndex, unsigned int textureId); // Set shader value sampler
782784
RLAPI void rlSetShader(unsigned int id, int *locs); // Set shader currently active (id and locations)
783785
RLAPI unsigned int rlGetShaderCurrent();
784-
785786
// Compute shader management
786787
RLAPI unsigned int rlLoadComputeShaderProgram(unsigned int shaderId); // Load compute shader program
787788
RLAPI void rlComputeShaderDispatch(unsigned int groupX, unsigned int groupY, unsigned int groupZ); // Dispatch compute shader (equivalent to *draw* for graphics pipeline)
@@ -1489,7 +1490,7 @@ void rlEnd(void)
14891490
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
14901491
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
14911492
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
1492-
RLGL.currentBatch->currentDepth += (1.0f/20000.0f);
1493+
RLGL.currentBatch->currentDepth += (1.0f/200000.0f);
14931494
}
14941495

14951496
// Define one vertex (position)
@@ -3102,8 +3103,6 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
31023103
// Reset vertex counter for next frame
31033104
RLGL.State.vertexCounter = 0;
31043105

3105-
// Reset depth for next draw
3106-
batch->currentDepth = -1.0f;
31073106

31083107
// Restore projection/modelview matrices
31093108
RLGL.State.projection = matProjection;
@@ -3117,9 +3116,6 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
31173116
batch->draws[i].textureId = RLGL.State.defaultTextureId;
31183117
}
31193118

3120-
// Reset active texture units for next batch
3121-
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0;
3122-
31233119
// Reset draws counter to one draw for the batch
31243120
batch->drawCounter = 1;
31253121
//------------------------------------------------------------------------------------------------------------
@@ -4401,6 +4397,19 @@ void rlSetUniformSampler(int locIndex, unsigned int textureId)
44014397
#endif
44024398
}
44034399

4400+
4401+
// Reset depth for next draw
4402+
void rlResetDrawDepth()
4403+
{
4404+
RLGL.currentBatch->currentDepth = -1.0f;
4405+
}
4406+
4407+
// Reset active texture units for next batch
4408+
void rlClearActiveTextures()
4409+
{
4410+
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) RLGL.State.activeTextureId[i] = 0;
4411+
}
4412+
44044413
// Set shader currently active (id and locations)
44054414
void rlSetShader(unsigned int id, int *locs)
44064415
{

0 commit comments

Comments
 (0)