Skip to content

Commit 00396e3

Browse files
authored
[rcore] Clipboard Image Support (#4459)
* [rcore] add 'GetClipboardImage' for windows * [rcore] GetClipboardImage removed some unneeded defines * [rcore] PLATFORM_SDL: create a compatility layer for SDL3 * external: add win32_clipboard.h header only lib * [rcore] using win32_clipboard on platforms rlfw and rgfw * [rcore] fix warnings in SDL3 compatibility layer * Makefile: Allow specifying SDL_LIBRARIES to link, this helps with SDL3 * Makefile: examples makefile now compile others/rlgl_standalone only when TARGET_PLATFORM is PLATFORM_DESKTOP_GFLW * Makefile: examples makefile now compile others/rlgl_standalone only when TARGET_PLATFORM is PLATFORM_DESKTOP_GFLW * [rcore]: PLATFORM_SDL: improve clipboard data retrieval * external: remove unused function from win32_clipboard.h * Makefile: allow for extra flags necessary when compiling for SDL3 * [rcore]: fix string typo * [rcore]: Properly handle NULL dpi passing. As is allowed in SDL2 * external: fix arch finding on win32_clipboard.h to allow compilation on msvc cmake CI * [rcore]: PLATFORM_SDL: Treat monitor as an ID in SDL3 as opposed to an index as in SDL2 * [rcore]: typo
1 parent 53b929c commit 00396e3

File tree

9 files changed

+837
-11
lines changed

9 files changed

+837
-11
lines changed

examples/Makefile

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ USE_EXTERNAL_GLFW ?= FALSE
8787
# WARNING: Library is not included in raylib, it MUST be configured by users
8888
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
8989
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
90+
SDL_LIBRARIES ?= -lSDL2 -lSDL2main
91+
9092

9193
# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
9294
# NOTE: This variable is only used for PLATFORM_OS: LINUX
@@ -263,9 +265,9 @@ endif
263265
# Define include paths for required headers: INCLUDE_PATHS
264266
# NOTE: Some external/extras libraries could be required (stb, easings...)
265267
#------------------------------------------------------------------------------------------------
266-
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external
267-
268+
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
268269
# Define additional directories containing required header files
270+
269271
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
270272
ifeq ($(PLATFORM_OS),BSD)
271273
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
@@ -415,12 +417,12 @@ endif
415417
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
416418
ifeq ($(PLATFORM_OS),WINDOWS)
417419
# Libraries for Windows desktop compilation
418-
LDLIBS = -lraylib -lSDL2 -lSDL2main -lopengl32 -lgdi32
420+
LDLIBS = -lraylib $(SDL_LIBRARIES) -lopengl32 -lgdi32
419421
endif
420422
ifeq ($(PLATFORM_OS),LINUX)
421423
# Libraries for Debian GNU/Linux desktop compiling
422424
# NOTE: Required packages: libegl1-mesa-dev
423-
LDLIBS = -lraylib -lSDL2 -lSDL2main -lGL -lm -lpthread -ldl -lrt
425+
LDLIBS = -lraylib $(SDL_LIBRARIES) -lGL -lm -lpthread -ldl -lrt
424426

425427
# On X11 requires also below libraries
426428
LDLIBS += -lX11
@@ -646,8 +648,12 @@ OTHERS = \
646648
others/embedded_files_loading \
647649
others/raylib_opengl_interop \
648650
others/raymath_vector_angle \
649-
others/rlgl_compute_shader \
650-
others/rlgl_standalone
651+
others/rlgl_compute_shader
652+
653+
ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW)
654+
OTHERS += others/rlgl_standalone
655+
endif
656+
651657

652658
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
653659

src/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ GLFW_LINUX_ENABLE_X11 ?= TRUE
118118
# WARNING: Library is not included in raylib, it MUST be configured by users
119119
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
120120
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
121+
SDL_LIBRARIES ?= -lSDL2 -lSDL2main
122+
121123

122124
# Determine if the file has root access (only required to install raylib)
123125
# "whoami" prints the name of the user that calls him (so, if it is the root user, "whoami" prints "root")
@@ -460,7 +462,7 @@ CFLAGS += $(CUSTOM_CFLAGS)
460462
# Define include paths for required headers: INCLUDE_PATHS
461463
# NOTE: Several external required libraries (stb and others)
462464
#------------------------------------------------------------------------------------------------
463-
INCLUDE_PATHS = -I.
465+
INCLUDE_PATHS = -I. $(EXTRA_INCLUDE_PATHS)
464466

465467
# Define additional directories containing required header files
466468
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
@@ -586,7 +588,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
586588
LDLIBS += -lX11
587589
endif
588590
endif
589-
LDLIBS += -lSDL2 -lSDL2main
591+
LDLIBS += $(SDL_LIBRARIES)
590592
endif
591593
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
592594
ifeq ($(PLATFORM_OS),WINDOWS)

src/config.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
// Enabling this flag allows manual control of the frame processes, use at your own risk
7272
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1
7373

74+
7475
// rcore: Configuration values
7576
//------------------------------------------------------------------------------------
7677
#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
@@ -272,4 +273,31 @@
272273
//------------------------------------------------------------------------------------
273274
#define MAX_TRACELOG_MSG_LENGTH 256 // Max length of one trace-log message
274275

276+
277+
// Enable partial support for clipboard image, only working on SDL3 or
278+
// being on both Windows OS + GLFW or Windows OS + RGFW
279+
#define SUPPORT_CLIPBOARD_IMAGE 1
280+
281+
#if defined(SUPPORT_CLIPBOARD_IMAGE)
282+
#ifndef STBI_REQUIRED
283+
#define STBI_REQUIRED
284+
#endif
285+
286+
#ifndef SUPPORT_FILEFORMAT_BMP // For clipboard image on Windows
287+
#define SUPPORT_FILEFORMAT_BMP 1
288+
#endif
289+
290+
#ifndef SUPPORT_FILEFORMAT_PNG // Wayland uses png for prints, at least it was on 22 LTS ubuntu
291+
#define SUPPORT_FILEFORMAT_PNG 1
292+
#endif
293+
294+
#ifndef SUPPORT_FILEFORMAT_JPG
295+
#define SUPPORT_FILEFORMAT_JPG 1
296+
#endif
297+
298+
#ifndef SUPPORT_MODULE_RTEXTURES
299+
#define SUPPORT_MODULE_RTEXTURES 1
300+
#endif
301+
#endif
302+
275303
#endif // CONFIG_H

0 commit comments

Comments
 (0)