[rcore] using win32_clipboard on platforms rlfw and rgfw
This commit is contained in:
parent
ba5045963e
commit
057f7dc98f
3 changed files with 70 additions and 35 deletions
|
|
@ -58,6 +58,7 @@
|
|||
#if defined(_WIN32)
|
||||
typedef void *PVOID;
|
||||
typedef PVOID HANDLE;
|
||||
#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
|
||||
|
|
@ -966,6 +967,33 @@ const char *GetClipboardText(void)
|
|||
return glfwGetClipboardString(platform.handle);
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = {0};
|
||||
unsigned long long int dataSize = 0;
|
||||
void* fileData = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
int width, height;
|
||||
fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize);
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_GLFW doesn't implement `GetClipboardImage` for this OS");
|
||||
#endif
|
||||
|
||||
if (fileData == NULL)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
|
||||
}
|
||||
else
|
||||
{
|
||||
image = LoadImageFromMemory(".bmp", fileData, dataSize);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
@ -1898,4 +1926,8 @@ static void JoystickCallback(int jid, int event)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||
# include "../external/win32_clipboard.h"
|
||||
#endif
|
||||
// EOF
|
||||
|
|
|
|||
|
|
@ -664,6 +664,43 @@ const char *GetClipboardText(void)
|
|||
return RGFW_readClipboard(NULL);
|
||||
}
|
||||
|
||||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
|
||||
#ifdef _WIN32
|
||||
# define WIN32_CLIPBOARD_IMPLEMENTATION
|
||||
# define WINUSER_ALREADY_INCLUDED
|
||||
# define WINBASE_ALREADY_INCLUDED
|
||||
# define WINGDI_ALREADY_INCLUDED
|
||||
# include "../external/win32_clipboard.h"
|
||||
#endif
|
||||
|
||||
// Get clipboard image
|
||||
Image GetClipboardImage(void)
|
||||
{
|
||||
Image image = {0};
|
||||
unsigned long long int dataSize = 0;
|
||||
void* fileData = NULL;
|
||||
|
||||
#ifdef _WIN32
|
||||
int width, height;
|
||||
fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize);
|
||||
#else
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_GLFW doesn't implement `GetClipboardImage` for this OS");
|
||||
#endif
|
||||
|
||||
if (fileData == NULL)
|
||||
{
|
||||
TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
|
||||
}
|
||||
else
|
||||
{
|
||||
image = LoadImageFromMemory(".bmp", fileData, dataSize);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
|
||||
// Show mouse cursor
|
||||
void ShowCursor(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -514,7 +514,7 @@ const char *TextFormat(const char *text, ...); // Formatting of tex
|
|||
|
||||
#if defined(SUPPORT_CLIPBOARD_IMAGE)
|
||||
#if !defined(SUPPORT_FILEFORMAT_BMP) || !defined(STBI_REQUIRED) || !defined(SUPPORT_MODULE_RTEXTURES)
|
||||
#error "To enabled SUPPORT_CLIPBOARD_IMAGE, it also needs SUPPORT_FILEFORMAT_BMP, SUPPORT_MODULE_RTEXTURES and STBI_REQUIRED to be defined"
|
||||
#error "To enabled SUPPORT_CLIPBOARD_IMAGE, it also needs SUPPORT_FILEFORMAT_BMP, SUPPORT_MODULE_RTEXTURES and STBI_REQUIRED to be defined. It should have been defined earlier"
|
||||
#endif
|
||||
#endif // SUPPORT_CLIPBOARD_IMAGE
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue