瀏覽代碼

Merge branch 'master' into overridable_config

pull/4554/head
Ray 6 月之前
committed by GitHub
父節點
當前提交
f2bfdeab97
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: B5690EEEBB952194
共有 22 個檔案被更改,包括 1195 行新增1042 行删除
  1. +1
    -0
      build.zig
  2. +23
    -16
      examples/Makefile
  3. +16
    -11
      examples/Makefile.Web
  4. +2
    -2
      parser/output/raylib_api.json
  5. +2
    -2
      parser/output/raylib_api.lua
  6. +2
    -2
      parser/output/raylib_api.txt
  7. +2
    -2
      parser/output/raylib_api.xml
  8. +0
    -4
      projects/VS2022/raylib.sln
  9. +1
    -0
      src/CMakeLists.txt
  10. +13
    -11
      src/Makefile
  11. +804
    -698
      src/external/RGFW.h
  12. +3
    -3
      src/platforms/rcore_android.c
  13. +117
    -155
      src/platforms/rcore_desktop_rgfw.c
  14. +66
    -15
      src/platforms/rcore_desktop_sdl.c
  15. +3
    -3
      src/platforms/rcore_drm.c
  16. +6
    -0
      src/platforms/rcore_template.c
  17. +5
    -5
      src/platforms/rcore_web.c
  18. +62
    -63
      src/raylib.h
  19. +14
    -5
      src/rcore.c
  20. +0
    -15
      src/rlgl.h
  21. +52
    -26
      src/rmodels.c
  22. +1
    -4
      src/rtextures.c

+ 1
- 0
build.zig 查看文件

