C++ compiler support v2 (#5252)

* Get C++ compilers working

* Fix Formatting
This commit is contained in:
Saksham Goyal
2025-10-15 13:11:44 -04:00
committed by GitHub
parent 17bc628fd9
commit adfe2c1704
20 changed files with 106 additions and 97 deletions

View File

@ -56,10 +56,12 @@
// Support retrieving native window handlers
#if defined(_WIN32)
typedef void *PVOID;
typedef PVOID HANDLE;
#if !defined(HWND) && !defined(_MSVC_LANG)
#define HWND void*
#elif !defined(HWND) && defined(_MSVC_LANG)
typedef struct HWND__ *HWND;
#endif
#include "../external/win32_clipboard.h"
typedef HANDLE HWND;
#define GLFW_EXPOSE_NATIVE_WIN32
#define GLFW_NATIVE_INCLUDE_NONE // To avoid some symbols re-definition in windows.h
#include "GLFW/glfw3native.h"
@ -1031,7 +1033,7 @@ Image GetClipboardImage(void)
fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize);
if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
else image = LoadImageFromMemory(".bmp", fileData, (int)dataSize);
else image = LoadImageFromMemory(".bmp", (const unsigned char*)fileData, (int)dataSize);
#else
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
#endif
@ -1353,8 +1355,8 @@ int InitPlatform(void)
const GLFWallocator allocator = {
.allocate = AllocateWrapper,
.deallocate = DeallocateWrapper,
.reallocate = ReallocateWrapper,
.deallocate = DeallocateWrapper,
.user = NULL, // RL_*ALLOC macros are not capable of handling user-provided data
};

View File

@ -83,7 +83,14 @@ void CloseWindow(void);
#undef MAX_PATH
#if defined(__cplusplus)
extern "C" {
#endif
__declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int CodePage, unsigned long dwFlags, const char *lpMultiByteStr, int cbMultiByte, wchar_t *lpWideCharStr, int cchWideChar);
#if defined(__cplusplus)
}
#endif
#endif
#if defined(__APPLE__)
@ -564,7 +571,7 @@ int RGFW_formatToChannels(int format)
// Set icon for window
void SetWindowIcon(Image image)
{
RGFW_window_setIcon(platform.window, image.data, RGFW_AREA(image.width, image.height), RGFW_formatToChannels(image.format));
RGFW_window_setIcon(platform.window, (u8 *)image.data, RGFW_AREA(image.width, image.height), RGFW_formatToChannels(image.format));
}
// Set icon for window
@ -585,8 +592,8 @@ void SetWindowIcons(Image *images, int count)
if ((smallIcon == NULL) || ((images[i].width < smallIcon->width) && (images[i].height > smallIcon->height))) smallIcon = &images[i];
}
if (smallIcon != NULL) RGFW_window_setIconEx(platform.window, smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow);
if (bigIcon != NULL) RGFW_window_setIconEx(platform.window, bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar);
if (smallIcon != NULL) RGFW_window_setIconEx(platform.window, (u8 *)smallIcon->data, RGFW_AREA(smallIcon->width, smallIcon->height), RGFW_formatToChannels(smallIcon->format), RGFW_iconWindow);
if (bigIcon != NULL) RGFW_window_setIconEx(platform.window, (u8 *)bigIcon->data, RGFW_AREA(bigIcon->width, bigIcon->height), RGFW_formatToChannels(bigIcon->format), RGFW_iconTaskbar);
}
}
@ -805,7 +812,7 @@ Image GetClipboardImage(void)
fileData = (void *)Win32GetClipboardImageData(&width, &height, &dataSize);
if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data");
else image = LoadImageFromMemory(".bmp", fileData, dataSize);
else image = LoadImageFromMemory(".bmp", (const unsigned char *)fileData, dataSize);
#else
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement GetClipboardImage() for this OS");
#endif
@ -1418,7 +1425,8 @@ void ClosePlatform(void)
// Keycode mapping
static KeyboardKey ConvertScancodeToKey(u32 keycode)
{
if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0;
if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return KEY_NULL;
return keyMappingRGFW[keycode];
return (KeyboardKey)keyMappingRGFW[keycode];
}