Skip to content

Commit

Permalink
[rcore] Clipboard Image Support (#4459)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
evertonse authored Nov 9, 2024
1 parent 53b929c commit 00396e3
Show file tree
Hide file tree
Showing 9 changed files with 837 additions and 11 deletions.
18 changes: 12 additions & 6 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ USE_EXTERNAL_GLFW ?= FALSE
# WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
SDL_LIBRARIES ?= -lSDL2 -lSDL2main


# Use Wayland display server protocol on Linux desktop (by default it uses X11 windowing system)
# NOTE: This variable is only used for PLATFORM_OS: LINUX
Expand Down Expand Up @@ -263,9 +265,9 @@ endif
# Define include paths for required headers: INCLUDE_PATHS
# NOTE: Some external/extras libraries could be required (stb, easings...)
#------------------------------------------------------------------------------------------------
INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external

INCLUDE_PATHS = -I. -I$(RAYLIB_PATH)/src -I$(RAYLIB_PATH)/src/external $(EXTRA_INCLUDE_PATHS)
# Define additional directories containing required header files

ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(PLATFORM_OS),BSD)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I/usr/pkg/include -I/usr/X11R7/include
Expand Down Expand Up @@ -415,12 +417,12 @@ endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
ifeq ($(PLATFORM_OS),WINDOWS)
# Libraries for Windows desktop compilation
LDLIBS = -lraylib -lSDL2 -lSDL2main -lopengl32 -lgdi32
LDLIBS = -lraylib $(SDL_LIBRARIES) -lopengl32 -lgdi32
endif
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compiling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lraylib -lSDL2 -lSDL2main -lGL -lm -lpthread -ldl -lrt
LDLIBS = -lraylib $(SDL_LIBRARIES) -lGL -lm -lpthread -ldl -lrt

# On X11 requires also below libraries
LDLIBS += -lX11
Expand Down Expand Up @@ -646,8 +648,12 @@ OTHERS = \
others/embedded_files_loading \
others/raylib_opengl_interop \
others/raymath_vector_angle \
others/rlgl_compute_shader \
others/rlgl_standalone
others/rlgl_compute_shader

ifeq ($(TARGET_PLATFORM), PLATFORM_DESKTOP_GFLW)
OTHERS += others/rlgl_standalone
endif


CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))

Expand Down
6 changes: 4 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ GLFW_LINUX_ENABLE_X11 ?= TRUE
# WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
SDL_LIBRARY_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/lib
SDL_LIBRARIES ?= -lSDL2 -lSDL2main


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

# Define additional directories containing required header files
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
Expand Down Expand Up @@ -586,7 +588,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
LDLIBS += -lX11
endif
endif
LDLIBS += -lSDL2 -lSDL2main
LDLIBS += $(SDL_LIBRARIES)
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),WINDOWS)
Expand Down
28 changes: 28 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
// Enabling this flag allows manual control of the frame processes, use at your own risk
//#define SUPPORT_CUSTOM_FRAME_CONTROL 1


// rcore: Configuration values
//------------------------------------------------------------------------------------
#define MAX_FILEPATH_CAPACITY 8192 // Maximum file paths capacity
Expand Down Expand Up @@ -272,4 +273,31 @@
//------------------------------------------------------------------------------------
#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
Loading

0 comments on commit 00396e3

Please sign in to comment.