Merge branch 'raysan5:master' into pure

This commit is contained in:
Colleague Riley 2025-02-21 00:58:10 -05:00 committed by GitHub
commit 04b0db2319
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 79 additions and 52 deletions

View File

@ -989,6 +989,7 @@ models/models_rlgl_solar_system: models/models_rlgl_solar_system.c
models/models_skybox: models/models_skybox.c models/models_skybox: models/models_skybox.c
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 -sFORCE_FILESYSTEM=1 \ $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -sTOTAL_MEMORY=67108864 -sFORCE_FILESYSTEM=1 \
--preload-file models/resources/dresden_square_2k.hdr@resources/dresden_square_2k.hdr \ --preload-file models/resources/dresden_square_2k.hdr@resources/dresden_square_2k.hdr \
--preload-file models/resources/skybox.png@resources/skybox.png \
--preload-file models/resources/shaders/glsl100/skybox.vs@resources/shaders/glsl100/skybox.vs \ --preload-file models/resources/shaders/glsl100/skybox.vs@resources/shaders/glsl100/skybox.vs \
--preload-file models/resources/shaders/glsl100/skybox.fs@resources/shaders/glsl100/skybox.fs \ --preload-file models/resources/shaders/glsl100/skybox.fs@resources/shaders/glsl100/skybox.fs \
--preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \ --preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \

View File

