Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ tools/rexm/rexm
# CI
emsdk-cache/
raylib.com/

# Wayland files
src/*protocol.h
src/*protocol-code.h
src/*protocol-code.c
15 changes: 14 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ USE_EXTERNAL_GLFW ?= FALSE
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
GLFW_LINUX_ENABLE_X11 ?= TRUE

# Enable support for X11 by default on Linux when using GLFW
# NOTE: Wayland is disabled by default, only enable if you are sure
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
RGFW_LINUX_ENABLE_X11 ?= TRUE

# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
# WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
Expand Down Expand Up @@ -475,7 +480,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
# Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev
LDFLAGS += -L../src
LDLIBS = -lraylib -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lm -lpthread -ldl -lrt
LDLIBS = -lraylib -lm

ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXxf86vm -lXcursor -lpthread -ldl -lrt
endif

ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
LDLIBS += -lwayland-client -lwayland-cursor -lwayland-egl -lxkbcommon
endif

# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
Expand Down
86 changes: 83 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ USE_EXTERNAL_GLFW ?= FALSE
GLFW_LINUX_ENABLE_WAYLAND ?= FALSE
GLFW_LINUX_ENABLE_X11 ?= TRUE

# Enable support for X11 by default on Linux when using GLFW
# NOTE: Wayland is disabled by default, only enable if you are sure
RGFW_LINUX_ENABLE_WAYLAND ?= FALSE
RGFW_LINUX_ENABLE_X11 ?= TRUE

# PLATFORM_DESKTOP_SDL: It requires SDL library to be provided externally
# WARNING: Library is not included in raylib, it MUST be configured by users
SDL_INCLUDE_PATH ?= $(RAYLIB_SRC_PATH)/external/SDL2/include
Expand Down Expand Up @@ -289,6 +294,17 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
CC = clang
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),OSX)
# OSX default compiler
CC = clang
GLFW_OSX = -x objective-c
endif
ifeq ($(PLATFORM_OS),BSD)
# FreeBSD, OpenBSD, NetBSD, DragonFly default compiler
CC = clang
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
ifeq ($(USE_RPI_CROSSCOMPILER),TRUE)
# Define RPI cross-compiler
Expand Down Expand Up @@ -450,7 +466,6 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif
ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
CFLAGS += -D_GLFW_WAYLAND
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
Comment thread
raysan5 marked this conversation as resolved.

WL_PROTOCOLS_DIR := external/glfw/deps/wayland

Expand All @@ -472,6 +487,33 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
endif
endif
endif
# Use Wayland display on Linux desktop
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS), LINUX)
ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
CFLAGS += -DRGFW_X11 -DRGFW_UNIX
endif
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
CFLAGS += -DRGFW_WAYLAND -DEGLAPIENTRY=

WL_PROTOCOLS_DIR := external/RGFW/deps/wayland

wl_generate = \
$(eval protocol=$(1)) \
$(eval basename=$(2)) \
$(shell wayland-scanner client-header $(protocol) $(RAYLIB_SRC_PATH)/$(basename).h) \
$(shell wayland-scanner private-code $(protocol) $(RAYLIB_SRC_PATH)/$(basename)-code.c)

$(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-constraints-unstable-v1.xml, pointer-constraints-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/pointer-warp-v1.xml, pointer-warp-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/relative-pointer-unstable-v1.xml, relative-pointer-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-decoration-unstable-v1.xml, xdg-decoration-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-output-unstable-v1.xml, xdg-output-unstable-v1-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-shell.xml, xdg-shell-client-protocol)
$(call wl_generate, $(WL_PROTOCOLS_DIR)/xdg-toplevel-icon-v1.xml, xdg-toplevel-icon-v1-client-protocol)
endif
endif
endif

CFLAGS += $(CUSTOM_CFLAGS)

Expand Down Expand Up @@ -583,6 +625,10 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
ifeq ($(GLFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lX11
endif

ifeq ($(GLFW_LINUX_ENABLE_WAYLAND),TRUE)
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
endif
# TODO: On ARM 32bit arch, miniaudio requires atomics library
#LDLIBS += -latomic
endif
Expand Down Expand Up @@ -618,7 +664,15 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(PLATFORM_OS),LINUX)
# Libraries for Debian GNU/Linux desktop compipling
# NOTE: Required packages: libegl1-mesa-dev
LDLIBS = -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lm -lpthread -ldl -lrt
LDLIBS = -lm

ifeq ($(RGFW_LINUX_ENABLE_X11),TRUE)
LDLIBS += -lGL -lX11 -lXrandr -lXinerama -lXi -lXcursor -lpthread -ldl -lrt
endif

ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
LDFLAGS += $(shell pkg-config wayland-client wayland-cursor wayland-egl xkbcommon --libs)
endif

# Explicit link to libc
ifeq ($(RAYLIB_LIBTYPE),SHARED)
Expand Down Expand Up @@ -665,6 +719,21 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
OBJS += rglfw.o
endif
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
PROTOCOL_CODE_FILES = \
pointer-constraints-unstable-v1-client-protocol-code \
pointer-warp-v1-client-protocol-code \
relative-pointer-unstable-v1-client-protocol-code \
xdg-decoration-unstable-v1-client-protocol-code \
xdg-output-unstable-v1-client-protocol-code \
xdg-shell-client-protocol-code \
xdg-toplevel-icon-v1-client-protocol-code

PROTO_OBJS = $(addsuffix .o, $(PROTOCOL_CODE_FILES))
OBJS += $(PROTO_OBJS)
endif
endif
ifeq ($(RAYLIB_MODULE_MODELS),TRUE)
OBJS += rmodels.o
endif
Expand Down Expand Up @@ -801,6 +870,17 @@ endif
android_native_app_glue.o : $(NATIVE_APP_GLUE)/android_native_app_glue.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)

# Compile Wayland files
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_RGFW)
ifeq ($(RGFW_LINUX_ENABLE_WAYLAND),TRUE)
%-client-protocol-code.o: %-client-protocol-code.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS)

%-client-protocol-code.h: external/RGFW/deps/wayland/%.xml
wayland-scanner private-code $< $@
endif
endif

# Install generated and needed files to desired directories.
# On GNU/Linux and BSDs, there are some standard directories that contain extra
# libraries and header files. These directories (often /usr/local/lib and
Expand Down Expand Up @@ -885,7 +965,7 @@ clean: clean_shell_$(PLATFORM_SHELL)
@echo "removed all generated files!"

clean_shell_sh:
rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h
rm -fv *.o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).so* raygui.c $(RAYLIB_RELEASE_PATH)/*-protocol.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.h $(RAYLIB_RELEASE_PATH)/*-protocol-code.c
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
rm -fv $(NATIVE_APP_GLUE)/android_native_app_glue.o
endif
Expand Down
14 changes: 7 additions & 7 deletions src/external/RGFW/RGFW.h
Original file line number Diff line number Diff line change
Expand Up @@ -8667,13 +8667,13 @@ struct wl_surface* RGFW_window_getWindow_Wayland(RGFW_window* win) { return win-


/* wayland global garbage (wayland bad, X11 is fine (ish) (not really)) */
#include "xdg-shell.h"
#include "xdg-toplevel-icon-v1.h"
#include "xdg-decoration-unstable-v1.h"
#include "relative-pointer-unstable-v1.h"
#include "pointer-constraints-unstable-v1.h"
#include "xdg-output-unstable-v1.h"
#include "pointer-warp-v1.h"
#include "xdg-shell-client-protocol.h"
#include "xdg-toplevel-icon-v1-client-protocol.h"
#include "xdg-decoration-unstable-v1-client-protocol.h"
#include "relative-pointer-unstable-v1-client-protocol.h"
#include "pointer-constraints-unstable-v1-client-protocol.h"
#include "xdg-output-unstable-v1-client-protocol.h"
#include "pointer-warp-v1-client-protocol.h"
Comment thread
raysan5 marked this conversation as resolved.

void RGFW_toggleWaylandMaximized(RGFW_window* win, RGFW_bool maximized);

Expand Down
1 change: 1 addition & 0 deletions src/platforms/rcore_desktop_rgfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,7 @@ int InitPlatform(void)
// Close platform
void ClosePlatform(void)
{
mg_gamepads_free(&platform.minigamepad);
RGFW_window_close(platform.window);
}

Expand Down
Loading