Add rlCullDistance variables/getters and rlSetClipPlanes function (#3912)

The `RL_CULL_DISTANCE_` definition remains as the initial value
of the variables.

Basic usage can be:
```c
#include <raylib.h>
#include <rlgl.h>

rlSetClipPlanes(RL_CULL_DISTANCE_NEAR, MY_CULL_DISTANCE_FAR);

if (must_reset_clip_planes)
    rlSetClipPlanes(RL_CULL_DISTANCE_NEAR, RL_CULL_DISTANCE_FAR);
```
This commit is contained in:
KotzaBoss
2024-04-23 14:24:37 +02:00
committed by GitHub
parent d80febde7d
commit 4b0e25d3af
3 changed files with 32 additions and 8 deletions

View File

@@ -559,6 +559,10 @@ typedef enum {
extern "C" { // Prevents name mangling of functions
#endif
RLAPI void rlSetClipPlanes(double near, double far);
RLAPI double rlGetCullDistanceNear();
RLAPI double rlGetCullDistanceFar();
RLAPI void rlMatrixMode(int mode); // Choose the current matrix to be transformed
RLAPI void rlPushMatrix(void); // Push the current matrix to stack
RLAPI void rlPopMatrix(void); // Pop latest inserted matrix from stack
@@ -1083,6 +1087,10 @@ typedef void *(*rlglLoadProc)(const char *name); // OpenGL extension functions
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
static double rlCullDistanceNear = RL_CULL_DISTANCE_NEAR;
static double rlCullDistanceFar = RL_CULL_DISTANCE_FAR;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
static rlglData RLGL = { 0 };
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
@@ -1127,6 +1135,22 @@ static Matrix rlMatrixInvert(Matrix mat); // Invert provided m
// Module Functions Definition - Matrix operations
//----------------------------------------------------------------------------------
void rlSetClipPlanes(double near, double far)
{
rlCullDistanceNear = near;
rlCullDistanceFar = far;
}
double rlGetCullDistanceFar()
{
return rlCullDistanceFar;
}
double rlGetCullDistanceNear()
{
return rlCullDistanceNear;
}
#if defined(GRAPHICS_API_OPENGL_11)
// Fallback to OpenGL 1.1 function calls
//---------------------------------------