@ -12119,7 +12119,7 @@
}, },
{ {
"name": "AttachAudioStreamProcessor", "name": "AttachAudioStreamProcessor",
"description": "Attach audio stream processor to stream, receives the samples as 'float'", "description": "Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)",
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {
@ -12149,7 +12149,7 @@
}, },
{ {
"name": "AttachAudioMixedProcessor", "name": "AttachAudioMixedProcessor",
"description": "Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'", "description": "Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)",
"returnType": "void", "returnType": "void",
"params": [ "params": [
{ {

View File

@ -8276,7 +8276,7 @@ return {
}, },
{ {
name = "AttachAudioStreamProcessor", name = "AttachAudioStreamProcessor",
description = "Attach audio stream processor to stream, receives the samples as 'float'", description = "Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)",
returnType = "void", returnType = "void",
params = { params = {
{type = "AudioStream", name = "stream"}, {type = "AudioStream", name = "stream"},
@ -8294,7 +8294,7 @@ return {
}, },
{ {
name = "AttachAudioMixedProcessor", name = "AttachAudioMixedProcessor",
description = "Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'", description = "Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)",
returnType = "void", returnType = "void",
params = { params = {
{type = "AudioCallback", name = "processor"} {type = "AudioCallback", name = "processor"}

View File

@ -4659,7 +4659,7 @@ Function 578: SetAudioStreamCallback() (2 input parameters)
Function 579: AttachAudioStreamProcessor() (2 input parameters) Function 579: AttachAudioStreamProcessor() (2 input parameters)
Name: AttachAudioStreamProcessor Name: AttachAudioStreamProcessor
Return type: void Return type: void
Description: Attach audio stream processor to stream, receives the samples as 'float' Description: Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)
Param[1]: stream (type: AudioStream) Param[1]: stream (type: AudioStream)
Param[2]: processor (type: AudioCallback) Param[2]: processor (type: AudioCallback)
Function 580: DetachAudioStreamProcessor() (2 input parameters) Function 580: DetachAudioStreamProcessor() (2 input parameters)
@ -4671,7 +4671,7 @@ Function 580: DetachAudioStreamProcessor() (2 input parameters)
Function 581: AttachAudioMixedProcessor() (1 input parameters) Function 581: AttachAudioMixedProcessor() (1 input parameters)
Name: AttachAudioMixedProcessor Name: AttachAudioMixedProcessor
Return type: void Return type: void
Description: Attach audio stream processor to the entire audio pipeline, receives the samples as 'float' Description: Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)
Param[1]: processor (type: AudioCallback) Param[1]: processor (type: AudioCallback)
Function 582: DetachAudioMixedProcessor() (1 input parameters) Function 582: DetachAudioMixedProcessor() (1 input parameters)
Name: DetachAudioMixedProcessor Name: DetachAudioMixedProcessor

View File

@ -3104,7 +3104,7 @@
<Param type="AudioStream" name="stream" desc="" /> <Param type="AudioStream" name="stream" desc="" />
<Param type="AudioCallback" name="callback" desc="" /> <Param type="AudioCallback" name="callback" desc="" />
</Function> </Function>
<Function name="AttachAudioStreamProcessor" retType="void" paramCount="2" desc="Attach audio stream processor to stream, receives the samples as 'float'"> <Function name="AttachAudioStreamProcessor" retType="void" paramCount="2" desc="Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)">
<Param type="AudioStream" name="stream" desc="" /> <Param type="AudioStream" name="stream" desc="" />
<Param type="AudioCallback" name="processor" desc="" /> <Param type="AudioCallback" name="processor" desc="" />
</Function> </Function>
@ -3112,7 +3112,7 @@
<Param type="AudioStream" name="stream" desc="" /> <Param type="AudioStream" name="stream" desc="" />
<Param type="AudioCallback" name="processor" desc="" /> <Param type="AudioCallback" name="processor" desc="" />
</Function> </Function>
<Function name="AttachAudioMixedProcessor" retType="void" paramCount="1" desc="Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'"> <Function name="AttachAudioMixedProcessor" retType="void" paramCount="1" desc="Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)">
<Param type="AudioCallback" name="processor" desc="" /> <Param type="AudioCallback" name="processor" desc="" />
</Function> </Function>
<Function name="DetachAudioMixedProcessor" retType="void" paramCount="1" desc="Detach audio stream processor from the entire audio pipeline"> <Function name="DetachAudioMixedProcessor" retType="void" paramCount="1" desc="Detach audio stream processor from the entire audio pipeline">

View File

@ -3634,7 +3634,7 @@
</KeyWord> </KeyWord>
<KeyWord name="AttachAudioStreamProcessor" func="yes"> <KeyWord name="AttachAudioStreamProcessor" func="yes">
<Overload retVal="void" descr="Attach audio stream processor to stream, receives the samples as 'float'"> <Overload retVal="void" descr="Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)">
<Param name="AudioStream stream" /> <Param name="AudioStream stream" />
<Param name="AudioCallback processor" /> <Param name="AudioCallback processor" />
</Overload> </Overload>
@ -3647,7 +3647,7 @@
</KeyWord> </KeyWord>
<KeyWord name="AttachAudioMixedProcessor" func="yes"> <KeyWord name="AttachAudioMixedProcessor" func="yes">
<Overload retVal="void" descr="Attach audio stream processor to the entire audio pipeline, receives the samples as 'float'"> <Overload retVal="void" descr="Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)">
<Param name="AudioCallback processor" /> <Param name="AudioCallback processor" />
</Overload> </Overload>
</KeyWord> </KeyWord>

View File

@ -734,9 +734,9 @@ RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as 'float' RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)
RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as 'float' RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)
RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline

View File

@ -460,17 +460,21 @@ int GetMonitorHeight(int monitor)
} }
// Get selected monitor physical width in millimetres // Get selected monitor physical width in millimetres
// NOTE: It seems to return a slightly underestimated value on some devices
int GetMonitorPhysicalWidth(int monitor) int GetMonitorPhysicalWidth(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform"); int widthPixels = ANativeWindow_getWidth(platform.app->window);
return 0; float dpi = AConfiguration_getDensity(platform.app->config);
return (widthPixels/dpi)*25.4f;
} }
// Get selected monitor physical height in millimetres // Get selected monitor physical height in millimetres
// NOTE: It seems to return a slightly underestimated value on some devices
int GetMonitorPhysicalHeight(int monitor) int GetMonitorPhysicalHeight(int monitor)
{ {
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform"); int heightPixels = ANativeWindow_getHeight(platform.app->window);
return 0; float dpi = AConfiguration_getDensity(platform.app->config);
return (heightPixels/dpi)*25.4f;
} }
// Get selected monitor refresh rate // Get selected monitor refresh rate
@ -497,8 +501,9 @@ Vector2 GetWindowPosition(void)
// Get window scale DPI factor for current monitor // Get window scale DPI factor for current monitor
Vector2 GetWindowScaleDPI(void) Vector2 GetWindowScaleDPI(void)
{ {
TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); int density = AConfiguration_getDensity(platform.app->config);
return (Vector2){ 1.0f, 1.0f }; float scale = (float)density/160;
return (Vector2){ scale, scale };
} }
// Set clipboard text content // Set clipboard text content
@ -848,8 +853,7 @@ static int InitGraphicsDevice(void)
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
} }
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] = {
{
EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5) EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5)
EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6)
@ -862,8 +866,7 @@ static int InitGraphicsDevice(void)
EGL_NONE EGL_NONE
}; };
const EGLint contextAttribs[] = const EGLint contextAttribs[] = {
{
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE EGL_NONE
}; };

View File

@ -86,6 +86,8 @@
#include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow() #include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow()
#endif #endif
#include <stddef.h> // Required for: size_t
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -127,6 +129,11 @@ static void MouseScrollCallback(GLFWwindow *window, double xoffset, double yoffs
static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area static void CursorEnterCallback(GLFWwindow *window, int enter); // GLFW3 Cursor Enter Callback, cursor enters client area
static void JoystickCallback(int jid, int event); // GLFW3 Joystick Connected/Disconnected Callback static void JoystickCallback(int jid, int event); // GLFW3 Joystick Connected/Disconnected Callback
// Wrappers used by glfwInitAllocator
static void* AllocateWrapper(size_t size, void* user); // GLFW3 GLFWallocatefun, wrapps around RL_MALLOC macro
static void* ReallocateWrapper(void* block, size_t size, void* user); // GLFW3 GLFWreallocatefun, wrapps around RL_MALLOC macro
static void DeallocateWrapper(void* block, void* user); // GLFW3 GLFWdeallocatefun, wraps around RL_FREE macro
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -1287,21 +1294,38 @@ static void SetDimensionsFromMonitor(GLFWmonitor *monitor)
if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height; if (CORE.Window.screen.height == 0) CORE.Window.screen.height = CORE.Window.display.height;
} }
// Function wrappers around RL_*alloc macros, used by glfwInitAllocator() inside of InitPlatform()
// We need to provide these because GLFWallocator expects function pointers with specific signatures.
// Similar wrappers exist in utils.c but we cannot reuse them here due to declaration mismatch.
// https://www.glfw.org/docs/latest/intro_guide.html#init_allocator
static void* AllocateWrapper(size_t size, void* user)
{
(void)user;
return RL_MALLOC(size);
}
static void* ReallocateWrapper(void* block, size_t size, void* user)
{
(void)user;
return RL_REALLOC(block, size);
}
static void DeallocateWrapper(void* block, void* user)
{
(void)user;
RL_FREE(block);
}
// Initialize platform: graphics, inputs and more // Initialize platform: graphics, inputs and more
int InitPlatform(void) int InitPlatform(void)
{ {
glfwSetErrorCallback(ErrorCallback); glfwSetErrorCallback(ErrorCallback);
/*
// TODO: Setup GLFW custom allocators to match raylib ones
const GLFWallocator allocator = {
.allocate = MemAlloc,
.deallocate = MemFree,
.reallocate = MemRealloc,
.user = NULL
};
const GLFWallocator allocator = {
.allocate = AllocateWrapper,
.deallocate = DeallocateWrapper,
.reallocate = ReallocateWrapper,
.user = NULL, // RL_*ALLOC macros are not capable of handling user-provided data
};
glfwInitAllocator(&allocator); glfwInitAllocator(&allocator);
*/
#if defined(__APPLE__) #if defined(__APPLE__)
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE); glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE);

View File

@ -898,8 +898,7 @@ int InitPlatform(void)
TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4");
} }
const EGLint framebufferAttribs[] = const EGLint framebufferAttribs[] = {
{
EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android! EGL_SURFACE_TYPE, EGL_WINDOW_BIT, // Don't use it on Android!
EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5) EGL_RED_SIZE, 8, // RED color bit depth (alternative: 5)

View File

@ -1365,7 +1365,7 @@ RLAPI void ImageAlphaPremultiply(Image *image);
RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation RLAPI void ImageBlurGaussian(Image *image, int blurSize); // Apply Gaussian blur using a box blur approximation
RLAPI void ImageKernelConvolution(Image *image, const float *kernel, int kernelSize); // Apply custom square convolution kernel to image RLAPI void ImageKernelConvolution(Image *image, const float *kernel, int kernelSize); // Apply custom square convolution kernel to image
RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm) RLAPI void ImageResize(Image *image, int newWidth, int newHeight); // Resize image (Bicubic scaling algorithm)
RLAPI void ImageResizeNN(Image *image, int newWidth,int newHeight); // Resize image (Nearest-Neighbor scaling algorithm) RLAPI void ImageResizeNN(Image *image, int newWidth, int newHeight); // Resize image (Nearest-Neighbor scaling algorithm)
RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color RLAPI void ImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color fill); // Resize canvas and fill with color
RLAPI void ImageMipmaps(Image *image); // Compute all mipmap levels for a provided image RLAPI void ImageMipmaps(Image *image); // Compute all mipmap levels for a provided image
RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) RLAPI void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering)
@ -1701,10 +1701,10 @@ RLAPI void SetAudioStreamPan(AudioStream stream, float pan); // Set pan
RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams RLAPI void SetAudioStreamBufferSizeDefault(int size); // Default size for new audio streams
RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data
RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives the samples as 'float' RLAPI void AttachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Attach audio stream processor to stream, receives frames x 2 samples as 'float' (stereo)
RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream RLAPI void DetachAudioStreamProcessor(AudioStream stream, AudioCallback processor); // Detach audio stream processor from stream
RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives the samples as 'float' RLAPI void AttachAudioMixedProcessor(AudioCallback processor); // Attach audio stream processor to the entire audio pipeline, receives frames x 2 samples as 'float' (stereo)
RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline RLAPI void DetachAudioMixedProcessor(AudioCallback processor); // Detach audio stream processor from the entire audio pipeline
#if defined(__cplusplus) #if defined(__cplusplus)

