diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 6f060652f..b9a521bb0 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -989,6 +989,7 @@ models/models_rlgl_solar_system: models/models_rlgl_solar_system.c models/models_skybox: models/models_skybox.c $(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/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.fs@resources/shaders/glsl100/skybox.fs \ --preload-file models/resources/shaders/glsl100/cubemap.vs@resources/shaders/glsl100/cubemap.vs \ diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index 9fd9bcef0..f5872ec8a 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -12119,7 +12119,7 @@ }, { "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", "params": [ { @@ -12149,7 +12149,7 @@ }, { "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", "params": [ { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 59eb4b0fc..81dd7f932 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -8276,7 +8276,7 @@ return { }, { 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", params = { {type = "AudioStream", name = "stream"}, @@ -8294,7 +8294,7 @@ return { }, { 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", params = { {type = "AudioCallback", name = "processor"} diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index f0fb4eab4..c74a79a5f 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -4659,7 +4659,7 @@ Function 578: SetAudioStreamCallback() (2 input parameters) Function 579: AttachAudioStreamProcessor() (2 input parameters) Name: AttachAudioStreamProcessor 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[2]: processor (type: AudioCallback) Function 580: DetachAudioStreamProcessor() (2 input parameters) @@ -4671,7 +4671,7 @@ Function 580: DetachAudioStreamProcessor() (2 input parameters) Function 581: AttachAudioMixedProcessor() (1 input parameters) Name: AttachAudioMixedProcessor 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) Function 582: DetachAudioMixedProcessor() (1 input parameters) Name: DetachAudioMixedProcessor diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index 21e9d30e6..b7af0c41a 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -3104,7 +3104,7 @@ - + @@ -3112,7 +3112,7 @@ - + diff --git a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml index 3c642ad31..0fada9c4f 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +++ b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml @@ -3634,7 +3634,7 @@ - + @@ -3647,7 +3647,7 @@ - + diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index 2ff4c9cb3..c6b34b777 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -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 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 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 diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index 96ea367dc..1e726c455 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -460,17 +460,21 @@ int GetMonitorHeight(int monitor) } // Get selected monitor physical width in millimetres +// NOTE: It seems to return a slightly underestimated value on some devices int GetMonitorPhysicalWidth(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform"); - return 0; + int widthPixels = ANativeWindow_getWidth(platform.app->window); + float dpi = AConfiguration_getDensity(platform.app->config); + return (widthPixels/dpi)*25.4f; } // Get selected monitor physical height in millimetres +// NOTE: It seems to return a slightly underestimated value on some devices int GetMonitorPhysicalHeight(int monitor) { - TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform"); - return 0; + int heightPixels = ANativeWindow_getHeight(platform.app->window); + float dpi = AConfiguration_getDensity(platform.app->config); + return (heightPixels/dpi)*25.4f; } // Get selected monitor refresh rate @@ -497,8 +501,9 @@ Vector2 GetWindowPosition(void) // Get window scale DPI factor for current monitor Vector2 GetWindowScaleDPI(void) { - TRACELOG(LOG_WARNING, "GetWindowScaleDPI() not implemented on target platform"); - return (Vector2){ 1.0f, 1.0f }; + int density = AConfiguration_getDensity(platform.app->config); + float scale = (float)density/160; + return (Vector2){ scale, scale }; } // Set clipboard text content @@ -848,22 +853,20 @@ static int InitGraphicsDevice(void) TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); } - const EGLint framebufferAttribs[] = - { - EGL_RENDERABLE_TYPE, (rlGetVersion() == RL_OPENGL_ES_30)? EGL_OPENGL_ES3_BIT : EGL_OPENGL_ES2_BIT, // Type of context support + const EGLint framebufferAttribs[] = { + 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_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) //EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI) EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!) //EGL_STENCIL_SIZE, 8, // Stencil buffer size - EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA + EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs) EGL_NONE }; - const EGLint contextAttribs[] = - { + const EGLint contextAttribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 279f8c193..90b725ddb 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -86,6 +86,8 @@ #include "GLFW/glfw3native.h" // Required for: glfwGetCocoaWindow() #endif +#include // Required for: size_t + //---------------------------------------------------------------------------------- // 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 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 //---------------------------------------------------------------------------------- @@ -1287,21 +1294,38 @@ static void SetDimensionsFromMonitor(GLFWmonitor *monitor) 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 int InitPlatform(void) { 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); -*/ #if defined(__APPLE__) glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE); diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index 36d255bc0..abd696fb3 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -898,10 +898,9 @@ int InitPlatform(void) TRACELOG(LOG_INFO, "DISPLAY: Trying to enable MSAA x4"); } - const EGLint framebufferAttribs[] = - { - 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! + const EGLint framebufferAttribs[] = { + 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_RED_SIZE, 8, // RED color bit depth (alternative: 5) EGL_GREEN_SIZE, 8, // GREEN color bit depth (alternative: 6) EGL_BLUE_SIZE, 8, // BLUE color bit depth (alternative: 5) @@ -909,7 +908,7 @@ int InitPlatform(void) //EGL_TRANSPARENT_TYPE, EGL_NONE, // Request transparent framebuffer (EGL_TRANSPARENT_RGB does not work on RPI) EGL_DEPTH_SIZE, 16, // Depth buffer size (Required to use Depth testing!) //EGL_STENCIL_SIZE, 8, // Stencil buffer size - EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA + EGL_SAMPLE_BUFFERS, sampleBuffer, // Activate MSAA EGL_SAMPLES, samples, // 4x Antialiasing if activated (Free on MALI GPUs) EGL_NONE }; diff --git a/src/raylib.h b/src/raylib.h index b8428e7ac..7919db775 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -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 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 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 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) @@ -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 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 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 #if defined(__cplusplus) diff --git a/src/rcore.c b/src/rcore.c index 59b1b31c8..165c6f1fb 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -3696,7 +3696,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const } else { - if (TextFindIndex(filter, DIRECTORY_FILTER_TAG) >= 0) + if (strstr(filter, DIRECTORY_FILTER_TAG) != NULL) { strcpy(files->paths[files->count], path); files->count++; @@ -3762,7 +3762,7 @@ static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *fi } 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); files->count++; diff --git a/src/rmodels.c b/src/rmodels.c index 4928d4bf1..812823ac1 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -1307,7 +1307,7 @@ void UploadMesh(Mesh *mesh, bool dynamic) { // Default vertex attribute: normal // 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); rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_NORMAL); } @@ -1339,7 +1339,7 @@ void UploadMesh(Mesh *mesh, bool dynamic) { // Default vertex attribute: tangent // 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); rlDisableVertexAttribute(RL_DEFAULT_SHADER_ATTRIB_LOCATION_TANGENT); } diff --git a/src/rshapes.c b/src/rshapes.c index 704d74f40..9327a5543 100644 --- a/src/rshapes.c +++ b/src/rshapes.c @@ -2356,7 +2356,7 @@ bool CheckCollisionPointLine(Vector2 point, Vector2 p1, Vector2 p2, int threshol 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) { float dx = p1.x - p2.x; diff --git a/src/rtext.c b/src/rtext.c index 982402f54..0d06caa9a 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1540,21 +1540,21 @@ const char *TextSubtext(const char *text, int position, int length) if (position >= textLength) { - position = textLength - 1; - length = 0; + return buffer; //First char is already '\0' by memset } - 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) for (int c = 0 ; c < length ; c++) { - *(buffer + c) = *(text + position); - text++; + buffer[c] = text[position + c]; } - *(buffer + length) = '\0'; + buffer[length] = '\0'; return buffer; }