added a way to get information about the amount of draw calls
its under the custom frame control features as its done automatically per default if no custom frame control is chosen accessor exist so it can be adapted to custom frame control
This commit is contained in:
parent
93a1e75741
commit
2ad2ac55ca
|
|
@ -1088,6 +1088,7 @@ RLAPI int GetFPS(void); // Get current
|
||||||
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
|
RLAPI void SwapScreenBuffer(void); // Swap back buffer with front buffer (screen drawing)
|
||||||
RLAPI void PollInputEvents(void); // Register all input events
|
RLAPI void PollInputEvents(void); // Register all input events
|
||||||
RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)
|
RLAPI void WaitTime(double seconds); // Wait for some time (halt program execution)
|
||||||
|
RLAPI int GetDrawCalls(void); // Returns draw calls made during the last tick
|
||||||
|
|
||||||
// Random values generation functions
|
// Random values generation functions
|
||||||
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
|
RLAPI void SetRandomSeed(unsigned int seed); // Set the seed for the random number generator
|
||||||
|
|
@ -1710,4 +1711,4 @@ RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio s
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // RAYLIB_H
|
#endif // RAYLIB_H
|
||||||
10
src/rcore.c
10
src/rcore.c
|
|
@ -955,6 +955,7 @@ void EndDrawing(void)
|
||||||
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
|
CORE.Time.frame += waitTime; // Total frame time: update + draw + wait
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rlSwapDrawCallsCounter();
|
||||||
PollInputEvents(); // Poll user events (before next frame update)
|
PollInputEvents(); // Poll user events (before next frame update)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -1754,6 +1755,13 @@ void WaitTime(double seconds)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the draw calls of the previous tick
|
||||||
|
// This is because we don't know the full count until the current tick ends
|
||||||
|
int GetDrawCalls(void)
|
||||||
|
{
|
||||||
|
return rlGetPreviousDrawCalls();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition: Misc
|
// Module Functions Definition: Misc
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
@ -4076,4 +4084,4 @@ const char *TextFormat(const char *text, ...)
|
||||||
return currentBuffer;
|
return currentBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !SUPPORT_MODULE_RTEXT
|
#endif // !SUPPORT_MODULE_RTEXT
|
||||||
22
src/rlgl.h
22
src/rlgl.h
|
|
@ -718,6 +718,8 @@ RLAPI int rlGetFramebufferHeight(void); // Get default framebuff
|
||||||
RLAPI unsigned int rlGetTextureIdDefault(void); // Get default texture id
|
RLAPI unsigned int rlGetTextureIdDefault(void); // Get default texture id
|
||||||
RLAPI unsigned int rlGetShaderIdDefault(void); // Get default shader id
|
RLAPI unsigned int rlGetShaderIdDefault(void); // Get default shader id
|
||||||
RLAPI int *rlGetShaderLocsDefault(void); // Get default shader locations
|
RLAPI int *rlGetShaderLocsDefault(void); // Get default shader locations
|
||||||
|
RLAPI int rlGetPreviousDrawCalls(void); // Get previous ticks draw calls
|
||||||
|
RLAPI void rlSwapDrawCallsCounter(void); // Swap previous with current draw calls (marks end of a tick)
|
||||||
|
|
||||||
// Render batch management
|
// Render batch management
|
||||||
// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
|
// NOTE: rlgl provides a default render batch to behave like OpenGL 1.1 immediate mode
|
||||||
|
|
@ -1087,6 +1089,8 @@ typedef struct rlglData {
|
||||||
|
|
||||||
int framebufferWidth; // Current framebuffer width
|
int framebufferWidth; // Current framebuffer width
|
||||||
int framebufferHeight; // Current framebuffer height
|
int framebufferHeight; // Current framebuffer height
|
||||||
|
int currentDrawCalls; // Draw calls made in the current tick (might be incomplete)
|
||||||
|
int previousDrawCalls; // Draw calls made during the last tick
|
||||||
|
|
||||||
} State; // Renderer state
|
} State; // Renderer state
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -1110,6 +1114,7 @@ typedef struct rlglData {
|
||||||
float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f)
|
float maxAnisotropyLevel; // Maximum anisotropy level supported (minimum is 2.0f)
|
||||||
int maxDepthBits; // Maximum bits for depth component
|
int maxDepthBits; // Maximum bits for depth component
|
||||||
|
|
||||||
|
|
||||||
} ExtSupported; // Extensions supported flags
|
} ExtSupported; // Extensions supported flags
|
||||||
} rlglData;
|
} rlglData;
|
||||||
|
|
||||||
|
|
@ -2724,6 +2729,20 @@ int *rlGetShaderLocsDefault(void)
|
||||||
return locs;
|
return locs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get previous ticks draw calls
|
||||||
|
RLAPI int rlGetPreviousDrawCalls(void)
|
||||||
|
{
|
||||||
|
return RLGL.State.previousDrawCalls;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Swap previous with current draw calls (marks end of a tick)
|
||||||
|
RLAPI void rlSwapDrawCallsCounter(void)
|
||||||
|
{
|
||||||
|
RLGL.State.previousDrawCalls = RLGL.State.currentDrawCalls;
|
||||||
|
RLGL.State.currentDrawCalls = 0; // Reset counter
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Render batch management
|
// Render batch management
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
// Load render batch
|
// Load render batch
|
||||||
|
|
@ -2983,6 +3002,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
|
||||||
// Draw buffers
|
// Draw buffers
|
||||||
if (RLGL.State.vertexCounter > 0)
|
if (RLGL.State.vertexCounter > 0)
|
||||||
{
|
{
|
||||||
|
RLGL.State.currentDrawCalls++;
|
||||||
// Set current shader and upload current MVP matrix
|
// Set current shader and upload current MVP matrix
|
||||||
glUseProgram(RLGL.State.currentShaderId);
|
glUseProgram(RLGL.State.currentShaderId);
|
||||||
|
|
||||||
|
|
@ -5266,4 +5286,4 @@ static Matrix rlMatrixInvert(Matrix mat)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // RLGL_IMPLEMENTATION
|
#endif // RLGL_IMPLEMENTATION
|
||||||
Loading…
Reference in New Issue
Block a user