Skip to content

Commit

Permalink
try updating
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Nov 19, 2024
1 parent a15f1dd commit 5354e55
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 159 deletions.
2 changes: 1 addition & 1 deletion src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import std/[assertions, paths]
const raylibDir = currentSourcePath().Path.parentDir / Path"raylib"

{.passC: "-I" & raylibDir.string.}
{.passC: "-I" & string(raylibDir / Path"external").}
# {.passC: "-I" & string(raylibDir / Path"external").}
{.passC: "-I" & string(raylibDir / Path"external/glfw/include").}
{.passC: "-I" & string(raylibDir / Path"external/glfw/deps/mingw").}
{.passC: "-Wall -D_GNU_SOURCE -Wno-missing-braces -Werror=pointer-arith".}
Expand Down
51 changes: 24 additions & 27 deletions src/raylib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,30 @@
// Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1

// Support for clipboard image loading
// NOTE: Only working on SDL3, GLFW (Windows) and RGFW (Windows)
#define SUPPORT_CLIPBOARD_IMAGE 1

// NOTE: Clipboard image loading requires support for some image file formats
// TODO: Those defines should probably be removed from here, I prefer to let the user manage them
#if defined(SUPPORT_CLIPBOARD_IMAGE)
#ifndef SUPPORT_MODULE_RTEXTURES
#define SUPPORT_MODULE_RTEXTURES 1
#endif
#ifndef STBI_REQUIRED
#define STBI_REQUIRED
#endif
#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
#define SUPPORT_FILEFORMAT_BMP 1
#endif
#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
#define SUPPORT_FILEFORMAT_PNG 1
#endif
#ifndef SUPPORT_FILEFORMAT_JPG
#define SUPPORT_FILEFORMAT_JPG 1
#endif
#endif


// rcore: Configuration values
//------------------------------------------------------------------------------------
Expand Down Expand Up @@ -273,31 +297,4 @@
//------------------------------------------------------------------------------------
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message


// Enable partial support for clipboard image, only working on SDL3 or
// being on both Windows OS + GLFW or Windows OS + RGFW
#define SUPPORT_CLIPBOARD_IMAGE 1

#if defined(SUPPORT_CLIPBOARD_IMAGE)
#ifndef STBI_REQUIRED
#define STBI_REQUIRED
#endif

#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
#define SUPPORT_FILEFORMAT_BMP 1
#endif

#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
#define SUPPORT_FILEFORMAT_PNG 1
#endif

#ifndef SUPPORT_FILEFORMAT_JPG
#define SUPPORT_FILEFORMAT_JPG 1
#endif

#ifndef SUPPORT_MODULE_RTEXTURES
#define SUPPORT_MODULE_RTEXTURES 1
#endif
#endif

#endif // CONFIG_H
10 changes: 10 additions & 0 deletions src/raylib/platforms/rcore_android.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,16 @@ const char *GetClipboardText(void)
return NULL;
}

// Get clipboard image
Image GetClipboardImage(void)
{
Image image = { 0 };

TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");

return image;
}

// Show mouse cursor
void rlShowCursor(void)
{
Expand Down
29 changes: 13 additions & 16 deletions src/raylib/platforms/rcore_desktop_glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
// NOTE: Those functions require linking with winmm library
//#pragma warning(disable: 4273)
__declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod);
//#pragma warning(default: 4273)
//#pragma warning(default: 4273)
#endif
#endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
Expand Down Expand Up @@ -967,32 +967,29 @@ const char *GetClipboardText(void)
return glfwGetClipboardString(platform.handle);
}

#if defined(SUPPORT_CLIPBOARD_IMAGE)
// Get clipboard image
Image GetClipboardImage(void)
{
Image image = {0};
Image image = { 0 };

#if defined(SUPPORT_CLIPBOARD_IMAGE)
#if defined(_WIN32)
unsigned long long int dataSize = 0;
void* fileData = NULL;
void *fileData = NULL;
int width = 0;
int height = 0;

#ifdef _WIN32
int width, height;
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
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_GLFW doesn't implement `GetClipboardImage` for this OS");
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
#endif
#endif // SUPPORT_CLIPBOARD_IMAGE

if (fileData == NULL)
{
TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
}
else
{
image = LoadImageFromMemory(".bmp", fileData, (int)dataSize);
}
return image;
}
#endif // SUPPORT_CLIPBOARD_IMAGE

// Show mouse cursor
void rlShowCursor(void)
Expand Down
49 changes: 23 additions & 26 deletions src/raylib/platforms/rcore_desktop_rgfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ bool WindowShouldClose(void)

// Toggle fullscreen mode
void ToggleFullscreen(void)
{
{
RGFW_window_maximize(platform.window);
ToggleBorderlessWindowed();
}
Expand Down Expand Up @@ -664,42 +664,39 @@ 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"
#if defined(_WIN32)
#define WIN32_CLIPBOARD_IMPLEMENTATION
#define WINUSER_ALREADY_INCLUDED
#define WINBASE_ALREADY_INCLUDED
#define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h"
#endif
#endif // SUPPORT_CLIPBOARD_IMAGE

// Get clipboard image
Image GetClipboardImage(void)
{
Image image = {0};
Image image = { 0 };

#if defined(SUPPORT_CLIPBOARD_IMAGE)
#if defined(_WIN32)
unsigned long long int dataSize = 0;
void* fileData = NULL;
void *fileData = NULL;
int width = 0;
int height = 0;

#ifdef _WIN32
int width, height;
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
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW doesn't implement `GetClipboardImage` for this OS");
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
#endif
#endif // SUPPORT_CLIPBOARD_IMAGE

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 rlShowCursor(void)
Expand Down Expand Up @@ -1197,7 +1194,7 @@ void PollInputEvents(void)
int button = (axis == GAMEPAD_AXIS_LEFT_TRIGGER)? GAMEPAD_BUTTON_LEFT_TRIGGER_2 : GAMEPAD_BUTTON_RIGHT_TRIGGER_2;
int pressed = (value > 0.1f);
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = pressed;

if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
}
Expand Down Expand Up @@ -1289,8 +1286,8 @@ int InitPlatform(void)
RGFW_area screenSize = RGFW_getScreenSize();
CORE.Window.display.width = screenSize.w;
CORE.Window.display.height = screenSize.h;
/*
I think this is needed by Raylib now ?
/*
I think this is needed by Raylib now ?
If so, rcore_destkop_sdl should be updated too
*/
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
Expand Down
Loading

0 comments on commit 5354e55

Please sign in to comment.