4 Commits

Author SHA1 Message Date
d768dae402 [build] Shift __cplusplus check to a higher level for bool type define (#5804)
* Adds a missing macro definition check

* Shifts __cplusplus check to a higher level for bool define

* Copy same change to rgestures.h and rlgl.h

* Fixes float comparison issues in raymath functions

* Revert "Fixes float comparison issues in raymath functions"

This reverts commit a266d0bbaa.
2026-04-29 18:02:49 +02:00
d580c47504 [raymath.h] Add missing (float * Vector) operator overloads (#5815) 2026-04-29 17:49:23 +02:00
7b7ded566c Fix directory navigation in core_directory_files (#5823)
Co-authored-by: zhanlong9890 <lichuang59559890@gmail.com>
2026-04-29 17:45:25 +02:00
Ray
d9427b1e6f REVIEWED: Avoid static variable floating around and include it to PlatformData struct 2026-04-29 17:42:51 +02:00
6 changed files with 55 additions and 18 deletions

View File

@ -21,6 +21,7 @@
#include "raygui.h" // Required for GUI controls #include "raygui.h" // Required for GUI controls
#define MAX_FILEPATH_SIZE 1024 #define MAX_FILEPATH_SIZE 1024
#define FILE_FILTER "DIRS*;.png;.c"
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -41,7 +42,7 @@ int main(void)
// NOTE: LoadDirectoryFiles() loads files and directories by default, // NOTE: LoadDirectoryFiles() loads files and directories by default,
// use LoadDirectoryFilesEx() for custom filters and recursive directories loading // use LoadDirectoryFilesEx() for custom filters and recursive directories loading
//FilePathList files = LoadDirectoryFiles(directory); //FilePathList files = LoadDirectoryFiles(directory);
FilePathList files = LoadDirectoryFilesEx(directory, ".png;.c", false); FilePathList files = LoadDirectoryFilesEx(directory, FILE_FILTER, false);
int btnBackPressed = false; int btnBackPressed = false;
@ -61,7 +62,22 @@ int main(void)
{ {
TextCopy(directory, GetPrevDirectoryPath(directory)); TextCopy(directory, GetPrevDirectoryPath(directory));
UnloadDirectoryFiles(files); UnloadDirectoryFiles(files);
files = LoadDirectoryFiles(directory); files = LoadDirectoryFilesEx(directory, FILE_FILTER, false);
listScrollIndex = 0;
listItemActive = -1;
listItemFocused = -1;
}
if ((listItemActive >= 0) && (listItemActive < (int)files.count) && DirectoryExists(files.paths[listItemActive]))
{
TextCopy(directory, files.paths[listItemActive]);
UnloadDirectoryFiles(files);
files = LoadDirectoryFilesEx(directory, FILE_FILTER, false);
listScrollIndex = 0;
listItemActive = -1;
listItemFocused = -1;
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------

View File

@ -111,6 +111,12 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
typedef struct { typedef struct {
GLFWwindow *handle; // GLFW window handle (graphic device) GLFWwindow *handle; // GLFW window handle (graphic device)
#if defined(__linux__) && defined(_GLFW_X11)
// Local storage for the window handle returned by glfwGetX11Window
// This is needed as X11 handles are integers and may not fit inside a pointer depending on platform
// Storing the handle locally and returning a pointer in GetWindowHandle allows the code to work regardless of pointer width
XID windowHandleX11;
#endif
} PlatformData; } PlatformData;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -755,12 +761,6 @@ void SetWindowFocused(void)
glfwFocusWindow(platform.handle); glfwFocusWindow(platform.handle);
} }
#if defined(__linux__) && defined(_GLFW_X11)
// Local storage for the window handle returned by glfwGetX11Window
// This is needed as X11 handles are integers and may not fit inside a pointer depending on platform
// Storing the handle locally and returning a pointer in GetWindowHandle allows the code to work regardless of pointer width
static XID X11WindowHandle;
#endif
// Get native window handle // Get native window handle
void *GetWindowHandle(void) void *GetWindowHandle(void)
{ {
@ -778,17 +778,16 @@ void *GetWindowHandle(void)
} }
else else
{ {
X11WindowHandle = glfwGetX11Window(platform.handle); platform.windowHandleX11 = glfwGetX11Window(platform.handle);
return &X11WindowHandle; return &platform.windowHandleX11;
} }
#else #else
return glfwGetWaylandWindow(platform.handle); return glfwGetWaylandWindow(platform.handle);
#endif #endif
#elif defined(_GLFW_X11) #elif defined(_GLFW_X11)
// Store the window handle localy and return a pointer to the variable instead // Store the window handle localy and return a pointer to the variable instead
// Reasoning detailed in the declaration of X11WindowHandle platform.windowHandleX11 = glfwGetX11Window(platform.handle);
X11WindowHandle = glfwGetX11Window(platform.handle); return &platform.windowHandleX11;
return &X11WindowHandle;
#endif #endif
#endif #endif
#if defined(__APPLE__) #if defined(__APPLE__)

View File

@ -203,12 +203,14 @@
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Boolean type // Boolean type
#if !defined(__cplusplus)
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
#include <stdbool.h> #include <stdbool.h>
#elif !defined(__cplusplus) && !defined(bool) #elif !defined(bool)
typedef enum bool { false = 0, true = !false } bool; typedef enum bool { false = 0, true = !false } bool;
#define RL_BOOL_TYPE #define RL_BOOL_TYPE
#endif #endif
#endif
// Vector2, 2 components // Vector2, 2 components
typedef struct Vector2 { typedef struct Vector2 {

View File

@ -2802,6 +2802,11 @@ inline const Vector2& operator -= (Vector2& lhs, const Vector2& rhs)
return lhs; return lhs;
} }
inline Vector2 operator * (const float& lhs, const Vector2& rhs)
{
return Vector2Scale(rhs, lhs);
}
inline Vector2 operator * (const Vector2& lhs, const float& rhs) inline Vector2 operator * (const Vector2& lhs, const float& rhs)
{ {
return Vector2Scale(lhs, rhs); return Vector2Scale(lhs, rhs);
@ -2896,6 +2901,11 @@ inline const Vector3& operator -= (Vector3& lhs, const Vector3& rhs)
return lhs; return lhs;
} }
inline Vector3 operator * (const float& lhs, const Vector3& rhs)
{
return Vector3Scale(rhs, lhs);
}
inline Vector3 operator * (const Vector3& lhs, const float& rhs) inline Vector3 operator * (const Vector3& lhs, const float& rhs)
{ {
return Vector3Scale(lhs, rhs); return Vector3Scale(lhs, rhs);
@ -2991,6 +3001,11 @@ inline const Vector4& operator -= (Vector4& lhs, const Vector4& rhs)
return lhs; return lhs;
} }
inline Vector4 operator * (const float& lhs, const Vector4& rhs)
{
return Vector4Scale(rhs, lhs);
}
inline Vector4 operator * (const Vector4& lhs, const float& rhs) inline Vector4 operator * (const Vector4& lhs, const float& rhs)
{ {
return Vector4Scale(lhs, rhs); return Vector4Scale(lhs, rhs);

View File

@ -59,10 +59,13 @@
// NOTE: Below types are required for standalone usage // NOTE: Below types are required for standalone usage
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Boolean type // Boolean type
#if !defined(__cplusplus)
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
#include <stdbool.h> #include <stdbool.h>
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) #elif !defined(bool)
typedef enum bool { false = 0, true = !false } bool; typedef enum bool { false = 0, true = !false } bool;
#define RL_BOOL_TYPE
#endif
#endif #endif
#if !defined(RL_VECTOR2_TYPE) #if !defined(RL_VECTOR2_TYPE)

View File

@ -358,11 +358,13 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Types and Structures Definition // Types and Structures Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if !defined(__cplusplus)
#if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800)
#include <stdbool.h> #include <stdbool.h>
#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) #elif !defined(bool)
// Boolean type
typedef enum bool { false = 0, true = !false } bool; typedef enum bool { false = 0, true = !false } bool;
#define RL_BOOL_TYPE
#endif
#endif #endif
#if !defined(RL_MATRIX_TYPE) #if !defined(RL_MATRIX_TYPE)