@ -401,6 +401,7 @@ pub fn build(b: *std.Build) !void {
const lib = try compileRaylib(b, target, optimize, Options.getOptions(b)); const lib = try compileRaylib(b, target, optimize, Options.getOptions(b));
lib.installHeader(b.path("src/raylib.h"), "raylib.h"); lib.installHeader(b.path("src/raylib.h"), "raylib.h");
lib.installHeader(b.path("src/rcamera.h"), "rcamera.h");
lib.installHeader(b.path("src/raymath.h"), "raymath.h"); lib.installHeader(b.path("src/raymath.h"), "raymath.h");
lib.installHeader(b.path("src/rlgl.h"), "rlgl.h"); lib.installHeader(b.path("src/rlgl.h"), "rlgl.h");

+ 23
- 16
examples/Makefile 查看文件

@ -20,6 +20,8 @@
# - Linux (X11 desktop mode) # - Linux (X11 desktop mode)
# - macOS/OSX (x64, arm64 (not tested)) # - macOS/OSX (x64, arm64 (not tested))
# - Others (not tested) # - Others (not tested)
# > PLATFORM_WEB_RGFW:
# - HTML5 (WebAssembly)
# > PLATFORM_WEB: # > PLATFORM_WEB:
# - HTML5 (WebAssembly) # - HTML5 (WebAssembly)
# > PLATFORM_DRM: # > PLATFORM_DRM:
@ -51,7 +53,7 @@
# Define required environment variables # Define required environment variables
#------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB
# Define target platform: PLATFORM_DESKTOP, PLATFORM_DESKTOP_SDL, PLATFORM_DRM, PLATFORM_ANDROID, PLATFORM_WEB, PLATFORM_WEB_RGFW
PLATFORM ?= PLATFORM_DESKTOP PLATFORM ?= PLATFORM_DESKTOP
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))
@ -107,7 +109,7 @@ BUILD_WEB_RESOURCES ?= TRUE
BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources BUILD_WEB_RESOURCES_PATH ?= $(dir $<)resources@resources
# Determine PLATFORM_OS when required # Determine PLATFORM_OS when required
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB))
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -158,7 +160,7 @@ endif
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH ?= C:/raylib/emsdk EMSDK_PATH ?= C:/raylib/emsdk
@ -184,8 +186,8 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
CC = clang CC = clang
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
# HTML5 emscripten compiler
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler
# WARNING: To compile to HTML5, code must be redesigned # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop() # to use emscripten.h and emscripten_set_main_loop()
CC = emcc CC = emcc
@ -203,7 +205,7 @@ endif
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
MAKE = mingw32-make MAKE = mingw32-make
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
MAKE = mingw32-make MAKE = mingw32-make
else else
@ -231,11 +233,11 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
ifeq ($(BUILD_MODE),DEBUG) ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG CFLAGS += -g -D_DEBUG
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
CFLAGS += -sASSERTIONS=1 --profiling CFLAGS += -sASSERTIONS=1 --profiling
endif endif
else
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
else
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
CFLAGS += -O3 CFLAGS += -O3
else else
@ -325,7 +327,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_SDL)
endif endif
LDFLAGS += -L$(SDL_LIBRARY_PATH) LDFLAGS += -L$(SDL_LIBRARY_PATH)
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# -Os # size optimization # -Os # size optimization
# -O2 # optimization level 2, if used, also set --memory-init-file 0 # -O2 # optimization level 2, if used, also set --memory-init-file 0
# -sUSE_GLFW=3 # Use glfw3 library (context/input management) # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
@ -341,9 +343,14 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# --preload-file resources # specify a resources folder for data compilation # --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map # --source-map-base # allow debugging in browser with source map
LDFLAGS += -sUSE_GLFW=3 -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1
# Build using asyncify
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
LDFLAGS += -sUSE_GLFW=3
endif
LDFLAGS += -sTOTAL_MEMORY=$(BUILD_WEB_HEAP_SIZE) -sFORCE_FILESYSTEM=1
# Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
LDFLAGS += -sASYNCIFY LDFLAGS += -sASYNCIFY
endif endif
@ -480,9 +487,9 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
# NOTE: Required packages: libasound2-dev (ALSA) # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# Libraries for web (HTML5) compiling # Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
endif endif
# Define source code object files required # Define source code object files required
@ -681,7 +688,7 @@ others: $(OTHERS)
%: %.c %: %.c
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID) ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
$(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$< $(MAKE) -f Makefile.Android PROJECT_NAME=$@ PROJECT_SOURCE_FILES=$<
else ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
else ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
$(MAKE) -f Makefile.Web $@ $(MAKE) -f Makefile.Web $@
else else
$(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -D$(TARGET_PLATFORM) $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) -D$(TARGET_PLATFORM)
@ -710,7 +717,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
find . -type f -executable -delete find . -type f -executable -delete
rm -fv *.o rm -fv *.o
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
del *.wasm *.html *.js *.data del *.wasm *.html *.js *.data
else else

+ 16
- 11
examples/Makefile.Web 查看文件

@ -65,7 +65,7 @@ BUILD_WEB_HEAP_SIZE ?= 134217728
USE_WEBGL2 ?= FALSE USE_WEBGL2 ?= FALSE
# Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected # Determine PLATFORM_OS in case PLATFORM_DESKTOP or PLATFORM_WEB selected
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB))
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_DESKTOP PLATFORM_WEB PLATFORM_WEB_RGFW))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -116,7 +116,7 @@ endif
# Define raylib release directory for compiled library # Define raylib release directory for compiled library
RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src RAYLIB_RELEASE_PATH ?= $(RAYLIB_PATH)/src
ifeq ($(PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS),WINDOWS) ifeq ($(PLATFORM_OS),WINDOWS)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH ?= C:/raylib/emsdk EMSDK_PATH ?= C:/raylib/emsdk
@ -142,7 +142,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
CC = clang CC = clang
endif endif
endif endif
ifeq ($(PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler # HTML5 emscripten compiler
# WARNING: To compile to HTML5, code must be redesigned # WARNING: To compile to HTML5, code must be redesigned
# to use emscripten.h and emscripten_set_main_loop() # to use emscripten.h and emscripten_set_main_loop()
@ -161,7 +161,7 @@ endif
ifeq ($(PLATFORM),PLATFORM_ANDROID) ifeq ($(PLATFORM),PLATFORM_ANDROID)
MAKE = mingw32-make MAKE = mingw32-make
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
MAKE = mingw32-make MAKE = mingw32-make
else else
@ -189,11 +189,11 @@ CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
ifeq ($(BUILD_MODE),DEBUG) ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG CFLAGS += -g -D_DEBUG
ifeq ($(PLATFORM),PLATFORM_WEB)
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
CFLAGS += -sASSERTIONS=1 --profiling CFLAGS += -sASSERTIONS=1 --profiling
endif endif
else else
ifeq ($(PLATFORM),PLATFORM_WEB)
ifeq ($(PLATFORM),$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
CFLAGS += -O3 CFLAGS += -O3
else else
@ -263,7 +263,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP)
LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH) LDFLAGS += -Lsrc -L$(RAYLIB_LIB_PATH)
endif endif
endif endif
ifeq ($(PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# -Os # size optimization # -Os # size optimization
# -O2 # optimization level 2, if used, also set --memory-init-file 0 # -O2 # optimization level 2, if used, also set --memory-init-file 0
# -sUSE_GLFW=3 # Use glfw3 library (context/input management) # -sUSE_GLFW=3 # Use glfw3 library (context/input management)
@ -279,7 +279,12 @@ ifeq ($(PLATFORM),PLATFORM_WEB)
# --memory-init-file 0 # to avoid an external memory initialization code file (.mem) # --memory-init-file 0 # to avoid an external memory initialization code file (.mem)
# --preload-file resources # specify a resources folder for data compilation # --preload-file resources # specify a resources folder for data compilation
# --source-map-base # allow debugging in browser with source map # --source-map-base # allow debugging in browser with source map
LDFLAGS += -sUSE_GLFW=3 -sEXPORTED_RUNTIME_METHODS=ccall
ifeq ($(PLATFORM),PLATFORM_WEB)
LDFLAGS += -sUSE_GLFW=3
endif
LDFLAGS += -sEXPORTED_RUNTIME_METHODS=ccall
# Build using asyncify # Build using asyncify
ifeq ($(BUILD_WEB_ASYNCIFY),TRUE) ifeq ($(BUILD_WEB_ASYNCIFY),TRUE)
@ -363,9 +368,9 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
# NOTE: Required packages: libasound2-dev (ALSA) # NOTE: Required packages: libasound2-dev (ALSA)
LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic LDLIBS = -lraylib -lGLESv2 -lEGL -lpthread -lrt -lm -lgbm -ldrm -ldl -latomic
endif endif
ifeq ($(PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# Libraries for web (HTML5) compiling # Libraries for web (HTML5) compiling
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.a
LDLIBS = $(RAYLIB_RELEASE_PATH)/libraylib.web.a
endif endif
# Define source code object files required # Define source code object files required
@ -1225,7 +1230,7 @@ ifeq ($(PLATFORM),PLATFORM_DRM)
find . -type f -executable -delete find . -type f -executable -delete
rm -fv *.o rm -fv *.o
endif endif
ifeq ($(PLATFORM),err">PLATFORM_WEB)
ifeq ($(PLATFORM),k">$(filter $(PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
del *.o *.html *.js del *.o *.html *.js
endif endif
@echo Cleaning done @echo Cleaning done

+ 2
- 2
parser/output/raylib_api.json 查看文件

@ -9801,7 +9801,7 @@
}, },
{ {
"name": "TextToInteger", "name": "TextToInteger",
"description": "Get integer value from text (negative values not supported)",
"description": "Get integer value from text",
"returnType": "int", "returnType": "int",
"params": [ "params": [
{ {
@ -9812,7 +9812,7 @@
}, },
{ {
"name": "TextToFloat", "name": "TextToFloat",
"description": "Get float value from text (negative values not supported)",
"description": "Get float value from text",
"returnType": "float", "returnType": "float",
"params": [ "params": [
{ {

+ 2
- 2
parser/output/raylib_api.lua 查看文件

@ -6969,7 +6969,7 @@ return {
}, },
{ {
name = "TextToInteger", name = "TextToInteger",
description = "Get integer value from text (negative values not supported)",
description = "Get integer value from text",
returnType = "int", returnType = "int",
params = { params = {
{type = "const char *", name = "text"} {type = "const char *", name = "text"}
@ -6977,7 +6977,7 @@ return {
}, },
{ {
name = "TextToFloat", name = "TextToFloat",
description = "Get float value from text (negative values not supported)",
description = "Get float value from text",
returnType = "float", returnType = "float",
params = { params = {
{type = "const char *", name = "text"} {type = "const char *", name = "text"}

+ 2
- 2
parser/output/raylib_api.txt 查看文件

@ -3757,12 +3757,12 @@ Function 438: TextToCamel() (1 input parameters)
Function 439: TextToInteger() (1 input parameters) Function 439: TextToInteger() (1 input parameters)
Name: TextToInteger Name: TextToInteger
Return type: int Return type: int
Description: Get integer value from text (negative values not supported)
Description: Get integer value from text
Param[1]: text (type: const char *) Param[1]: text (type: const char *)
Function 440: TextToFloat() (1 input parameters) Function 440: TextToFloat() (1 input parameters)
Name: TextToFloat Name: TextToFloat
Return type: float Return type: float
Description: Get float value from text (negative values not supported)
Description: Get float value from text
Param[1]: text (type: const char *) Param[1]: text (type: const char *)
Function 441: DrawLine3D() (3 input parameters) Function 441: DrawLine3D() (3 input parameters)
Name: DrawLine3D Name: DrawLine3D

+ 2
- 2
parser/output/raylib_api.xml 查看文件

@ -2487,10 +2487,10 @@
<Function name="TextToCamel" retType="const char *" paramCount="1" desc="Get Camel case notation version of provided string"> <Function name="TextToCamel" retType="const char *" paramCount="1" desc="Get Camel case notation version of provided string">
<Param type="const char *" name="text" desc="" /> <Param type="const char *" name="text" desc="" />
</Function> </Function>
<Function name="TextToInteger" retType="int" paramCount="1" desc="Get integer value from text (negative values not supported)">
<Function name="TextToInteger" retType="int" paramCount="1" desc="Get integer value from text">
<Param type="const char *" name="text" desc="" /> <Param type="const char *" name="text" desc="" />
</Function> </Function>
<Function name="TextToFloat" retType="float" paramCount="1" desc="Get float value from text (negative values not supported)">
<Function name="TextToFloat" retType="float" paramCount="1" desc="Get float value from text">
<Param type="const char *" name="text" desc="" /> <Param type="const char *" name="text" desc="" />
</Function> </Function>
<Function name="DrawLine3D" retType="void" paramCount="3" desc="Draw a line in 3D world space"> <Function name="DrawLine3D" retType="void" paramCount="3" desc="Draw a line in 3D world space">

+ 0
- 4
projects/VS2022/raylib.sln 查看文件

@ -693,16 +693,12 @@ Global
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x64.ActiveCfg = Debug|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x64.ActiveCfg = Debug|x64
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x64.Build.0 = Debug|x64
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x86.ActiveCfg = Debug|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x86.ActiveCfg = Debug|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Debug|x86.Build.0 = Debug|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x64.ActiveCfg = Release.DLL|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x64.ActiveCfg = Release.DLL|x64
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.Build.0 = Release.DLL|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release.DLL|x86.Build.0 = Release.DLL|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x64.ActiveCfg = Release|x64 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x64.ActiveCfg = Release|x64
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x64.Build.0 = Release|x64
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x86.ActiveCfg = Release|Win32 {F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x86.ActiveCfg = Release|Win32
{F026020F-7B00-40C8-91C3-5DE85EC45A95}.Release|x86.Build.0 = Release|Win32
{6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.ActiveCfg = Debug.DLL|x64
{6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.Build.0 = Debug.DLL|x64 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x64.Build.0 = Debug.DLL|x64
{6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32 {6B8BAAF1-75C7-4C68-80B8-0E2A9EABBD9A}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32

+ 1
- 0
src/CMakeLists.txt 查看文件

@ -23,6 +23,7 @@ endif()
# Used as public API to be included into other projects # Used as public API to be included into other projects
set(raylib_public_headers set(raylib_public_headers
raylib.h raylib.h
rcamera.h
rlgl.h rlgl.h
raymath.h raymath.h
) )

+ 13
- 11
src/Makefile 查看文件

@ -20,6 +20,8 @@
# - Linux (X11 desktop mode) # - Linux (X11 desktop mode)
# - macOS/OSX (x64, arm64 (not tested)) # - macOS/OSX (x64, arm64 (not tested))
# - Others (not tested) # - Others (not tested)
# > PLATFORM_WEB_RGFW:
# - HTML5 (WebAssembly)
# > PLATFORM_WEB: # > PLATFORM_WEB:
# - HTML5 (WebAssembly) # - HTML5 (WebAssembly)
# > PLATFORM_DRM: # > PLATFORM_DRM:
@ -130,7 +132,7 @@ HOST_PLATFORM_OS ?= WINDOWS
PLATFORM_OS ?= WINDOWS PLATFORM_OS ?= WINDOWS
# Determine PLATFORM_OS when required # Determine PLATFORM_OS when required
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_ANDROID))
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW PLATFORM_WEB PLATFORM_WEB_RGFW PLATFORM_ANDROID))
# No uname.exe on MinGW!, but OS=Windows_NT on Windows! # No uname.exe on MinGW!, but OS=Windows_NT on Windows!
# ifeq ($(UNAME),Msys) -> Windows # ifeq ($(UNAME),Msys) -> Windows
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
@ -172,7 +174,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
PLATFORM_SHELL = sh PLATFORM_SHELL = sh
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS),LINUX) ifeq ($(PLATFORM_OS),LINUX)
ifndef PLATFORM_SHELL ifndef PLATFORM_SHELL
PLATFORM_SHELL = sh PLATFORM_SHELL = sh
@ -180,7 +182,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
ifeq ($(PLATFORM_OS), WINDOWS) ifeq ($(PLATFORM_OS), WINDOWS)
# Emscripten required variables # Emscripten required variables
EMSDK_PATH ?= C:/raylib/emsdk EMSDK_PATH ?= C:/raylib/emsdk
@ -254,7 +256,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
# On DRM OpenGL ES 2.0 must be used # On DRM OpenGL ES 2.0 must be used
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0 # On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
GRAPHICS = GRAPHICS_API_OPENGL_ES2 GRAPHICS = GRAPHICS_API_OPENGL_ES2
#GRAPHICS = GRAPHICS_API_OPENGL_ES3 #GRAPHICS = GRAPHICS_API_OPENGL_ES3
@ -288,7 +290,7 @@ ifeq ($(TARGET_PLATFORM),PLATFORM_DRM)
AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar AR = $(RPI_TOOLCHAIN)/bin/$(RPI_TOOLCHAIN_NAME)-ar
endif endif
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# HTML5 emscripten compiler # HTML5 emscripten compiler
CC = emcc CC = emcc
AR = emar AR = emar
@ -331,7 +333,7 @@ ifneq ($(RAYLIB_CONFIG_FLAGS), NONE)
CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS) CFLAGS += -DEXTERNAL_CONFIG_FLAGS $(RAYLIB_CONFIG_FLAGS)
endif endif
ifeq ($(TARGET_PLATFORM), PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# NOTE: When using multi-threading in the user code, it requires -pthread enabled # NOTE: When using multi-threading in the user code, it requires -pthread enabled
CFLAGS += -std=gnu99 CFLAGS += -std=gnu99
else else
@ -347,7 +349,7 @@ ifeq ($(RAYLIB_BUILD_MODE),DEBUG)
endif endif
ifeq ($(RAYLIB_BUILD_MODE),RELEASE) ifeq ($(RAYLIB_BUILD_MODE),RELEASE)
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
CFLAGS += -Os CFLAGS += -Os
endif endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
@ -366,7 +368,7 @@ endif
ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW) ifeq ($(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW)
CFLAGS += -Werror=implicit-function-declaration CFLAGS += -Werror=implicit-function-declaration
endif endif
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# -Os # size optimization # -Os # size optimization
# -O2 # optimization level 2, if used, also set --memory-init-file 0 # -O2 # optimization level 2, if used, also set --memory-init-file 0
# -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker! # -sUSE_GLFW=3 # Use glfw3 library (context/input management) -> Only for linker!
@ -659,11 +661,11 @@ all: raylib
# Compile raylib library # Compile raylib library
# NOTE: Release directory is created if not exist # NOTE: Release directory is created if not exist
raylib: $(OBJS) raylib: $(OBJS)
ifeq ($(TARGET_PLATFORM),err">PLATFORM_WEB)
ifeq ($(TARGET_PLATFORM),k">$(filter $(TARGET_PLATFORM),PLATFORM_WEB PLATFORM_WEB_RGFW))
# Compile raylib libray for web # Compile raylib libray for web
#$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc #$(CC) $(OBJS) -r -o $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).bc
$(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).a $(OBJS)
@echo "raylib library generated (lib$(RAYLIB_LIB_NAME).a)!"
$(AR) rcs $(RAYLIB_RELEASE_PATH)/lib$(RAYLIB_LIB_NAME).web.a $(OBJS)
@echo "raylib library generated (lib$(RAYLIB_LIB_NAME).web.a)!"
else else
ifeq ($(RAYLIB_LIBTYPE),SHARED) ifeq ($(RAYLIB_LIBTYPE),SHARED)
ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW)) ifeq ($(TARGET_PLATFORM),$(filter $(TARGET_PLATFORM),PLATFORM_DESKTOP_GLFW PLATFORM_DESKTOP_SDL PLATFORM_DESKTOP_RGFW))

+ 804
- 698
src/external/RGFW.h
文件差異過大導致無法顯示
查看文件


+ 3
- 3
src/platforms/rcore_android.c 查看文件

@ -699,7 +699,7 @@ void PollInputEvents(void)
// Poll Events (registered events) until we reach TIMEOUT which indicates there are no events left to poll // Poll Events (registered events) until we reach TIMEOUT which indicates there are no events left to poll
// NOTE: Activity is paused if not enabled (platform.appEnabled) // NOTE: Activity is paused if not enabled (platform.appEnabled)
while ((pollResult = ALooper_pollOnce(platform.appEnabled? 0 : -1, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT)
while ((pollResult = ALooper_pollOnce(platform.appEnabled? 0 : -1, NULL, &pollEvents, (p">(void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
{ {
// Process this event // Process this event
if (platform.source != NULL) platform.source->process(platform.app, platform.source); if (platform.source != NULL) platform.source->process(platform.app, platform.source);
@ -786,7 +786,7 @@ int InitPlatform(void)
while (!CORE.Window.ready) while (!CORE.Window.ready)
{ {
// Process events until we reach TIMEOUT, which indicates no more events queued. // Process events until we reach TIMEOUT, which indicates no more events queued.
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (void**)&platform.source)) > ALOOPER_POLL_TIMEOUT)
while ((pollResult = ALooper_pollOnce(0, NULL, &pollEvents, (p">(void **)&platform.source)) > ALOOPER_POLL_TIMEOUT))
{ {
// Process this event // Process this event
if (platform.source != NULL) platform.source->process(platform.app, platform.source); if (platform.source != NULL) platform.source->process(platform.app, platform.source);
@ -1226,7 +1226,7 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
return 1; // Handled gamepad button return 1; // Handled gamepad button
} }
KeyboardKey key = (keycode > 0 && keycode < KEYCODE_MAP_SIZE)? mapKeycode[keycode] : KEY_NULL;
KeyboardKey key = (p">(keycode > 0) && p">(keycode < KEYCODE_MAP_SIZE))? mapKeycode[keycode] : KEY_NULL;
if (key != KEY_NULL) if (key != KEY_NULL)
{ {
// Save current key and its state // Save current key and its state

+ 117
- 155
src/platforms/rcore_desktop_rgfw.c 查看文件

@ -6,6 +6,8 @@
* - Windows (Win32, Win64) * - Windows (Win32, Win64)
* - Linux (X11/Wayland desktop mode) * - Linux (X11/Wayland desktop mode)
* - MacOS (Cocoa) * - MacOS (Cocoa)
* - HTML5 (Emscripten)
* - Others (untested)
* *
* LIMITATIONS: * LIMITATIONS:
* - TODO * - TODO
@ -46,7 +48,11 @@
* *
**********************************************************************************************/ **********************************************************************************************/
#if defined(GRAPHICS_API_OPENGL_ES2)
#if defined(PLATFORM_WEB_RGFW)
#define RGFW_NO_GL_HEADER
#endif
#if defined(GRAPHICS_API_OPENGL_ES2) && !defined(PLATFORM_WEB_RGFW)
#define RGFW_OPENGL_ES2 #define RGFW_OPENGL_ES2
#endif #endif
@ -80,6 +86,10 @@ void CloseWindow(void);
#define Size NSSIZE #define Size NSSIZE
#endif #endif
#define RGFW_MALLOC RL_MALLOC
#define RGFW_FREE RL_FREE
#define RGFW_CALLOC RL_CALLOC
#include "../external/RGFW.h" #include "../external/RGFW.h"
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
@ -118,6 +128,7 @@ static bool RGFW_disableCursor = false;
static const unsigned short keyMappingRGFW[] = { static const unsigned short keyMappingRGFW[] = {
[RGFW_KEY_NULL] = KEY_NULL, [RGFW_KEY_NULL] = KEY_NULL,
[RGFW_Return] = KEY_ENTER,
[RGFW_Quote] = KEY_APOSTROPHE, [RGFW_Quote] = KEY_APOSTROPHE,
[RGFW_Comma] = KEY_COMMA, [RGFW_Comma] = KEY_COMMA,
[RGFW_Minus] = KEY_MINUS, [RGFW_Minus] = KEY_MINUS,
@ -246,7 +257,7 @@ bool WindowShouldClose(void)
// Toggle fullscreen mode // Toggle fullscreen mode
void ToggleFullscreen(void) void ToggleFullscreen(void)
{
{
RGFW_window_maximize(platform.window); RGFW_window_maximize(platform.window);
ToggleBorderlessWindowed(); ToggleBorderlessWindowed();
} }
@ -485,7 +496,7 @@ void SetWindowIcons(Image *images, int count)
// Set title for window // Set title for window
void SetWindowTitle(const char *title) void SetWindowTitle(const char *title)
{ {
RGFW_window_setName(platform.window, (char*)title);
RGFW_window_setName(platform.window, (char *)title);
CORE.Window.title = title; CORE.Window.title = title;
} }
@ -542,9 +553,9 @@ void SetWindowFocused(void)
void *GetWindowHandle(void) void *GetWindowHandle(void)
{ {
#ifdef RGFW_WEBASM #ifdef RGFW_WEBASM
return (void*)platform.window->src.ctx;
return (void *)platform.window->src.ctx;
#else #else
return (void*)platform.window->src.window;
return (void *)platform.window->src.window;
#endif #endif
} }
@ -587,7 +598,7 @@ Vector2 GetMonitorPosition(int monitor)
{ {
RGFW_monitor *mons = RGFW_getMonitors(); RGFW_monitor *mons = RGFW_getMonitors();
return (Vector2){(float)mons[monitor].rect.x, (float)mons[monitor].rect.y};
return (Vector2){ (float)mons[monitor].rect.x, (float)mons[monitor].rect.y };
} }
// Get selected monitor width (currently used by monitor) // Get selected monitor width (currently used by monitor)
@ -609,9 +620,9 @@ int GetMonitorHeight(int monitor)
// Get selected monitor physical width in millimetres // Get selected monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor) int GetMonitorPhysicalWidth(int monitor)
{ {
RGFW_monitor* mons = RGFW_getMonitors();
RGFW_monitor *mons = RGFW_getMonitors();
return p">(int)mons[monitor].physW;
return mons[monitor].physW;
} }
// Get selected monitor physical height in millimetres // Get selected monitor physical height in millimetres
@ -654,7 +665,7 @@ Vector2 GetWindowScaleDPI(void)
// Set clipboard text content // Set clipboard text content
void SetClipboardText(const char *text) void SetClipboardText(const char *text)
{ {
RGFW_writeClipboard(text, p">(u32)strlen(text));
RGFW_writeClipboard(text, strlen(text));
} }
// Get clipboard text content // Get clipboard text content
@ -672,7 +683,7 @@ const char *GetClipboardText(void)
#define WINGDI_ALREADY_INCLUDED #define WINGDI_ALREADY_INCLUDED
#include "../external/win32_clipboard.h" #include "../external/win32_clipboard.h"
#endif #endif
#endif // SUPPORT_CLIPBOARD_IMAGE
#endif
// Get clipboard image // Get clipboard image
Image GetClipboardImage(void) Image GetClipboardImage(void)
@ -683,15 +694,13 @@ Image GetClipboardImage(void)
#if defined(_WIN32) #if defined(_WIN32)
unsigned long long int dataSize = 0; unsigned long long int dataSize = 0;
void *fileData = NULL; void *fileData = NULL;
int width = 0;
int height = 0;
fileData = (void*)Win32GetClipboardImageData(&width, &height, &dataSize);
int width, height;
fileData = (void *)Win32GetClipboardImageData(&width, &height, &dataSize);
if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data."); if (fileData == NULL) TRACELOG(LOG_WARNING, "Clipboard image: Couldn't get clipboard data.");
else image = LoadImageFromMemory(".bmp", fileData, p">(int)dataSize);
else image = LoadImageFromMemory(".bmp", fileData, dataSize);
#else #else
TRACELOG(LOG_WARNING, "GetClipboardImage() not implemented on target platform");
TRACELOG(LOG_WARNING, "Clipboard image: PLATFORM_DESKTOP_RGFW does not implement `GetClipboardImage()` for this OS");
#endif #endif
#endif // SUPPORT_CLIPBOARD_IMAGE #endif // SUPPORT_CLIPBOARD_IMAGE
@ -780,6 +789,12 @@ int SetGamepadMappings(const char *mappings)
return 0; return 0;
} }
// Set gamepad vibration
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration)
{
TRACELOG(LOG_WARNING, "GamepadSetVibration() not available on target platform");
}
// Set mouse position XY // Set mouse position XY
void SetMousePosition(int x, int y) void SetMousePosition(int x, int y)
{ {
@ -855,6 +870,28 @@ char RSGL_keystrToChar(const char *str)
return '\0'; return '\0';
} }
int RGFW_gpConvTable[18] = {
[RGFW_GP_Y] = GAMEPAD_BUTTON_RIGHT_FACE_UP,
[RGFW_GP_B] = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT,
[RGFW_GP_A] = GAMEPAD_BUTTON_RIGHT_FACE_DOWN,
[RGFW_GP_X] = GAMEPAD_BUTTON_RIGHT_FACE_LEFT,
[RGFW_GP_L1] = GAMEPAD_BUTTON_LEFT_TRIGGER_1,
[RGFW_GP_R1] = GAMEPAD_BUTTON_RIGHT_TRIGGER_1,
[RGFW_GP_L2] = GAMEPAD_BUTTON_LEFT_TRIGGER_2,
[RGFW_GP_R2] = GAMEPAD_BUTTON_RIGHT_TRIGGER_2,
[RGFW_GP_SELECT] = GAMEPAD_BUTTON_MIDDLE_LEFT,
[RGFW_GP_HOME] = GAMEPAD_BUTTON_MIDDLE,
[RGFW_GP_START] = GAMEPAD_BUTTON_MIDDLE_RIGHT,
[RGFW_GP_UP] = GAMEPAD_BUTTON_LEFT_FACE_UP,
[RGFW_GP_RIGHT] = GAMEPAD_BUTTON_LEFT_FACE_RIGHT,
[RGFW_GP_DOWN] = GAMEPAD_BUTTON_LEFT_FACE_DOWN,
[RGFW_GP_LEFT] = GAMEPAD_BUTTON_LEFT_FACE_LEFT,
[RGFW_GP_L3] = GAMEPAD_BUTTON_LEFT_THUMB,
[RGFW_GP_R3] = GAMEPAD_BUTTON_RIGHT_THUMB,
};
// Register all input events // Register all input events
void PollInputEvents(void) void PollInputEvents(void)
{ {
@ -863,7 +900,7 @@ void PollInputEvents(void)
// because ProcessGestureEvent() is just called on an event, not every frame // because ProcessGestureEvent() is just called on an event, not every frame
UpdateGestures(); UpdateGestures();
#endif #endif
// Reset keys/chars pressed registered // Reset keys/chars pressed registered
CORE.Input.Keyboard.keyPressedQueueCount = 0; CORE.Input.Keyboard.keyPressedQueueCount = 0;
CORE.Input.Keyboard.charPressedQueueCount = 0; CORE.Input.Keyboard.charPressedQueueCount = 0;
@ -927,27 +964,27 @@ void PollInputEvents(void)
while (RGFW_window_checkEvent(platform.window)) while (RGFW_window_checkEvent(platform.window))
{ {
if ((platform.window->event.type >= RGFW_jsButtonPressed) && (platform.window->event.type <= RGFW_jsAxisMove))
if ((platform.window->event.type >= RGFW_gpButtonPressed) && (platform.window->event.type <= RGFW_gpAxisMove))
{ {
if (!CORE.Input.Gamepad.ready[platform.window->event.joystick])
if (!CORE.Input.Gamepad.ready[platform.window->event.gamepad])
{ {
CORE.Input.Gamepad.ready[platform.window->event.joystick] = true;
CORE.Input.Gamepad.axisCount[platform.window->event.joystick] = platform.window->event.axisesCount;
CORE.Input.Gamepad.name[platform.window->event.joystick][0] = '\0';
CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
CORE.Input.Gamepad.axisState[platform.window->event.joystick][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
CORE.Input.Gamepad.ready[platform.window->event.gamepad] = true;
CORE.Input.Gamepad.axisCount[platform.window->event.gamepad] = platform.window->event.axisesCount;
CORE.Input.Gamepad.name[platform.window->event.gamepad][0] = '\0';
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f;
CORE.Input.Gamepad.axisState[platform.window->event.gamepad][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f;
} }
} }
RGFW_Event *event = &platform.window->event; RGFW_Event *event = &platform.window->event;
// All input events can be processed after polling // All input events can be processed after polling
switch (event->type)
switch (event->type)
{ {
case RGFW_quit: CORE.Window.shouldClose = true; break; case RGFW_quit: CORE.Window.shouldClose = true; break;
case RGFW_dnd: // Dropped file case RGFW_dnd: // Dropped file
{ {
for (n">u32 i = 0; i < event->droppedFilesCount; i++)
for (kt">int i = 0; i < event->droppedFilesCount; i++)
{ {
if (CORE.Window.dropFileCount == 0) if (CORE.Window.dropFileCount == 0)
{ {
@ -958,7 +995,7 @@ void PollInputEvents(void)
CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char));
strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event->droppedFiles[i]); strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event->droppedFiles[i]);
CORE.Window.dropFileCount++; CORE.Window.dropFileCount++;
} }
else if (CORE.Window.dropFileCount < 1024) else if (CORE.Window.dropFileCount < 1024)
@ -992,7 +1029,6 @@ void PollInputEvents(void)
case RGFW_keyPressed: case RGFW_keyPressed:
{ {
KeyboardKey key = ConvertScancodeToKey(event->keyCode); KeyboardKey key = ConvertScancodeToKey(event->keyCode);
if (key != KEY_NULL) if (key != KEY_NULL)
{ {
// If key was up, add it to the key pressed queue // If key was up, add it to the key pressed queue
@ -1031,7 +1067,7 @@ void PollInputEvents(void)
{ {
if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown))
{ {
CORE.Input.Mouse.currentWheelMove.y = p">(float)event->scroll;
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
break; break;
} }
@ -1047,10 +1083,9 @@ void PollInputEvents(void)
} break; } break;
case RGFW_mouseButtonReleased: case RGFW_mouseButtonReleased:
{ {
if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown)) if ((event->button == RGFW_mouseScrollUp) || (event->button == RGFW_mouseScrollDown))
{ {
CORE.Input.Mouse.currentWheelMove.y = p">(float)event->scroll;
CORE.Input.Mouse.currentWheelMove.y = event->scroll;
break; break;
} }
@ -1081,124 +1116,53 @@ void PollInputEvents(void)
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition;
touchAction = 2; touchAction = 2;
} break; } break;
case RGFW_jsButtonPressed:
case RGFW_gpButtonPressed:
{ {
int button = -1;
switch (event->button)
{
case RGFW_JS_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break;
case RGFW_JS_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
case RGFW_JS_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
case RGFW_JS_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break;
case RGFW_JS_L1: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break;
case RGFW_JS_R1: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break;
case RGFW_JS_L2: button = GAMEPAD_BUTTON_LEFT_TRIGGER_2; break;
case RGFW_JS_R2: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_2; break;
case RGFW_JS_SELECT: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break;
case RGFW_JS_HOME: button = GAMEPAD_BUTTON_MIDDLE; break;
case RGFW_JS_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break;
case RGFW_JS_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break;
case RGFW_JS_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
case RGFW_JS_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break;
case RGFW_JS_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break;
default: break;
}
int button = RGFW_gpConvTable[event->button];
if (button >= 0) if (button >= 0)
{ {
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 1;
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 1;
CORE.Input.Gamepad.lastButtonPressed = button; CORE.Input.Gamepad.lastButtonPressed = button;
} }
} break; } break;
case RGFW_jsButtonReleased:
case RGFW_gpButtonReleased:
{ {
int button = -1;
switch (event->button)
{
case RGFW_JS_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break;
case RGFW_JS_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break;
case RGFW_JS_A: button = GAMEPAD_BUTTON_RIGHT_FACE_DOWN; break;
case RGFW_JS_X: button = GAMEPAD_BUTTON_RIGHT_FACE_LEFT; break;
case RGFW_JS_L1: button = GAMEPAD_BUTTON_LEFT_TRIGGER_1; break;
case RGFW_JS_R1: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_1; break;
case RGFW_JS_L2: button = GAMEPAD_BUTTON_LEFT_TRIGGER_2; break;
case RGFW_JS_R2: button = GAMEPAD_BUTTON_RIGHT_TRIGGER_2; break;
case RGFW_JS_SELECT: button = GAMEPAD_BUTTON_MIDDLE_LEFT; break;
case RGFW_JS_HOME: button = GAMEPAD_BUTTON_MIDDLE; break;
case RGFW_JS_START: button = GAMEPAD_BUTTON_MIDDLE_RIGHT; break;
case RGFW_JS_UP: button = GAMEPAD_BUTTON_LEFT_FACE_UP; break;
case RGFW_JS_RIGHT: button = GAMEPAD_BUTTON_LEFT_FACE_RIGHT; break;
case RGFW_JS_DOWN: button = GAMEPAD_BUTTON_LEFT_FACE_DOWN; break;
case RGFW_JS_LEFT: button = GAMEPAD_BUTTON_LEFT_FACE_LEFT; break;
default: break;
}
int button = RGFW_gpConvTable[event->button];
if (button >= 0)
{
CORE.Input.Gamepad.currentButtonState[event->joystick][button] = 0;
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
}
CORE.Input.Gamepad.currentButtonState[event->gamepad][button] = 0;
if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
} break; } break;
case RGFW_jsAxisMove:
case RGFW_gpAxisMove:
{ {
int axis = -1; int axis = -1;
for (int i = 0; i < event->axisesCount; i++)
{
switch(i)
{
case 0:
{
if (abs(event->axis[i].x) > abs(event->axis[i].y))
{
axis = GAMEPAD_AXIS_LEFT_X;
break;
}
axis = GAMEPAD_AXIS_LEFT_Y;
} break;
case 1:
{
if (abs(event->axis[i].x) > abs(event->axis[i].y))
{
axis = GAMEPAD_AXIS_RIGHT_X;
break;
}
axis = GAMEPAD_AXIS_RIGHT_Y;
} break;
case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER; break;
case 3: axis = GAMEPAD_AXIS_RIGHT_TRIGGER; break;
default: break;
}
#ifdef __linux__
float value = (event->axis[i].x + event->axis[i].y)/(float)32767;
#else
float value = (event->axis[i].x + -event->axis[i].y)/(float)32767;
#endif
CORE.Input.Gamepad.axisState[event->joystick][axis] = value;
// Register button state for triggers in addition to their axes
if ((axis == GAMEPAD_AXIS_LEFT_TRIGGER) || (axis == GAMEPAD_AXIS_RIGHT_TRIGGER))
{
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;
}
}
float value = 0;
switch(event->whichAxis)
{
case 0:
{
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_X] = event->axis[0].x / 100.0f;
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_LEFT_Y] = event->axis[0].y / 100.0f;
} break;
case 1:
{
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_X] = event->axis[1].x / 100.0f;
CORE.Input.Gamepad.axisState[event->gamepad][GAMEPAD_AXIS_RIGHT_Y] = event->axis[1].y / 100.0f;
} break;
case 2: axis = GAMEPAD_AXIS_LEFT_TRIGGER;
case 3:
{
if (axis == -1) axis = GAMEPAD_AXIS_RIGHT_TRIGGER;
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->gamepad][button] = pressed;
if (pressed) CORE.Input.Gamepad.lastButtonPressed = button;
else if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0;
}
default: break;
}
} break; } break;
default: break; default: break;
} }
@ -1283,17 +1247,22 @@ int InitPlatform(void)
platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags); platform.window = RGFW_createWindow(CORE.Window.title, RGFW_RECT(0, 0, CORE.Window.screen.width, CORE.Window.screen.height), flags);
#ifndef PLATFORM_WEB_RGFW
RGFW_area screenSize = RGFW_getScreenSize(); RGFW_area screenSize = RGFW_getScreenSize();
CORE.Window.display.width = screenSize.w; CORE.Window.display.width = screenSize.w;
CORE.Window.display.height = screenSize.h; CORE.Window.display.height = screenSize.h;
/*
I think this is needed by Raylib now ?
#else
CORE.Window.display.width = CORE.Window.screen.width;
CORE.Window.display.height = CORE.Window.screen.height;
#endif
/*
I think this is needed by Raylib now ?
If so, rcore_destkop_sdl should be updated too If so, rcore_destkop_sdl should be updated too
*/ */
SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
//SetupFramebuffer(CORE.Window.display.width, CORE.Window.display.height);
if (CORE.Window.flags & FLAG_VSYNC_HINT) RGFW_window_swapInterval(platform.window, 1);
RGFW_window_makeCurrent(platform.window); RGFW_window_makeCurrent(platform.window);
// Check surface and context activation // Check surface and context activation
@ -1305,12 +1274,6 @@ int InitPlatform(void)
CORE.Window.render.height = CORE.Window.screen.height; CORE.Window.render.height = CORE.Window.screen.height;
CORE.Window.currentFbo.width = CORE.Window.render.width; CORE.Window.currentFbo.width = CORE.Window.render.width;
CORE.Window.currentFbo.height = CORE.Window.render.height; CORE.Window.currentFbo.height = CORE.Window.render.height;
TRACELOG(LOG_INFO, "DISPLAY: Device initialized successfully");
TRACELOG(LOG_INFO, " > Display size: %i x %i", CORE.Window.display.width, CORE.Window.display.height);
TRACELOG(LOG_INFO, " > Screen size: %i x %i", CORE.Window.screen.width, CORE.Window.screen.height);
TRACELOG(LOG_INFO, " > Render size: %i x %i", CORE.Window.render.width, CORE.Window.render.height);
TRACELOG(LOG_INFO, " > Viewport offsets: %i, %i", CORE.Window.renderOffset.x, CORE.Window.renderOffset.y);
} }
else else
{ {
@ -1336,7 +1299,7 @@ int InitPlatform(void)
// Load OpenGL extensions // Load OpenGL extensions
// NOTE: GL procedures address loader is required to load extensions // NOTE: GL procedures address loader is required to load extensions
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
rlLoadExtensions((void*)RGFW_getProcAddress);
rlLoadExtensions((void *)RGFW_getProcAddress);
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// TODO: Initialize input events system // TODO: Initialize input events system
@ -1360,12 +1323,11 @@ int InitPlatform(void)
#ifdef RGFW_X11 #ifdef RGFW_X11
for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++) for (int i = 0; (i < 4) && (i < MAX_GAMEPADS); i++)
{ {
RGFW_registerJoystick(platform.window, i);
RGFW_registergamepad(platform.window, i);
} }
#endif #endif
TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully"); TRACELOG(LOG_INFO, "PLATFORM: CUSTOM: Initialized successfully");
return 0; return 0;
} }
@ -1379,6 +1341,6 @@ void ClosePlatform(void)
static KeyboardKey ConvertScancodeToKey(u32 keycode) static KeyboardKey ConvertScancodeToKey(u32 keycode)
{ {
if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0; if (keycode > sizeof(keyMappingRGFW)/sizeof(unsigned short)) return 0;
return keyMappingRGFW[keycode];
return keyMappingRGFW[keycode];
} }

+ 66
- 15
src/platforms/rcore_desktop_sdl.c 查看文件

@ -68,7 +68,7 @@
#define MAX_CLIPBOARD_BUFFER_LENGTH 1024 // Size of the clipboard buffer used on GetClipboardText() #define MAX_CLIPBOARD_BUFFER_LENGTH 1024 // Size of the clipboard buffer used on GetClipboardText()
#endif #endif
#if ((defined(SDL_MAJOR_VERSION) && SDL_MAJOR_VERSION == 3) && (defined(SDL_MINOR_VERSION) && SDL_MINOR_VERSION >= 1))
#if ((defined(SDL_MAJOR_VERSION) && (SDL_MAJOR_VERSION == 3)) && (defined(SDL_MINOR_VERSION) && (SDL_MINOR_VERSION >= 1)))
#ifndef PLATFORM_DESKTOP_SDL3 #ifndef PLATFORM_DESKTOP_SDL3
#define PLATFORM_DESKTOP_SDL3 #define PLATFORM_DESKTOP_SDL3
#endif #endif
@ -405,7 +405,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
// Since SDL2 doesn't have this function we leave a stub // Since SDL2 doesn't have this function we leave a stub
// SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3) // SDL_GetClipboardData function is available since SDL 3.1.3. (e.g. SDL3)
void* SDL_GetClipboardData(const char *mime_type, size_t *size)
void *SDL_GetClipboardData(const char *mime_type, size_t *size)
{ {
TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3"); TRACELOG(LOG_WARNING, "Getting clipboard data that is not text is only available in SDL3");
@ -497,20 +497,21 @@ void ToggleBorderlessWindowed(void)
void MaximizeWindow(void) void MaximizeWindow(void)
{ {
SDL_MaximizeWindow(platform.window); SDL_MaximizeWindow(platform.window);
CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED;
k">if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED;
} }
// Set window state: minimized // Set window state: minimized
void MinimizeWindow(void) void MinimizeWindow(void)
{ {
SDL_MinimizeWindow(platform.window); SDL_MinimizeWindow(platform.window);
CORE.Window.flags |= FLAG_WINDOW_MINIMIZED;
k">if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED;
} }
// Set window state: not minimized/maximized // Set window state: not minimized/maximized
void RestoreWindow(void) void RestoreWindow(void)
{ {
SDL_ShowWindow(platform.window);
SDL_RestoreWindow(platform.window);
// CORE.Window.flags will be removed on PollInputEvents()
} }
// Set window configuration state using flags // Set window configuration state using flags
@ -1426,7 +1427,7 @@ void PollInputEvents(void)
// Window events are also polled (Minimized, maximized, close...) // Window events are also polled (Minimized, maximized, close...)
#ifndef PLATFORM_DESKTOP_SDL3
#ifndef PLATFORM_DESKTOP_SDL3
// SDL3 states: // SDL3 states:
// The SDL_WINDOWEVENT_* events have been moved to top level events, // The SDL_WINDOWEVENT_* events have been moved to top level events,
// and SDL_WINDOWEVENT has been removed. // and SDL_WINDOWEVENT has been removed.
@ -1436,7 +1437,7 @@ void PollInputEvents(void)
{ {
switch (event.window.event) switch (event.window.event)
{ {
#endif
#endif
case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_RESIZED:
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
{ {
@ -1448,7 +1449,24 @@ void PollInputEvents(void)
CORE.Window.currentFbo.width = width; CORE.Window.currentFbo.width = width;
CORE.Window.currentFbo.height = height; CORE.Window.currentFbo.height = height;
CORE.Window.resizedLastFrame = true; CORE.Window.resizedLastFrame = true;
#ifndef PLATFORM_DESKTOP_SDL3
// Manually detect if the window was maximized (due to SDL2 restore being unreliable on some platforms) to remove the FLAG_WINDOW_MAXIMIZED accordingly
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) > 0)
{
int borderTop = 0;
int borderLeft = 0;
int borderBottom = 0;
int borderRight = 0;
SDL_GetWindowBordersSize(platform.window, &borderTop, &borderLeft, &borderBottom, &borderRight);
SDL_Rect usableBounds;
SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(platform.window), &usableBounds);
if ((width + borderLeft + borderRight != usableBounds.w) && (height + borderTop + borderBottom != usableBounds.h)) CORE.Window.flags &= ~FLAG_WINDOW_MAXIMIZED;
}
#endif
} break; } break;
case SDL_WINDOWEVENT_ENTER: case SDL_WINDOWEVENT_ENTER:
{ {
CORE.Input.Mouse.cursorOnScreen = true; CORE.Input.Mouse.cursorOnScreen = true;
@ -1457,16 +1475,49 @@ void PollInputEvents(void)
{ {
CORE.Input.Mouse.cursorOnScreen = false; CORE.Input.Mouse.cursorOnScreen = false;
} break; } break;
case SDL_WINDOWEVENT_HIDDEN:
case SDL_WINDOWEVENT_MINIMIZED: case SDL_WINDOWEVENT_MINIMIZED:
k">case SDL_WINDOWEVENT_FOCUS_LOST:
case SDL_WINDOWEVENT_SHOWN:
k">case SDL_WINDOWEVENT_FOCUS_GAINED:
p">{
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED;
p">} break;
case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_MAXIMIZED:
{
if ((CORE.Window.flags & FLAG_WINDOW_MAXIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MAXIMIZED;
} break;
case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_RESTORED:
#if defined(PLATFORM_DESKTOP_SDL3)
break;
#else
{
if ((SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MINIMIZED) == 0)
{
if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED;
}
#ifdef PLATFORM_DESKTOP_SDL3
if ((SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MAXIMIZED) == 0)
{
if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED;
}
#endif
} break;
case SDL_WINDOWEVENT_HIDDEN:
{
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) == 0) CORE.Window.flags |= FLAG_WINDOW_HIDDEN;
} break;
case SDL_WINDOWEVENT_SHOWN:
{
if ((CORE.Window.flags & FLAG_WINDOW_HIDDEN) > 0) CORE.Window.flags &= ~FLAG_WINDOW_HIDDEN;
} break;
case SDL_WINDOWEVENT_FOCUS_GAINED:
{
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_UNFOCUSED;
} break;
case SDL_WINDOWEVENT_FOCUS_LOST:
{
if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0) CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED;
} break;
#ifndef PLATFORM_DESKTOP_SDL3
default: break; default: break;
} }
} break; } break;
@ -1971,7 +2022,7 @@ void ClosePlatform(void)
// Scancode to keycode mapping // Scancode to keycode mapping
static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode) static KeyboardKey ConvertScancodeToKey(SDL_Scancode sdlScancode)
{ {
if (sdlScancode >= 0 && sdlScancode < SCANCODE_MAPPED_NUM)
if (p">(sdlScancode >= 0) && p">(sdlScancode < SCANCODE_MAPPED_NUM))
{ {
return mapScancodeToKey[sdlScancode]; return mapScancodeToKey[sdlScancode];
} }

+ 3
- 3
src/platforms/rcore_drm.c 查看文件

@ -1529,7 +1529,7 @@ static void ConfigureEvdevDevice(char *device)
platform.absRange.height = absinfo[ABS_Y].info.maximum - absinfo[ABS_Y].info.minimum; platform.absRange.height = absinfo[ABS_Y].info.maximum - absinfo[ABS_Y].info.minimum;
} }
} }
else if (isGamepad && !isMouse && !isKeyboard && platform.gamepadCount < MAX_GAMEPADS)
else if (isGamepad && !isMouse && !isKeyboard && p">(platform.gamepadCount < MAX_GAMEPADS))
{ {
deviceKindStr = "gamepad"; deviceKindStr = "gamepad";
int index = platform.gamepadCount++; int index = platform.gamepadCount++;
@ -1893,7 +1893,7 @@ static int FindExactConnectorMode(const drmModeConnector *connector, uint width,
TRACELOG(LOG_TRACE, "DISPLAY: DRM Mode %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive"); TRACELOG(LOG_TRACE, "DISPLAY: DRM Mode %d %ux%u@%u %s", i, mode->hdisplay, mode->vdisplay, mode->vrefresh, (mode->flags & DRM_MODE_FLAG_INTERLACE)? "interlaced" : "progressive");
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && p">(!allowInterlaced)) continue;
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced) continue;
if ((mode->hdisplay == width) && (mode->vdisplay == height) && (mode->vrefresh == fps)) return i; if ((mode->hdisplay == width) && (mode->vdisplay == height) && (mode->vrefresh == fps)) return i;
} }
@ -1923,7 +1923,7 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
continue; continue;
} }
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && p">(!allowInterlaced))
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && !allowInterlaced)
{ {
TRACELOG(LOG_TRACE, "DISPLAY: DRM shouldn't choose an interlaced mode"); TRACELOG(LOG_TRACE, "DISPLAY: DRM shouldn't choose an interlaced mode");
continue; continue;

+ 6
- 0
src/platforms/rcore_template.c 查看文件

@ -381,6 +381,12 @@ int SetGamepadMappings(const char *mappings)
return 0; return 0;
} }
// Set gamepad vibration
void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration)
{
TRACELOG(LOG_WARNING, "GamepadSetVibration() not implemented on target platform");
}
// Set mouse position XY // Set mouse position XY
void SetMousePosition(int x, int y) void SetMousePosition(int x, int y)
{ {

+ 5
- 5
src/platforms/rcore_web.c 查看文件

@ -319,7 +319,7 @@ void ToggleBorderlessWindowed(void)
// Set window state: maximized, if resizable // Set window state: maximized, if resizable
void MaximizeWindow(void) void MaximizeWindow(void)
{ {
if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE && !(CORE.Window.flags & FLAG_WINDOW_MAXIMIZED))
if (p">(glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && !(CORE.Window.flags & FLAG_WINDOW_MAXIMIZED))
{ {
platform.unmaximizedWidth = CORE.Window.screen.width; platform.unmaximizedWidth = CORE.Window.screen.width;
platform.unmaximizedHeight = CORE.Window.screen.height; platform.unmaximizedHeight = CORE.Window.screen.height;
@ -342,7 +342,7 @@ void MinimizeWindow(void)
// Set window state: not minimized/maximized // Set window state: not minimized/maximized
void RestoreWindow(void) void RestoreWindow(void)
{ {
if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED))
if (p">(glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED))
{ {
if (platform.unmaximizedWidth && platform.unmaximizedHeight) glfwSetWindowSize(platform.handle, platform.unmaximizedWidth, platform.unmaximizedHeight); if (platform.unmaximizedWidth && platform.unmaximizedHeight) glfwSetWindowSize(platform.handle, platform.unmaximizedWidth, platform.unmaximizedHeight);
@ -1664,10 +1664,10 @@ static EM_BOOL EmscriptenResizeCallback(int eventType, const EmscriptenUiEvent *
int height = EM_ASM_INT( return window.innerHeight; ); int height = EM_ASM_INT( return window.innerHeight; );
if (width < (int)CORE.Window.screenMin.width) width = CORE.Window.screenMin.width; if (width < (int)CORE.Window.screenMin.width) width = CORE.Window.screenMin.width;
else if (width > (int)CORE.Window.screenMax.width && CORE.Window.screenMax.width > 0) width = CORE.Window.screenMax.width;
else if (p">(width > (int)CORE.Window.screenMax.width) && p">(CORE.Window.screenMax.width > 0)) width = CORE.Window.screenMax.width;
if (height < (int)CORE.Window.screenMin.height) height = CORE.Window.screenMin.height; if (height < (int)CORE.Window.screenMin.height) height = CORE.Window.screenMin.height;
else if (height > (int)CORE.Window.screenMax.height && CORE.Window.screenMax.height > 0) height = CORE.Window.screenMax.height;
else if (p">(height > (int)CORE.Window.screenMax.height) && p">(CORE.Window.screenMax.height > 0)) height = CORE.Window.screenMax.height;
emscripten_set_canvas_element_size("#canvas", width, height); emscripten_set_canvas_element_size("#canvas", width, height);
@ -1722,7 +1722,7 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
for (int i = 0; i < gamepadEvent->numButtons; ++i) TRACELOGD("Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]); for (int i = 0; i < gamepadEvent->numButtons; ++i) TRACELOGD("Button %d: Digital: %d, Analog: %g", i, gamepadEvent->digitalButton[i], gamepadEvent->analogButton[i]);
*/ */
if (p">(gamepadEvent->connected) && (gamepadEvent->index < MAX_GAMEPADS))
if (gamepadEvent->connected && (gamepadEvent->index < MAX_GAMEPADS))
{ {
CORE.Input.Gamepad.ready[gamepadEvent->index] = true; CORE.Input.Gamepad.ready[gamepadEvent->index] = true;
sprintf(CORE.Input.Gamepad.name[gamepadEvent->index], "%s", gamepadEvent->id); sprintf(CORE.Input.Gamepad.name[gamepadEvent->index], "%s", gamepadEvent->id);

+ 62
- 63
src/raylib.h 查看文件

@ -1155,20 +1155,19 @@ RLAPI unsigned char *CompressData(const unsigned char *data, int dataSize, int *
RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree() RLAPI unsigned char *DecompressData(const unsigned char *compData, int compDataSize, int *dataSize); // Decompress data (DEFLATE algorithm), memory must be MemFree()
RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree() RLAPI char *EncodeDataBase64(const unsigned char *data, int dataSize, int *outputSize); // Encode data to Base64 string, memory must be MemFree()
RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree() RLAPI unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize); // Decode Base64 string data, memory must be MemFree()
RLAPI unsigned int ComputeCRC32(unsigned char *data, int dataSize); // Compute CRC32 hash code
RLAPI unsigned int *ComputeMD5(unsigned char *data, int dataSize); // Compute MD5 hash code, returns static int[4] (16 bytes)
RLAPI unsigned int *ComputeSHA1(unsigned char *data, int dataSize); // Compute SHA1 hash code, returns static int[5] (20 bytes)
RLAPI unsigned int ComputeCRC32(unsigned char *data, int dataSize); // Compute CRC32 hash code
RLAPI unsigned int *ComputeMD5(unsigned char *data, int dataSize); // Compute MD5 hash code, returns static int[4] (16 bytes)
RLAPI unsigned int *ComputeSHA1(unsigned char *data, int dataSize); // Compute SHA1 hash code, returns static int[5] (20 bytes)
// Automation events functionality // Automation events functionality
RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS
RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file
RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file
RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to
RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording
RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set)
RLAPI void StopAutomationEventRecording(void); // Stop recording automation events
RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event
RLAPI AutomationEventList LoadAutomationEventList(const char *fileName); // Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS
RLAPI void UnloadAutomationEventList(AutomationEventList list); // Unload automation events list from file
RLAPI bool ExportAutomationEventList(AutomationEventList list, const char *fileName); // Export automation events list as text file
RLAPI void SetAutomationEventList(AutomationEventList *list); // Set automation event list to record to
RLAPI void SetAutomationEventBaseFrame(int frame); // Set automation event internal base frame to start recording
RLAPI void StartAutomationEventRecording(void); // Start recording automation events (AutomationEventList must be set)
RLAPI void StopAutomationEventRecording(void); // Stop recording automation events
RLAPI void PlayAutomationEvent(AutomationEvent event); // Play a recorded automation event
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Input Handling Functions (Module: core) // Input Handling Functions (Module: core)
@ -1186,16 +1185,16 @@ RLAPI const char *GetKeyName(int key); // Get name of a Q
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC) RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
// Input-related functions: gamepads // Input-related functions: gamepads
RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once
RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed
RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once
RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed
RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
RLAPI const char *GetGamepadName(int gamepad); // Get gamepad internal name id
RLAPI bool IsGamepadButtonPressed(int gamepad, int button); // Check if a gamepad button has been pressed once
RLAPI bool IsGamepadButtonDown(int gamepad, int button); // Check if a gamepad button is being pressed
RLAPI bool IsGamepadButtonReleased(int gamepad, int button); // Check if a gamepad button has been released once
RLAPI bool IsGamepadButtonUp(int gamepad, int button); // Check if a gamepad button is NOT being pressed
RLAPI int GetGamepadButtonPressed(void); // Get the last gamepad button pressed
RLAPI int GetGamepadAxisCount(int gamepad); // Get gamepad axis count for a gamepad
RLAPI float GetGamepadAxisMovement(int gamepad, int axis); // Get axis movement value for a gamepad axis
RLAPI int SetGamepadMappings(const char *mappings); // Set internal gamepad mappings (SDL_GameControllerDB)
RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); // Set gamepad vibration for both motors (duration in seconds) RLAPI void SetGamepadVibration(int gamepad, float leftMotor, float rightMotor, float duration); // Set gamepad vibration for both motors (duration in seconds)
// Input-related functions: mouse // Input-related functions: mouse
@ -1224,19 +1223,19 @@ RLAPI int GetTouchPointCount(void); // Get number of t
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Gestures and Touch Handling Functions (Module: rgestures) // Gestures and Touch Handling Functions (Module: rgestures)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected
RLAPI int GetGestureDetected(void); // Get latest detected gesture
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in seconds
RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
RLAPI float GetGestureDragAngle(void); // Get gesture drag angle
RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle
RLAPI void SetGesturesEnabled(unsigned int flags); // Enable a set of gestures using flags
RLAPI bool IsGestureDetected(unsigned int gesture); // Check if a gesture have been detected
RLAPI int GetGestureDetected(void); // Get latest detected gesture
RLAPI float GetGestureHoldDuration(void); // Get gesture hold time in seconds
RLAPI Vector2 GetGestureDragVector(void); // Get gesture drag vector
RLAPI float GetGestureDragAngle(void); // Get gesture drag angle
RLAPI Vector2 GetGesturePinchVector(void); // Get gesture pinch delta
RLAPI float GetGesturePinchAngle(void); // Get gesture pinch angle
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Camera System Functions (Module: rcamera) // Camera System Functions (Module: rcamera)
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode
RLAPI void UpdateCamera(Camera *camera, int mode); // Update camera position for selected mode
RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, float zoom); // Update camera movement/rotation
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
@ -1245,9 +1244,9 @@ RLAPI void UpdateCameraPro(Camera *camera, Vector3 movement, Vector3 rotation, f
// Set texture and rectangle to be used on shapes drawing // Set texture and rectangle to be used on shapes drawing
// NOTE: It can be useful when using basic shapes and one single font, // NOTE: It can be useful when using basic shapes and one single font,
// defining a font char white rectangle would allow drawing everything in a single draw call // defining a font char white rectangle would allow drawing everything in a single draw call
RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing
RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing
RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing
RLAPI void SetShapesTexture(Texture2D texture, Rectangle source); // Set texture and rectangle to be used on shapes drawing
RLAPI Texture2D GetShapesTexture(void); // Get texture that is used for shapes drawing
RLAPI Rectangle GetShapesTextureRectangle(void); // Get texture source rectangle that is used for shapes drawing
// Basic shapes drawing functions // Basic shapes drawing functions
RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel using geometry [Can be slow, use with care] RLAPI void DrawPixel(int posX, int posY, Color color); // Draw a pixel using geometry [Can be slow, use with care]
@ -1289,11 +1288,11 @@ RLAPI void DrawPolyLines(Vector2 center, int sides, float radius, float rotation
RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters RLAPI void DrawPolyLinesEx(Vector2 center, int sides, float radius, float rotation, float lineThick, Color color); // Draw a polygon outline of n sides with extended parameters
// Splines drawing functions // Splines drawing functions
RLAPI void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points
RLAPI void DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points
RLAPI void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points
RLAPI void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]
RLAPI void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]
RLAPI void DrawSplineLinear(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Linear, minimum 2 points
RLAPI void DrawSplineBasis(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: B-Spline, minimum 4 points
RLAPI void DrawSplineCatmullRom(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Catmull-Rom, minimum 4 points
RLAPI void DrawSplineBezierQuadratic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Quadratic Bezier, minimum 3 points (1 control point): [p1, c2, p3, c4...]
RLAPI void DrawSplineBezierCubic(const Vector2 *points, int pointCount, float thick, Color color); // Draw spline: Cubic Bezier, minimum 4 points (2 control points): [p1, c2, c3, p4, c5, c6...]
RLAPI void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); // Draw spline segment: Linear, 2 points RLAPI void DrawSplineSegmentLinear(Vector2 p1, Vector2 p2, float thick, Color color); // Draw spline segment: Linear, 2 points
RLAPI void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: B-Spline, 4 points RLAPI void DrawSplineSegmentBasis(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: B-Spline, 4 points
RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: Catmull-Rom, 4 points RLAPI void DrawSplineSegmentCatmullRom(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, float thick, Color color); // Draw spline segment: Catmull-Rom, 4 points
@ -1492,15 +1491,15 @@ RLAPI GlyphInfo GetGlyphInfo(Font font, int codepoint);
RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found RLAPI Rectangle GetGlyphAtlasRec(Font font, int codepoint); // Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found
// Text codepoints management functions (unicode characters) // Text codepoints management functions (unicode characters)
RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array
RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array
RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory
RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string
RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
RLAPI char *LoadUTF8(const int *codepoints, int length); // Load UTF-8 text encoded from codepoints array
RLAPI void UnloadUTF8(char *text); // Unload UTF-8 text encoded from codepoints array
RLAPI int *LoadCodepoints(const char *text, int *count); // Load all codepoints from a UTF-8 text string, codepoints count returned by parameter
RLAPI void UnloadCodepoints(int *codepoints); // Unload codepoints data from memory
RLAPI int GetCodepointCount(const char *text); // Get total number of codepoints in a UTF-8 encoded string
RLAPI int GetCodepoint(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI int GetCodepointNext(const char *text, int *codepointSize); // Get next codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI int GetCodepointPrevious(const char *text, int *codepointSize); // Get previous codepoint in a UTF-8 encoded string, 0x3f('?') is returned on failure
RLAPI const char *CodepointToUTF8(int codepoint, int *utf8Size); // Encode one codepoint into UTF-8 byte array (array length returned as parameter)
// Text strings management functions (no UTF-8 strings, only byte chars) // Text strings management functions (no UTF-8 strings, only byte chars)
// NOTE: Some strings allocate memory internally for returned strings, just be careful! // NOTE: Some strings allocate memory internally for returned strings, just be careful!
@ -1515,14 +1514,14 @@ RLAPI const char *TextJoin(const char **textList, int count, const char *delimit
RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings RLAPI const char **TextSplit(const char *text, char delimiter, int *count); // Split text into multiple strings
RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor! RLAPI void TextAppend(char *text, const char *append, int *position); // Append text at specific position and move cursor!
RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string RLAPI int TextFindIndex(const char *text, const char *find); // Find first text occurrence within a string
RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string
RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string
RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string
RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string
RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string
RLAPI const char *TextToUpper(const char *text); // Get upper case version of provided string
RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string
RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string
RLAPI const char *TextToSnake(const char *text); // Get Snake case notation version of provided string
RLAPI const char *TextToCamel(const char *text); // Get Camel case notation version of provided string
RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported)
RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported)
RLAPI int TextToInteger(const char *text); // Get integer value from text
RLAPI float TextToFloat(const char *text); // Get float value from text
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Basic 3d Shapes Drawing Functions (Module: models) // Basic 3d Shapes Drawing Functions (Module: models)
@ -1615,14 +1614,14 @@ RLAPI void UnloadModelAnimations(ModelAnimation *animations, int animCount);
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match
// Collision detection functions // Collision detection functions
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere
RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere
RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box
RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh
RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle
RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Check collision between two spheres
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Check collision between two bounding boxes
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Check collision between box and sphere
RLAPI RayCollision GetRayCollisionSphere(Ray ray, Vector3 center, float radius); // Get collision info between ray and sphere
RLAPI RayCollision GetRayCollisionBox(Ray ray, BoundingBox box); // Get collision info between ray and box
RLAPI RayCollision GetRayCollisionMesh(Ray ray, Mesh mesh, Matrix transform); // Get collision info between ray and mesh
RLAPI RayCollision GetRayCollisionTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle
RLAPI RayCollision GetRayCollisionQuad(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4); // Get collision info between ray and quad
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Audio Loading and Playing Functions (Module: audio) // Audio Loading and Playing Functions (Module: audio)

+ 14
- 5
src/rcore.c 查看文件

@ -12,6 +12,13 @@
* - Windows (Win32, Win64) * - Windows (Win32, Win64)
* - Linux (X11/Wayland desktop mode) * - Linux (X11/Wayland desktop mode)
* - Others (not tested) * - Others (not tested)
* > PLATFORM_DESKTOP_RGFW (RGFW backend):
* - Windows (Win32, Win64)
* - Linux (X11/Wayland desktop mode)
* - macOS/OSX (x64, arm64)
* - Others (not tested)
* > PLATFORM_WEB_RGFW:
* - HTML5 (WebAssembly)
* > PLATFORM_WEB: * > PLATFORM_WEB:
* - HTML5 (WebAssembly) * - HTML5 (WebAssembly)
* > PLATFORM_DRM: * > PLATFORM_DRM:
@ -85,12 +92,12 @@
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Feature Test Macros required for this module // Feature Test Macros required for this module
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_XOPEN_SOURCE < 500)
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_XOPEN_SOURCE < 500)
#undef _XOPEN_SOURCE #undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext. #define _XOPEN_SOURCE 500 // Required for: readlink if compiled with c99 without gnu ext.
#endif #endif
#if (defined(__linux__) || defined(PLATFORM_WEB)) && (_POSIX_C_SOURCE < 199309L)
#if (defined(__linux__) || defined(PLATFORM_WEB) || defined(PLATFORM_WEB_RGFW)) && (_POSIX_C_SOURCE < 199309L)
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext. #define _POSIX_C_SOURCE 199309L // Required for: CLOCK_MONOTONIC if compiled with c99 without gnu ext.
#endif #endif
@ -540,7 +547,7 @@ const char *TextFormat(const char *text, ...); // Formatting of tex
#include "platforms/rcore_desktop_glfw.c" #include "platforms/rcore_desktop_glfw.c"
#elif defined(PLATFORM_DESKTOP_SDL) #elif defined(PLATFORM_DESKTOP_SDL)
#include "platforms/rcore_desktop_sdl.c" #include "platforms/rcore_desktop_sdl.c"
#elif defined(PLATFORM_DESKTOP_RGFW)
#elif (defined(PLATFORM_DESKTOP_RGFW) || defined(PLATFORM_WEB_RGFW))
#include "platforms/rcore_desktop_rgfw.c" #include "platforms/rcore_desktop_rgfw.c"
#elif defined(PLATFORM_WEB) #elif defined(PLATFORM_WEB)
#include "platforms/rcore_web.c" #include "platforms/rcore_web.c"
@ -611,6 +618,8 @@ void InitWindow(int width, int height, const char *title)
TRACELOG(LOG_INFO, "Platform backend: DESKTOP (SDL)"); TRACELOG(LOG_INFO, "Platform backend: DESKTOP (SDL)");
#elif defined(PLATFORM_DESKTOP_RGFW) #elif defined(PLATFORM_DESKTOP_RGFW)
TRACELOG(LOG_INFO, "Platform backend: DESKTOP (RGFW)"); TRACELOG(LOG_INFO, "Platform backend: DESKTOP (RGFW)");
#elif defined(PLATFORM_WEB_RGFW)
TRACELOG(LOG_INFO, "Platform backend: WEB (RGFW) (HTML5)");
#elif defined(PLATFORM_WEB) #elif defined(PLATFORM_WEB)
TRACELOG(LOG_INFO, "Platform backend: WEB (HTML5)"); TRACELOG(LOG_INFO, "Platform backend: WEB (HTML5)");
#elif defined(PLATFORM_DRM) #elif defined(PLATFORM_DRM)
@ -2063,7 +2072,7 @@ const char *GetDirectoryPath(const char *filePath)
// In case provided path does not contain a root drive letter (C:\, D:\) nor leading path separator (\, /), // In case provided path does not contain a root drive letter (C:\, D:\) nor leading path separator (\, /),
// we add the current directory path to dirPath // we add the current directory path to dirPath
if (filePath[1] != ':' && filePath[0] != '\\' && filePath[0] != '/')
if (p">(filePath[1] != ':') && (filePath[0] != '\\') && (filePath[0] != '/'))
{ {
// For security, we set starting path to current directory, // For security, we set starting path to current directory,
// obtained path will be concatenated to this // obtained path will be concatenated to this
@ -3573,7 +3582,7 @@ void SetupViewport(int width, int height)
// NOTE: Global variables CORE.Window.render.width/CORE.Window.render.height and CORE.Window.renderOffset.x/CORE.Window.renderOffset.y can be modified // NOTE: Global variables CORE.Window.render.width/CORE.Window.render.height and CORE.Window.renderOffset.x/CORE.Window.renderOffset.y can be modified
void SetupFramebuffer(int width, int height) void SetupFramebuffer(int width, int height)
{ {
// Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var)
// Calculate CORE.Window.render.width and CORE.Window.render.height, we have the display size (input params) and the desired screen size (global var)
if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height)) if ((CORE.Window.screen.width > CORE.Window.display.width) || (CORE.Window.screen.height > CORE.Window.display.height))
{ {
TRACELOG(LOG_WARNING, "DISPLAY: Downscaling required: Screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height); TRACELOG(LOG_WARNING, "DISPLAY: Downscaling required: Screen size (%ix%i) is bigger than display size (%ix%i)", CORE.Window.screen.width, CORE.Window.screen.height, CORE.Window.display.width, CORE.Window.display.height);

+ 0
- 15
src/rlgl.h 查看文件

@ -1890,16 +1890,6 @@ void rlActiveDrawBuffers(int count)
else else
{ {
unsigned int buffers[8] = { unsigned int buffers[8] = {
#if defined(GRAPHICS_API_OPENGL_ES3)
GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT,
GL_COLOR_ATTACHMENT2_EXT,
GL_COLOR_ATTACHMENT3_EXT,
GL_COLOR_ATTACHMENT4_EXT,
GL_COLOR_ATTACHMENT5_EXT,
GL_COLOR_ATTACHMENT6_EXT,
GL_COLOR_ATTACHMENT7_EXT,
#else
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT2,
@ -1908,14 +1898,9 @@ void rlActiveDrawBuffers(int count)
GL_COLOR_ATTACHMENT5, GL_COLOR_ATTACHMENT5,
GL_COLOR_ATTACHMENT6, GL_COLOR_ATTACHMENT6,
GL_COLOR_ATTACHMENT7, GL_COLOR_ATTACHMENT7,
#endif
}; };
#if defined(GRAPHICS_API_OPENGL_ES3)
glDrawBuffersEXT(count, buffers);
#else
glDrawBuffers(count, buffers); glDrawBuffers(count, buffers);
#endif
} }
} }
else TRACELOG(LOG_WARNING, "GL: One color buffer active by default"); else TRACELOG(LOG_WARNING, "GL: One color buffer active by default");

+ 52
- 26
src/rmodels.c 查看文件

@ -2270,38 +2270,62 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame)
{ {
if (frame >= anim.frameCount) frame = frame%anim.frameCount; if (frame >= anim.frameCount) frame = frame%anim.frameCount;
// Get first mesh which have bones
int firstMeshWithBones = -1;
for (int i = 0; i < model.meshCount; i++) for (int i = 0; i < model.meshCount; i++)
{ {
if (model.meshes[i].boneMatrices) if (model.meshes[i].boneMatrices)
{ {
assert(model.meshes[i].boneCount == anim.boneCount); assert(model.meshes[i].boneCount == anim.boneCount);
if (firstMeshWithBones == -1)
{
firstMeshWithBones = i;
break;
}
}
}
for (int boneId = 0; boneId < model.meshes[i].boneCount; boneId++)
// Update all bones and boneMatrices of first mesh with bones.
for (int boneId = 0; boneId < anim.boneCount; boneId++)
{
Vector3 inTranslation = model.bindPose[boneId].translation;
Quaternion inRotation = model.bindPose[boneId].rotation;
Vector3 inScale = model.bindPose[boneId].scale;
Vector3 outTranslation = anim.framePoses[frame][boneId].translation;
Quaternion outRotation = anim.framePoses[frame][boneId].rotation;
Vector3 outScale = anim.framePoses[frame][boneId].scale;
Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), QuaternionInvert(inRotation));
Quaternion invRotation = QuaternionInvert(inRotation);
Vector3 invScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, inScale);
Vector3 boneTranslation = Vector3Add(
Vector3RotateByQuaternion(Vector3Multiply(outScale, invTranslation),
outRotation), outTranslation);
Quaternion boneRotation = QuaternionMultiply(outRotation, invRotation);
Vector3 boneScale = Vector3Multiply(outScale, invScale);
Matrix boneMatrix = MatrixMultiply(MatrixMultiply(
QuaternionToMatrix(boneRotation),
MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)),
MatrixScale(boneScale.x, boneScale.y, boneScale.z));
model.meshes[firstMeshWithBones].boneMatrices[boneId] = boneMatrix;
}
// Update remaining meshes with bones
// NOTE: Using deep copy because shallow copy results in double free with 'UnloadModel()'
if (firstMeshWithBones != -1)
{
for (int i = firstMeshWithBones + 1; i < model.meshCount; i++)
{
if (model.meshes[i].boneMatrices)
{ {
Vector3 inTranslation = model.bindPose[boneId].translation;
Quaternion inRotation = model.bindPose[boneId].rotation;
Vector3 inScale = model.bindPose[boneId].scale;
Vector3 outTranslation = anim.framePoses[frame][boneId].translation;
Quaternion outRotation = anim.framePoses[frame][boneId].rotation;
Vector3 outScale = anim.framePoses[frame][boneId].scale;
Vector3 invTranslation = Vector3RotateByQuaternion(Vector3Negate(inTranslation), QuaternionInvert(inRotation));
Quaternion invRotation = QuaternionInvert(inRotation);
Vector3 invScale = Vector3Divide((Vector3){ 1.0f, 1.0f, 1.0f }, inScale);
Vector3 boneTranslation = Vector3Add(
Vector3RotateByQuaternion(Vector3Multiply(outScale, invTranslation),
outRotation), outTranslation);
Quaternion boneRotation = QuaternionMultiply(outRotation, invRotation);
Vector3 boneScale = Vector3Multiply(outScale, invScale);
Matrix boneMatrix = MatrixMultiply(MatrixMultiply(
QuaternionToMatrix(boneRotation),
MatrixTranslate(boneTranslation.x, boneTranslation.y, boneTranslation.z)),
MatrixScale(boneScale.x, boneScale.y, boneScale.z));
model.meshes[i].boneMatrices[boneId] = boneMatrix;
memcpy(model.meshes[i].boneMatrices,
model.meshes[firstMeshWithBones].boneMatrices,
model.meshes[i].boneCount * sizeof(model.meshes[i].boneMatrices[0]));
} }
} }
} }
@ -2314,6 +2338,7 @@ void UpdateModelAnimationBones(Model model, ModelAnimation anim, int frame)
void UpdateModelAnimation(Model model, ModelAnimation anim, int frame) void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
{ {
UpdateModelAnimationBones(model,anim,frame); UpdateModelAnimationBones(model,anim,frame);
for (int m = 0; m < model.meshCount; m++) for (int m = 0; m < model.meshCount; m++)
{ {
Mesh mesh = model.meshes[m]; Mesh mesh = model.meshes[m];
@ -2322,8 +2347,9 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
int boneId = 0; int boneId = 0;
int boneCounter = 0; int boneCounter = 0;
float boneWeight = 0.0; float boneWeight = 0.0;
bool updated = false; // Flag to check when anim vertex information is updated
bool updated = false; // Flag to check when anim vertex information is updated
const int vValues = mesh.vertexCount*3; const int vValues = mesh.vertexCount*3;
for (int vCounter = 0; vCounter < vValues; vCounter += 3) for (int vCounter = 0; vCounter < vValues; vCounter += 3)
{ {
mesh.animVertices[vCounter] = 0; mesh.animVertices[vCounter] = 0;

+ 1
- 4
src/rtextures.c 查看文件

@ -833,10 +833,7 @@ Image GenImageGradientLinear(int width, int height, int direction, Color start,
// bottom-right or vice-versa), pixel (0, 0) is the farthest point on the gradient // bottom-right or vice-versa), pixel (0, 0) is the farthest point on the gradient
// (i.e. the pixel which should become one of the gradient's ends color); while for // (i.e. the pixel which should become one of the gradient's ends color); while for
// directions that lie in the second or fourth quadrant, that point is pixel (width, 0). // directions that lie in the second or fourth quadrant, that point is pixel (width, 0).
float maxPosValue =
((signbit(sinDir) != 0) == (signbit(cosDir) != 0))
? fabsf(startingPos)
: fabsf(startingPos+width*cosDir);
float maxPosValue = ((signbit(sinDir) != 0) == (signbit(cosDir) != 0))? fabsf(startingPos) : fabsf(startingPos + width*cosDir);
for (int i = 0; i < width; i++) for (int i = 0; i < width; i++)
{ {
for (int j = 0; j < height; j++) for (int j = 0; j < height; j++)

Loading…
取消
儲存