View File

@ -3696,7 +3696,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
} }
else else
{ {
if (TextFindIndex(filter, DIRECTORY_FILTER_TAG) >= 0) if (strstr(filter, DIRECTORY_FILTER_TAG) != NULL)
{ {
strcpy(files->paths[files->count], path); strcpy(files->paths[files->count], path);
files->count++; files->count++;
@ -3762,7 +3762,7 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi
} }
else else
{ {
if ((filter != NULL) && (TextFindIndex(filter, DIRECTORY_FILTER_TAG) >= 0)) if ((filter != NULL) && (strstr(filter, DIRECTORY_FILTER_TAG) != NULL))
{ {
strcpy(files->paths[files->count], path); strcpy(files->paths[files->count], path);
files->count++; files->count++;

View File

@ -1307,7 +1307,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
{ {
// Default vertex attribute: normal // Default vertex attribute: normal
// WARNING: Default value provided to shader if location available // WARNING: Default value provided to shader if location available
float value[3] = { 1.0f, 1.0f, 1.0f }; float value[3] = { 0.0f, 0.0f, 1.0f };
rlSetVertexAttributeDefault(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, value, SHADER_ATTRIB_VEC3, 3); rlSetVertexAttributeDefault(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL, value, SHADER_ATTRIB_VEC3, 3);
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL); rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL);
} }
@ -1339,7 +1339,7 @@ void UploadMesh(Mesh *mesh, bool dynamic)
{ {
// Default vertex attribute: tangent // Default vertex attribute: tangent
// WARNING: Default value provided to shader if location available // WARNING: Default value provided to shader if location available
float value[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; float value[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
rlSetVertexAttributeDefault(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, value, SHADER_ATTRIB_VEC4, 4); rlSetVertexAttributeDefault(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT, value, SHADER_ATTRIB_VEC4, 4);
rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT); rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT);
} }

View File

@ -2356,7 +2356,7 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol
return collision; return collision;
} }
// Check if circle collides with a line created betweeen two points [p1] and [p2] // Check if circle collides with a line created between two points [p1] and [p2]
RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2) RLAPI bool CheckCollisionCircleLine(Vector2 center, float radius, Vector2 p1, Vector2 p2)
{ {
float dx = p1.x - p2.x; float dx = p1.x - p2.x;

View File

@ -1540,21 +1540,21 @@ const char *TextSubtext(const char *text, int position, int length)
if (position >= textLength) if (position >= textLength)
{ {
position = textLength - 1; return buffer; //First char is already '\0' by memset
length = 0;
} }
if (length >= textLength) length = textLength; int maxLength = textLength - position;
if (length > maxLength) length = maxLength;
if (length >= MAX_TEXT_BUFFER_LENGTH) length = MAX_TEXT_BUFFER_LENGTH - 1;
// NOTE: Alternative: memcpy(buffer, text + position, length) // NOTE: Alternative: memcpy(buffer, text + position, length)
for (int c = 0 ; c < length ; c++) for (int c = 0 ; c < length ; c++)
{ {
*(buffer + c) = *(text + position); buffer[c] = text[position + c];
text++;
} }
*(buffer + length) = '\0'; buffer[length] = '\0';
return buffer; return buffer;
} }