From d0c39db6c2c996c716ab97e7e486f6e6ac920162 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Sep 2025 13:02:13 +0200 Subject: [PATCH 01/10] Update rlgl.h --- src/rlgl.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rlgl.h b/src/rlgl.h index ec581fcdc..9038e2a48 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -870,6 +870,7 @@ RLAPI void rlLoadDrawQuad(void); // Load and draw a quad #elif defined(GRAPHICS_API_OPENGL_ES2) // NOTE: OpenGL ES 2.0 can be enabled on Desktop platforms, // in that case, functions are loaded from a custom glad for OpenGL ES 2.0 + // TODO: OpenGL ES 2.0 support shouldn't be platform-dependant, neither require GLAD #if defined(PLATFORM_DESKTOP_GLFW) || defined(PLATFORM_DESKTOP_SDL) #define GLAD_GLES2_IMPLEMENTATION #include "external/glad_gles2.h" From 8d3a4b8dd5483c96b04c603569a3c7c0c406c8bc Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Sep 2025 13:03:28 +0200 Subject: [PATCH 02/10] REVIEWED: Renamed `PLATFORM_DESKTOP_SDL3` to `USING_VERSION_SDL3` #5175 Avoid using a new platform flag to address one platform version --- src/platforms/rcore_desktop_sdl.c | 52 +++++++++++++++---------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 33788d720..f07554762 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -85,8 +85,8 @@ #endif #if ((defined(SDL_MAJOR_VERSION) && (SDL_MAJOR_VERSION == 3)) && (defined(SDL_MINOR_VERSION) && (SDL_MINOR_VERSION >= 1))) - #ifndef PLATFORM_DESKTOP_SDL3 - #define PLATFORM_DESKTOP_SDL3 + #ifndef USING_VERSION_SDL3 + #define USING_VERSION_SDL3 #endif #endif @@ -255,7 +255,7 @@ static const int CursorsLUT[] = { }; // SDL3 Migration Layer made to avoid 'ifdefs' inside functions when we can -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) // SDL3 Migration: // SDL_WINDOW_FULLSCREEN_DESKTOP has been removed, @@ -429,7 +429,7 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size) return NULL; } -#endif // PLATFORM_DESKTOP_SDL3 +#endif // USING_VERSION_SDL3 //---------------------------------------------------------------------------------- // Module Internal Functions Declaration @@ -463,7 +463,7 @@ void ToggleFullscreen(void) const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); -#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure +#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -491,7 +491,7 @@ void ToggleBorderlessWindowed(void) const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); -#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure +#if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -548,7 +548,7 @@ void SetWindowState(unsigned int flags) const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); - #if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure + #if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -612,7 +612,7 @@ void SetWindowState(unsigned int flags) const int monitor = SDL_GetWindowDisplayIndex(platform.window); const int monitorCount = SDL_GetNumVideoDisplays(); - #if defined(PLATFORM_DESKTOP_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure + #if defined(USING_VERSION_SDL3) // SDL3 Migration: Monitor is an id instead of index now, returns 0 on failure if ((monitor > 0) && (monitor <= monitorCount)) #else if ((monitor >= 0) && (monitor < monitorCount)) @@ -850,7 +850,7 @@ void SetWindowMonitor(int monitor) const int screenHeight = CORE.Window.screen.height; SDL_Rect usableBounds; - #if defined(PLATFORM_DESKTOP_SDL3) // Different style for success checking + #if defined(USING_VERSION_SDL3) // Different style for success checking if (SDL_GetDisplayUsableBounds(monitor, &usableBounds)) #else if (SDL_GetDisplayUsableBounds(monitor, &usableBounds) == 0) @@ -966,7 +966,7 @@ Vector2 GetMonitorPosition(int monitor) { SDL_Rect displayBounds; - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) if (SDL_GetDisplayUsableBounds(monitor, &displayBounds)) #else if (SDL_GetDisplayUsableBounds(monitor, &displayBounds) == 0) @@ -1098,7 +1098,7 @@ Vector2 GetWindowScaleDPI(void) { Vector2 scale = { 1.0f, 1.0f }; -#ifndef PLATFORM_DESKTOP_SDL3 +#ifndef USING_VERSION_SDL3 // NOTE: SDL_GetWindowDisplayScale was only added on SDL3 // see https://wiki.libsdl.org/SDL3/SDL_GetWindowDisplayScale // TODO: Implement the window scale factor calculation manually @@ -1184,7 +1184,7 @@ Image GetClipboardImage(void) // Show mouse cursor void ShowCursor(void) { -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) SDL_ShowCursor(); #else SDL_ShowCursor(SDL_ENABLE); @@ -1195,7 +1195,7 @@ void ShowCursor(void) // Hides mouse cursor void HideCursor(void) { -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) SDL_HideCursor(); #else SDL_ShowCursor(SDL_DISABLE); @@ -1208,7 +1208,7 @@ void EnableCursor(void) { SDL_SetRelativeMouseMode(SDL_FALSE); -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) // SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible() SDL_ShowCursor(); #else @@ -1309,7 +1309,7 @@ const char *GetKeyName(int key) static void UpdateTouchPointsSDL(SDL_TouchFingerEvent event) { -#if defined(PLATFORM_DESKTOP_SDL3) // SDL3 +#if defined(USING_VERSION_SDL3) // SDL3 int count = 0; SDL_Finger **fingers = SDL_GetTouchFingers(event.touchID, &count); CORE.Input.Touch.pointCount = count; @@ -1436,7 +1436,7 @@ void PollInputEvents(void) CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) // const char *data; /**< The text for SDL_EVENT_DROP_TEXT and the file name for SDL_EVENT_DROP_FILE, NULL for other events */ // Event memory is now managed by SDL, so you should not free the data in SDL_EVENT_DROP_FILE, and if you want to hold onto the text in SDL_EVENT_TEXT_EDITING and SDL_EVENT_TEXT_INPUT events, you should make a copy of it. SDL_TEXTINPUTEVENT_TEXT_SIZE is no longer necessary and has been removed. strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data); @@ -1451,7 +1451,7 @@ void PollInputEvents(void) { CORE.Window.dropFilepaths[CORE.Window.dropFileCount] = (char *)RL_CALLOC(MAX_FILEPATH_LENGTH, sizeof(char)); - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.data); #else strcpy(CORE.Window.dropFilepaths[CORE.Window.dropFileCount], event.drop.file); @@ -1466,7 +1466,7 @@ void PollInputEvents(void) // Window events are also polled (Minimized, maximized, close...) - #ifndef PLATFORM_DESKTOP_SDL3 + #ifndef USING_VERSION_SDL3 // SDL3 states: // The SDL_WINDOWEVENT_* events have been moved to top level events, and SDL_WINDOWEVENT has been removed // In general, handling this change just means checking for the individual events instead of first checking for SDL_WINDOWEVENT @@ -1497,7 +1497,7 @@ void PollInputEvents(void) CORE.Window.currentFbo.height = height; CORE.Window.resizedLastFrame = true; - #ifndef PLATFORM_DESKTOP_SDL3 + #ifndef USING_VERSION_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) { @@ -1538,7 +1538,7 @@ void PollInputEvents(void) if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) > 0) CORE.Window.flags &= ~FLAG_WINDOW_MINIMIZED; } - #ifdef PLATFORM_DESKTOP_SDL3 + #ifdef USING_VERSION_SDL3 if ((SDL_GetWindowFlags(platform.window) & SDL_WINDOW_MAXIMIZED) == 0) { if ((CORE.Window.flags & SDL_WINDOW_MAXIMIZED) > 0) CORE.Window.flags &= ~SDL_WINDOW_MAXIMIZED; @@ -1564,7 +1564,7 @@ void PollInputEvents(void) if ((CORE.Window.flags & FLAG_WINDOW_UNFOCUSED) == 0) CORE.Window.flags |= FLAG_WINDOW_UNFOCUSED; } break; - #ifndef PLATFORM_DESKTOP_SDL3 + #ifndef USING_VERSION_SDL3 default: break; } } break; @@ -1573,7 +1573,7 @@ void PollInputEvents(void) // Keyboard events case SDL_KEYDOWN: { - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) // SDL3 Migration: The following structures have been removed: * SDL_Keysym KeyboardKey key = ConvertScancodeToKey(event.key.scancode); #else @@ -1604,7 +1604,7 @@ void PollInputEvents(void) case SDL_KEYUP: { - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) KeyboardKey key = ConvertScancodeToKey(event.key.scancode); #else KeyboardKey key = ConvertScancodeToKey(event.key.keysym.scancode); @@ -1620,7 +1620,7 @@ void PollInputEvents(void) if (CORE.Input.Keyboard.charPressedQueueCount < MAX_CHAR_PRESSED_QUEUE) { // Add character (codepoint) to the queue - #if defined(PLATFORM_DESKTOP_SDL3) + #if defined(USING_VERSION_SDL3) size_t textLen = strlen(event.text.text); unsigned int codepoint = (unsigned int)SDL_StepUTF8(&event.text.text, &textLen); #else @@ -1991,7 +1991,7 @@ int InitPlatform(void) } // Init window -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) platform.window = SDL_CreateWindow(CORE.Window.title, CORE.Window.screen.width, CORE.Window.screen.height, flags); #else platform.window = SDL_CreateWindow(CORE.Window.title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, CORE.Window.screen.width, CORE.Window.screen.height, flags); @@ -2085,7 +2085,7 @@ int InitPlatform(void) CORE.Storage.basePath = SDL_GetBasePath(); // Alternative: GetWorkingDirectory(); //---------------------------------------------------------------------------- -#if defined(PLATFORM_DESKTOP_SDL3) +#if defined(USING_VERSION_SDL3) TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL3): Initialized successfully"); #else TRACELOG(LOG_INFO, "PLATFORM: DESKTOP (SDL2): Initialized successfully"); From 7db5f56e814c7e91948580e61a9610ff417c3cb1 Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Fri, 12 Sep 2025 04:07:46 -0700 Subject: [PATCH 03/10] [cmake] export automatically raylib definitions and compile/link options (#5179) --- cmake/InstallConfigurations.cmake | 11 +++- cmake/raylib-config.cmake | 83 +------------------------------ src/CMakeLists.txt | 2 +- 3 files changed, 13 insertions(+), 83 deletions(-) diff --git a/cmake/InstallConfigurations.cmake b/cmake/InstallConfigurations.cmake index 6c606e565..84caea2c0 100644 --- a/cmake/InstallConfigurations.cmake +++ b/cmake/InstallConfigurations.cmake @@ -19,9 +19,18 @@ join_paths(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}") join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") configure_file(../raylib.pc.in raylib.pc @ONLY) configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY) +configure_file(../cmake/raylib-config.cmake raylib-config.cmake @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib") -install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/raylib-config.cmake" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib +) +install(EXPORT raylib-targets + FILE raylib-targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/raylib +) # populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS} include(PopulateConfigVariablesLocally) diff --git a/cmake/raylib-config.cmake b/cmake/raylib-config.cmake index 8906ae4d4..f34087ccd 100644 --- a/cmake/raylib-config.cmake +++ b/cmake/raylib-config.cmake @@ -1,81 +1,2 @@ -# - Try to find raylib -# Options: -# raylib_USE_STATIC_LIBS - ON by default -# raylib_VERBOSE - OFF by default -# Once done, this defines a raylib target that can be passed to -# target_link_libraries as well as following variables: -# -# raylib_FOUND - System has raylib installed -# raylib_INCLUDE_DIRS - The include directories for the raylib header(s) -# raylib_LIBRARIES - The libraries needed to use raylib -# raylib_LDFLAGS - The linker flags needed with raylib -# raylib_DEFINITIONS - Compiler switches required for using raylib - -option(raylib_USE_STATIC_LIBS "Use static libs" ON) -option(raylib_VERBOSE "Show raylib verbose messages" OFF) - -if (NOT TARGET raylib) - set(XPREFIX PC_RAYLIB) - - find_package(PkgConfig QUIET) - pkg_check_modules(${XPREFIX} QUIET raylib) - - if (raylib_USE_STATIC_LIBS) - set(XPREFIX ${XPREFIX}_STATIC) - endif() - - set(raylib_DEFINITIONS ${${XPREFIX}_CFLAGS}) - - find_path(raylib_INCLUDE_DIR - NAMES raylib.h - HINTS ${${XPREFIX}_INCLUDE_DIRS} ${raylib_DIR}/../../../include/ - ) - - - if (raylib_USE_STATIC_LIBS) - set(RAYLIB_NAMES libraylib.a raylib.lib) - else () - set(RAYLIB_NAMES raylib) - endif () - - find_library(raylib_LIBRARY - NAMES ${RAYLIB_NAMES} - HINTS ${${XPREFIX}_LIBRARY_DIRS} ${raylib_DIR}/../../ - ) - - set(raylib_LIBRARIES ${raylib_LIBRARY}) - set(raylib_INCLUDE_DIRS ${raylib_INCLUDE_DIR}) - set(raylib_LDFLAGS ${${XPREFIX}_LDFLAGS}) - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(raylib DEFAULT_MSG - raylib_LIBRARY - raylib_INCLUDE_DIR - ) - - mark_as_advanced(raylib_LIBRARY raylib_INCLUDE_DIR) - - if (raylib_USE_STATIC_LIBS) - add_library(raylib STATIC IMPORTED GLOBAL) - else() - add_library(raylib SHARED IMPORTED GLOBAL) - endif() - string (REPLACE ";" " " raylib_LDFLAGS "${raylib_LDFLAGS}") - - set_target_properties(raylib - PROPERTIES - IMPORTED_LOCATION "${raylib_LIBRARIES}" - IMPORTED_IMPLIB "${raylib_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${raylib_INCLUDE_DIRS}" - INTERFACE_LINK_LIBRARIES "${raylib_LDFLAGS}" - INTERFACE_COMPILE_OPTIONS "${raylib_DEFINITIONS}" - ) - - if (raylib_VERBOSE) - message(STATUS "raylib_FOUND: ${raylib_FOUND}") - message(STATUS "raylib_INCLUDE_DIRS: ${raylib_INCLUDE_DIRS}") - message(STATUS "raylib_LIBRARIES: ${raylib_LIBRARIES}") - message(STATUS "raylib_LDFLAGS: ${raylib_LDFLAGS}") - message(STATUS "raylib_DEFINITIONS: ${raylib_DEFINITIONS}") - endif() -endif() +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4ce6cb81a..dc8ca3a9b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -91,7 +91,7 @@ if (BUILD_SHARED_LIBS) set_property(TARGET raylib PROPERTY C_VISIBILITY_PRESET hidden) endif () -target_link_libraries(raylib "${LIBS_PRIVATE}") +target_link_libraries(raylib PRIVATE $) # Sets some compile time definitions for the pre-processor # If CUSTOMIZE_BUILD option is on you will not use config.h by default From 71321d179b9742253169c7d17feaa69e37e64ee2 Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Fri, 12 Sep 2025 12:42:50 -0700 Subject: [PATCH 04/10] [build][cmake] Added emscripten build options (#5180) * [cmake] export automatically raylib definitions and compile/link options * [cmake] pass emscripten options to consumer project --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7597694c..ee095b844 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ include(CompilerFlags) # Registers build options that are exposed to cmake include(CMakeOptions.txt) -if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM") +if (UNIX AND NOT APPLE AND NOT "${PLATFORM}" MATCHES "DRM" AND NOT "${PLATFORM}" MATCHES "Web") if (NOT GLFW_BUILD_WAYLAND AND NOT GLFW_BUILD_X11) MESSAGE(FATAL_ERROR "Cannot disable both Wayland and X11") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc8ca3a9b..4b3f87016 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,7 +69,7 @@ else() endif() if (${PLATFORM} MATCHES "Web") - target_link_options(raylib PUBLIC "-sUSE_GLFW=3") + target_link_options(raylib PUBLIC "-sUSE_GLFW=3" -sEXPORTED_RUNTIME_METHODS=ccall -sASYNCIFY) if(${GRAPHICS} MATCHES "GRAPHICS_API_OPENGL_ES3") target_link_options(raylib PUBLIC "-sMIN_WEBGL_VERSION=2") target_link_options(raylib PUBLIC "-sMAX_WEBGL_VERSION=2") From 28ce99b5398326260c35f5af8b63002a2f0044b7 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 12 Sep 2025 21:44:56 +0200 Subject: [PATCH 05/10] Update core_3d_camera_fps.c --- examples/core/core_3d_camera_fps.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/core/core_3d_camera_fps.c b/examples/core/core_3d_camera_fps.c index 0b1a5bdc5..c3c779431 100644 --- a/examples/core/core_3d_camera_fps.c +++ b/examples/core/core_3d_camera_fps.c @@ -261,8 +261,7 @@ static void UpdateCameraFPS(Camera *camera) Vector3 right = Vector3Normalize(Vector3CrossProduct(yaw, up)); // Rotate view vector around right axis - float pitchAngle = -lookRotation.y - - lean.y; + float pitchAngle = -lookRotation.y - lean.y; pitchAngle = Clamp(pitchAngle, -PI/2 + 0.0001f, PI/2 - 0.0001f); // Clamp angle so it doesn't go past straight up or straight down Vector3 pitch = Vector3RotateByAxisAngle(yaw, right, pitchAngle); From 6cf38b62928830c4fd42422b41fdf855070eb21a Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Sat, 13 Sep 2025 01:17:17 -0700 Subject: [PATCH 06/10] fix SDL3 gamepad detection (#5176) --- src/platforms/rcore_desktop_sdl.c | 78 ++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index f07554762..a0ddac075 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -98,7 +98,7 @@ typedef struct { SDL_GLContext glContext; SDL_GameController *gamepad[MAX_GAMEPADS]; - SDL_JoystickID gamepadId[MAX_GAMEPADS]; // Joystick instance ids + SDL_JoystickID gamepadId[MAX_GAMEPADS]; // Joystick instance ids, they do not start from 0 SDL_Cursor *cursor; bool cursorRelative; } PlatformData; @@ -1706,19 +1706,34 @@ void PollInputEvents(void) { int jid = event.jdevice.which; // Joystick device index - if (CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS)) + // check if already added at InitPlatform + for (int i = 0; i < MAX_GAMEPADS; ++i) { - platform.gamepad[jid] = SDL_GameControllerOpen(jid); - platform.gamepadId[jid] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[jid])); - - if (platform.gamepad[jid]) + if (jid == platform.gamepadId[i]) { - CORE.Input.Gamepad.ready[jid] = true; - CORE.Input.Gamepad.axisCount[jid] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[jid])); - CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; - CORE.Input.Gamepad.axisState[jid][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; - memset(CORE.Input.Gamepad.name[jid], 0, MAX_GAMEPAD_NAME_LENGTH); - strncpy(CORE.Input.Gamepad.name[jid], SDL_GameControllerNameForIndex(jid), MAX_GAMEPAD_NAME_LENGTH - 1); + return; + } + } + + int nextAvailableSlot = 0; + while (nextAvailableSlot < MAX_GAMEPADS && CORE.Input.Gamepad.ready[nextAvailableSlot]) + { + ++nextAvailableSlot; + } + + if ((nextAvailableSlot < MAX_GAMEPADS) && !CORE.Input.Gamepad.ready[nextAvailableSlot]) + { + platform.gamepad[nextAvailableSlot] = SDL_GameControllerOpen(jid); + platform.gamepadId[nextAvailableSlot] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[nextAvailableSlot])); + + if (platform.gamepad[nextAvailableSlot]) + { + CORE.Input.Gamepad.ready[nextAvailableSlot] = true; + CORE.Input.Gamepad.axisCount[nextAvailableSlot] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[nextAvailableSlot])); + CORE.Input.Gamepad.axisState[nextAvailableSlot][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.axisState[nextAvailableSlot][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; + memset(CORE.Input.Gamepad.name[nextAvailableSlot], 0, MAX_GAMEPAD_NAME_LENGTH); + strncpy(CORE.Input.Gamepad.name[nextAvailableSlot], SDL_GameControllerNameForIndex(nextAvailableSlot), MAX_GAMEPAD_NAME_LENGTH - 1); } else { @@ -1746,7 +1761,7 @@ void PollInputEvents(void) { int button = -1; - switch (event.jbutton.button) + switch (event.gbutton.button) { case SDL_CONTROLLER_BUTTON_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break; case SDL_CONTROLLER_BUTTON_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break; @@ -1774,7 +1789,7 @@ void PollInputEvents(void) { for (int i = 0; i < MAX_GAMEPADS; i++) { - if (platform.gamepadId[i] == event.jbutton.which) + if (platform.gamepadId[i] == event.gbutton.which) { CORE.Input.Gamepad.currentButtonState[i][button] = 1; CORE.Input.Gamepad.lastButtonPressed = button; @@ -1787,7 +1802,7 @@ void PollInputEvents(void) { int button = -1; - switch (event.jbutton.button) + switch (event.gbutton.button) { case SDL_CONTROLLER_BUTTON_Y: button = GAMEPAD_BUTTON_RIGHT_FACE_UP; break; case SDL_CONTROLLER_BUTTON_B: button = GAMEPAD_BUTTON_RIGHT_FACE_RIGHT; break; @@ -1815,7 +1830,7 @@ void PollInputEvents(void) { for (int i = 0; i < MAX_GAMEPADS; i++) { - if (platform.gamepadId[i] == event.jbutton.which) + if (platform.gamepadId[i] == event.gbutton.which) { CORE.Input.Gamepad.currentButtonState[i][button] = 0; if (CORE.Input.Gamepad.lastButtonPressed == button) CORE.Input.Gamepad.lastButtonPressed = 0; @@ -2044,21 +2059,28 @@ int InitPlatform(void) platform.gamepadId[i] = -1; // Set all gamepad initial instance ids as invalid to not conflict with instance id zero } - for (int i = 0; (i < SDL_NumJoysticks()) && (i < MAX_GAMEPADS); i++) - { - platform.gamepad[i] = SDL_GameControllerOpen(i); - platform.gamepadId[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[i])); + int numJoysticks = 0; + SDL_JoystickID *joysticks = SDL_GetJoysticks(&numJoysticks); // array of joystick IDs, they do not start from 0 - if (platform.gamepad[i]) + if (joysticks) + { + for (int i = 0; (i < numJoysticks) && (i < MAX_GAMEPADS); i++) { - CORE.Input.Gamepad.ready[i] = true; - CORE.Input.Gamepad.axisCount[i] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[i])); - CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; - CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; - strncpy(CORE.Input.Gamepad.name[i], SDL_GameControllerNameForIndex(i), MAX_GAMEPAD_NAME_LENGTH - 1); - CORE.Input.Gamepad.name[i][MAX_GAMEPAD_NAME_LENGTH - 1] = '\0'; + platform.gamepad[i] = SDL_GameControllerOpen(joysticks[i]); + platform.gamepadId[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[i])); + + if (platform.gamepad[i]) + { + CORE.Input.Gamepad.ready[i] = true; + CORE.Input.Gamepad.axisCount[i] = SDL_JoystickNumAxes(SDL_GameControllerGetJoystick(platform.gamepad[i])); + CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_LEFT_TRIGGER] = -1.0f; + CORE.Input.Gamepad.axisState[i][GAMEPAD_AXIS_RIGHT_TRIGGER] = -1.0f; + strncpy(CORE.Input.Gamepad.name[i], SDL_GameControllerNameForIndex(i), MAX_GAMEPAD_NAME_LENGTH - 1); + CORE.Input.Gamepad.name[i][MAX_GAMEPAD_NAME_LENGTH - 1] = '\0'; + } + else TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError()); } - else TRACELOG(LOG_WARNING, "PLATFORM: Unable to open game controller [ERROR: %s]", SDL_GetError()); + SDL_free(joysticks); } // Disable mouse events being interpreted as touch events From bb0c78476c32bca08fd4db515bd33ea3b6dfc1f1 Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Sat, 13 Sep 2025 01:19:44 -0700 Subject: [PATCH 07/10] [build][cmake] Fix definition to use SDL3 (#5175) * fix definition to use SDL3 * [cmake] fix definition to use SDL3 * [build][cmake] prefer USING_VERSION_SDL3 over PLATFORM_DESKTOP_SDL3 * [build][cmake] when libs are added externally, consumer needs to import them too --- cmake/LibraryConfigurations.cmake | 8 ++++++-- cmake/raylib-config.cmake | 2 ++ src/CMakeLists.txt | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/LibraryConfigurations.cmake b/cmake/LibraryConfigurations.cmake index e4655500e..c0a7e3d4b 100644 --- a/cmake/LibraryConfigurations.cmake +++ b/cmake/LibraryConfigurations.cmake @@ -7,6 +7,8 @@ if(POLICY CMP0072) cmake_policy(SET CMP0072 NEW) endif() +set(RAYLIB_DEPENDENCIES "include(CMakeFindDependencyMacro)") + if (${PLATFORM} MATCHES "Desktop") set(PLATFORM_CPP "PLATFORM_DESKTOP") @@ -120,15 +122,17 @@ elseif ("${PLATFORM}" MATCHES "SDL") find_package(SDL3 QUIET) if(SDL3_FOUND) message(STATUS "Found SDL3 via find_package()") + set(LIBS_PUBLIC SDL3::SDL3) + set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)") set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL") - set(LIBS_PRIVATE SDL3::SDL3) add_compile_definitions(USING_SDL3_PACKAGE) else() # Fallback to SDL2 find_package(SDL2 REQUIRED) message(STATUS "Found SDL2 via find_package()") set(PLATFORM_CPP "PLATFORM_DESKTOP_SDL") - set(LIBS_PRIVATE SDL2::SDL2) + set(LIBS_PUBLIC SDL2::SDL2) + set(RAYLIB_DEPENDENCIES "${RAYLIB_DEPENDENCIES}\nfind_dependency(SDL3 REQUIRED)") add_compile_definitions(USING_SDL2_PACKAGE) endif() endif() diff --git a/cmake/raylib-config.cmake b/cmake/raylib-config.cmake index f34087ccd..16e677513 100644 --- a/cmake/raylib-config.cmake +++ b/cmake/raylib-config.cmake @@ -1,2 +1,4 @@ @PACKAGE_INIT@ +@RAYLIB_DEPENDENCIES@ + include("${CMAKE_CURRENT_LIST_DIR}/raylib-targets.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4b3f87016..eb37f1a8e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -92,6 +92,7 @@ if (BUILD_SHARED_LIBS) endif () target_link_libraries(raylib PRIVATE $) +target_link_libraries(raylib PUBLIC ${LIBS_PUBLIC}) # Sets some compile time definitions for the pre-processor # If CUSTOMIZE_BUILD option is on you will not use config.h by default From adac5f77707712410def0600f4c06426d2108839 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 13 Sep 2025 10:41:25 +0200 Subject: [PATCH 08/10] REXM: RENAME: example: `shaders_write_depth` --> `shaders_depth_writing` --- examples/Makefile | 2 +- examples/Makefile.Web | 4 +- examples/README.md | 2 +- examples/examples_list.txt | 2 +- examples/shaders/shaders_depth_rendering.c | 56 +- ..._write_depth.c => shaders_depth_writing.c} | 29 +- ...te_depth.png => shaders_depth_writing.png} | Bin ....vcxproj => shaders_depth_writing.vcxproj} | 1136 ++++++++--------- projects/VS2022/raylib.sln | 2 +- 9 files changed, 632 insertions(+), 601 deletions(-) rename examples/shaders/{shaders_write_depth.c => shaders_depth_writing.c} (92%) rename examples/shaders/{shaders_write_depth.png => shaders_depth_writing.png} (100%) rename projects/VS2022/examples/{shaders_write_depth.vcxproj => shaders_depth_writing.vcxproj} (97%) diff --git a/examples/Makefile b/examples/Makefile index 23c976681..68111fa41 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -656,7 +656,7 @@ SHADERS = \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ shaders/shaders_vertex_displacement \ - shaders/shaders_write_depth + shaders/shaders_depth_writing AUDIO = \ audio/audio_mixed_processor \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 0b2fdec0b..79fc04a78 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -656,7 +656,7 @@ SHADERS = \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ shaders/shaders_vertex_displacement \ - shaders/shaders_write_depth + shaders/shaders_depth_writing AUDIO = \ audio/audio_mixed_processor \ @@ -1298,7 +1298,7 @@ shaders/shaders_vertex_displacement: shaders/shaders_vertex_displacement.c --preload-file shaders/resources/shaders/glsl100/vertex_displacement.vs@resources/shaders/glsl100/vertex_displacement.vs \ --preload-file shaders/resources/shaders/glsl100/vertex_displacement.fs@resources/shaders/glsl100/vertex_displacement.fs -shaders/shaders_write_depth: shaders/shaders_write_depth.c +shaders/shaders_depth_writing: shaders/shaders_depth_writing.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ --preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs diff --git a/examples/README.md b/examples/README.md index bc50cfc1d..fd6c9fcf3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -203,7 +203,7 @@ Examples using raylib shaders functionality, including shaders loading, paramete | [shaders_texture_tiling](shaders/shaders_texture_tiling.c) | shaders_texture_tiling | ⭐⭐☆☆ | 4.5 | 4.5 | [Luis Almeida](https://github.com/luis605) | | [shaders_shadowmap_rendering](shaders/shaders_shadowmap_rendering.c) | shaders_shadowmap_rendering | ⭐⭐⭐⭐️ | 5.0 | 5.0 | [TheManTheMythTheGameDev](https://github.com/TheManTheMythTheGameDev) | | [shaders_vertex_displacement](shaders/shaders_vertex_displacement.c) | shaders_vertex_displacement | ⭐⭐⭐☆ | 5.0 | 4.5 | [Alex ZH](https://github.com/ZzzhHe) | -| [shaders_write_depth](shaders/shaders_write_depth.c) | shaders_write_depth | ⭐⭐☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | +| [shaders_depth_writing](shaders/shaders_depth_writing.c) | shaders_depth_writing | ⭐⭐☆☆ | 4.2 | 4.2 | [Buğra Alptekin Sarı](https://github.com/BugraAlptekinSari) | | [shaders_basic_pbr](shaders/shaders_basic_pbr.c) | shaders_basic_pbr | ⭐⭐⭐⭐️ | 5.0 | 5.5 | [Afan OLOVCIC](https://github.com/_DevDad) | | [shaders_lightmap_rendering](shaders/shaders_lightmap_rendering.c) | shaders_lightmap_rendering | ⭐⭐⭐☆ | 4.5 | 4.5 | [Jussi Viitala](https://github.com/nullstare) | | [shaders_rounded_rectangle](shaders/shaders_rounded_rectangle.c) | shaders_rounded_rectangle | ⭐⭐⭐☆ | 5.5 | 5.5 | [Anstro Pleuton](https://github.com/anstropleuton) | diff --git a/examples/examples_list.txt b/examples/examples_list.txt index c76176c86..ecbc3e2cc 100644 --- a/examples/examples_list.txt +++ b/examples/examples_list.txt @@ -150,7 +150,7 @@ shaders;shaders_hybrid_rendering;★★★★;4.2;4.2;2022;2025;"Buğra Alptekin shaders;shaders_texture_tiling;★★☆☆;4.5;4.5;2023;2025;"Luis Almeida";@luis605 shaders;shaders_shadowmap_rendering;★★★★;5.0;5.0;2023;2025;"TheManTheMythTheGameDev";@TheManTheMythTheGameDev shaders;shaders_vertex_displacement;★★★☆;5.0;4.5;2023;2025;"Alex ZH";@ZzzhHe -shaders;shaders_write_depth;★★☆☆;4.2;4.2;2022;2025;"Buğra Alptekin Sarı";@BugraAlptekinSari +shaders;shaders_depth_writing;★★☆☆;4.2;4.2;2022;2025;"Buğra Alptekin Sarı";@BugraAlptekinSari shaders;shaders_basic_pbr;★★★★;5.0;5.5;2023;2025;"Afan OLOVCIC";@_DevDad shaders;shaders_lightmap_rendering;★★★☆;4.5;4.5;2019;2025;"Jussi Viitala";@nullstare shaders;shaders_rounded_rectangle;★★★☆;5.5;5.5;2025;2025;"Anstro Pleuton";@anstropleuton diff --git a/examples/shaders/shaders_depth_rendering.c b/examples/shaders/shaders_depth_rendering.c index 849aaed8b..0e69dba88 100644 --- a/examples/shaders/shaders_depth_rendering.c +++ b/examples/shaders/shaders_depth_rendering.c @@ -6,7 +6,7 @@ * * Example originally created with raylib 5.6-dev, last time updated with raylib 5.6-dev * -* Example contributed by Luís Almeida (@luis605) +* Example contributed by Luís Almeida (@luis605) and reviewed by Ramon Santamaria (@raysan5) * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software @@ -16,6 +16,7 @@ ********************************************************************************************/ #include "raylib.h" + #include "rlgl.h" #if defined(PLATFORM_DESKTOP) @@ -24,7 +25,14 @@ #define GLSL_VERSION 100 #endif -RenderTexture2D LoadRenderTextureWithDepth(int width, int height); +//-------------------------------------------------------------------------------------- +// Module Functions Declaration +//-------------------------------------------------------------------------------------- +// Load custom render texture with depth texture attached +static RenderTexture2D LoadRenderTextureDepthTex(int width, int height); + +// Unload render texture from GPU memory (VRAM) +static void UnloadRenderTextureDepthTex(RenderTexture2D target); //------------------------------------------------------------------------------------ // Program main entry point @@ -38,7 +46,7 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [shaders] example - depth rendering"); - // Init camera + // Define the camera to look into our 3d world Camera camera = { 0 }; camera.position = (Vector3){ 4.0f, 1.0f, 5.0f }; camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; @@ -46,8 +54,8 @@ int main(void) camera.fovy = 45.0f; camera.projection = CAMERA_PERSPECTIVE; - // Load an empty render texture with a depth texture - RenderTexture2D target = LoadRenderTextureWithDepth(screenWidth, screenHeight); + // Load render texture with a depth texture attached + RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight); // Load depth shader and get depth texture shader location Shader depthShader = LoadShader(0, TextFormat("resources/shaders/glsl%i/depth.fs", GLSL_VERSION)); @@ -55,7 +63,7 @@ int main(void) int flipTextureLoc = GetShaderLocation(depthShader, "flipY"); SetShaderValue(depthShader, flipTextureLoc, (int[]){ 1 }, SHADER_UNIFORM_INT); // Flip Y texture - // Load models + // Load scene models Model cube = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f)); Model floor = LoadModelFromMesh(GenMeshPlane(20.0f, 20.0f, 1, 1)); @@ -78,12 +86,14 @@ int main(void) ClearBackground(WHITE); BeginMode3D(camera); - DrawModel(cube, (Vector3){ 0.0f, 0.0f, 0.0f }, 3.0f, YELLOW); + DrawModel(cube, (Vector3){ 0.0f, 0.0f, 0.0f }, 3.0f, YELLOW); DrawModel(floor, (Vector3){ 10.0f, 0.0f, 2.0f }, 2.0f, RED); EndMode3D(); EndTextureMode(); + // Draw into screen (main framebuffer) BeginDrawing(); + ClearBackground(RAYWHITE); BeginShaderMode(depthShader); SetShaderValueTexture(depthShader, depthLoc, target.depth); @@ -106,19 +116,24 @@ int main(void) //-------------------------------------------------------------------------------------- UnloadModel(cube); // Unload model UnloadModel(floor); // Unload model - UnloadRenderTexture(target); // Unload render texture + UnloadRenderTextureDepthTex(target); UnloadShader(depthShader); // Unload shader CloseWindow(); // Close window and OpenGL context //-------------------------------------------------------------------------------------- + return 0; } -RenderTexture2D LoadRenderTextureWithDepth(int width, int height) +//-------------------------------------------------------------------------------------- +// Module Functions Definition +//-------------------------------------------------------------------------------------- +// Load custom render texture, create a writable depth texture buffer +static RenderTexture2D LoadRenderTextureDepthTex(int width, int height) { - RenderTexture2D target = {0}; + RenderTexture2D target = { 0 }; - target.id = rlLoadFramebuffer(); // Load an empty framebuffer + target.id = rlLoadFramebuffer(); // Load an empty framebuffer if (target.id > 0) { @@ -131,11 +146,11 @@ RenderTexture2D LoadRenderTextureWithDepth(int width, int height) target.texture.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8; target.texture.mipmaps = 1; - // Create depth texture + // Create depth texture buffer (instead of raylib default renderbuffer) target.depth.id = rlLoadTextureDepth(width, height, false); target.depth.width = width; target.depth.height = height; - target.depth.format = 19; //DEPTH_COMPONENT_24BIT? THIS DOESN'T EXIST IN RAYLIB + target.depth.format = 19; // DEPTH_COMPONENT_24BIT: Not defined in raylib target.depth.mipmaps = 1; // Attach color texture and depth texture to FBO @@ -150,4 +165,19 @@ RenderTexture2D LoadRenderTextureWithDepth(int width, int height) else TRACELOG(LOG_WARNING, "FBO: Framebuffer object can not be created"); return target; +} + +// Unload render texture from GPU memory (VRAM) +void UnloadRenderTextureDepthTex(RenderTexture2D target) +{ + if (target.id > 0) + { + // Color texture attached to FBO is deleted + rlUnloadTexture(target.texture.id); + rlUnloadTexture(target.depth.id); + + // NOTE: Depth texture is automatically + // queried and deleted before deleting framebuffer + rlUnloadFramebuffer(target.id); + } } \ No newline at end of file diff --git a/examples/shaders/shaders_write_depth.c b/examples/shaders/shaders_depth_writing.c similarity index 92% rename from examples/shaders/shaders_write_depth.c rename to examples/shaders/shaders_depth_writing.c index 677d0fb03..6934dc2c0 100644 --- a/examples/shaders/shaders_write_depth.c +++ b/examples/shaders/shaders_depth_writing.c @@ -1,6 +1,6 @@ /******************************************************************************************* * -* raylib [shaders] example - write depth +* raylib [shaders] example - depth writing * * Example complexity rating: [★★☆☆] 2/4 * @@ -20,9 +20,9 @@ #include "rlgl.h" #if defined(PLATFORM_DESKTOP) -#define GLSL_VERSION 330 + #define GLSL_VERSION 330 #else // PLATFORM_ANDROID, PLATFORM_WEB -#define GLSL_VERSION 100 + #define GLSL_VERSION 100 #endif //-------------------------------------------------------------------------------------- @@ -44,13 +44,7 @@ int main(void) const int screenWidth = 800; const int screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib [shaders] example - write depth"); - - // The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z;` - Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/write_depth.fs", GLSL_VERSION)); - - // Use Customized function to create writable depth texture buffer - RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight); + InitWindow(screenWidth, screenHeight, "raylib [shaders] example - depth writing"); // Define the camera to look into our 3d world Camera camera = { @@ -61,6 +55,12 @@ int main(void) .projection = CAMERA_PERSPECTIVE // Camera projection type }; + // Load custom render texture with writable depth texture buffer + RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight); + + // Load depth writting shader + // NOTE: The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z;` + Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/write_depth.fs", GLSL_VERSION)); SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- @@ -74,7 +74,7 @@ int main(void) // Draw //---------------------------------------------------------------------------------- - // Draw into our custom render texture (framebuffer) + // Draw into our custom render texture BeginTextureMode(target); ClearBackground(WHITE); @@ -92,7 +92,9 @@ int main(void) // Draw into screen our custom render texture BeginDrawing(); ClearBackground(RAYWHITE); + DrawTextureRec(target.texture, (Rectangle) { 0, 0, (float)screenWidth, (float)-screenHeight }, (Vector2) { 0, 0 }, WHITE); + DrawFPS(10, 10); EndDrawing(); //---------------------------------------------------------------------------------- @@ -112,9 +114,8 @@ int main(void) //-------------------------------------------------------------------------------------- // Module Functions Definition //-------------------------------------------------------------------------------------- - // Load custom render texture, create a writable depth texture buffer -RenderTexture2D LoadRenderTextureDepthTex(int width, int height) +static RenderTexture2D LoadRenderTextureDepthTex(int width, int height) { RenderTexture2D target = { 0 }; @@ -135,7 +136,7 @@ RenderTexture2D LoadRenderTextureDepthTex(int width, int height) target.depth.id = rlLoadTextureDepth(width, height, false); target.depth.width = width; target.depth.height = height; - target.depth.format = 19; //DEPTH_COMPONENT_24BIT? + target.depth.format = 19; // DEPTH_COMPONENT_24BIT: Not defined in raylib target.depth.mipmaps = 1; // Attach color texture and depth texture to FBO diff --git a/examples/shaders/shaders_write_depth.png b/examples/shaders/shaders_depth_writing.png similarity index 100% rename from examples/shaders/shaders_write_depth.png rename to examples/shaders/shaders_depth_writing.png diff --git a/projects/VS2022/examples/shaders_write_depth.vcxproj b/projects/VS2022/examples/shaders_depth_writing.vcxproj similarity index 97% rename from projects/VS2022/examples/shaders_write_depth.vcxproj rename to projects/VS2022/examples/shaders_depth_writing.vcxproj index 4c19cd4b2..a411b2c52 100644 --- a/projects/VS2022/examples/shaders_write_depth.vcxproj +++ b/projects/VS2022/examples/shaders_depth_writing.vcxproj @@ -1,569 +1,569 @@ - - - - - Debug.DLL - ARM64 - - - Debug.DLL - Win32 - - - Debug.DLL - x64 - - - Debug - ARM64 - - - Debug - Win32 - - - Debug - x64 - - - Release.DLL - ARM64 - - - Release.DLL - Win32 - - - Release.DLL - x64 - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - {70B35F59-AFC2-4D8F-8833-5314D2047A81} - Win32Proj - shaders_write_depth - 10.0 - shaders_write_depth - - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - true - $(DefaultPlatformToolset) - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - Application - false - $(DefaultPlatformToolset) - true - Unicode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - true - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - false - $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ - $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - $(SolutionDir)..\..\examples\shaders - WindowsLocalDebugger - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) - CompileAsC - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - - - Console - true - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - Copy Debug DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP - $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) - CompileAsC - true - - - Console - true - true - true - raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ - - - xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" - - - Copy Release DLL to output directory - - - - - - - - - - - {e89d61ac-55de-4482-afd4-df7242ebc859} - - - - - + + + + + Debug.DLL + ARM64 + + + Debug.DLL + Win32 + + + Debug.DLL + x64 + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release.DLL + ARM64 + + + Release.DLL + Win32 + + + Release.DLL + x64 + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {70B35F59-AFC2-4D8F-8833-5314D2047A81} + Win32Proj + shaders_depth_writing + 10.0 + shaders_depth_writing + + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + true + $(DefaultPlatformToolset) + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + Application + false + $(DefaultPlatformToolset) + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + true + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + false + $(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)\ + $(SolutionDir)\build\$(ProjectName)\obj\$(Platform)\$(Configuration)\ + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\shaders + WindowsLocalDebugger + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + /FS %(AdditionalOptions) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions) + CompileAsC + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + + + Console + true + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + Copy Debug DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP + $(SolutionDir)..\..\src;%(AdditionalIncludeDirectories) + CompileAsC + true + + + Console + true + true + true + raylib.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\ + + + xcopy /y /d "$(SolutionDir)\build\raylib\bin\$(Platform)\$(Configuration)\raylib.dll" "$(SolutionDir)\build\$(ProjectName)\bin\$(Platform)\$(Configuration)" + + + Copy Release DLL to output directory + + + + + + + + + + + {e89d61ac-55de-4482-afd4-df7242ebc859} + + + + + \ No newline at end of file diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 7ccb1b704..3eacc34ec 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -267,7 +267,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "textures_textured_curve", " EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "models_loading_m3d", "examples\models_loading_m3d.vcxproj", "{6D9E00D8-2893-45E4-9363-3F7F61D416BD}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_write_depth", "examples\shaders_write_depth.vcxproj", "{70B35F59-AFC2-4D8F-8833-5314D2047A81}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_depth_writing", "examples\shaders_depth_writing.vcxproj", "{70B35F59-AFC2-4D8F-8833-5314D2047A81}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shaders_depth_rendering", "examples\shaders_depth_rendering.vcxproj", "{DFDE29A7-4F54-455D-B20B-D2BF79D3B3F7}" EndProject From 314820675843f52ead4292d25e86896eb4ebb3bf Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 13 Sep 2025 10:44:12 +0200 Subject: [PATCH 09/10] Renamed shaders for consistency --- .../resources/shaders/glsl100/{depth.fs => depth_render.fs} | 0 .../shaders/glsl100/{write_depth.fs => depth_write.fs} | 0 .../resources/shaders/glsl120/{depth.fs => depth_render.fs} | 0 .../shaders/glsl120/{write_depth.fs => depth_write.fs} | 0 .../resources/shaders/glsl330/{depth.fs => depth_render.fs} | 0 .../shaders/glsl330/{write_depth.fs => depth_write.fs} | 0 examples/shaders/shaders_depth_rendering.c | 2 +- examples/shaders/shaders_depth_writing.c | 2 +- 8 files changed, 2 insertions(+), 2 deletions(-) rename examples/shaders/resources/shaders/glsl100/{depth.fs => depth_render.fs} (100%) rename examples/shaders/resources/shaders/glsl100/{write_depth.fs => depth_write.fs} (100%) rename examples/shaders/resources/shaders/glsl120/{depth.fs => depth_render.fs} (100%) rename examples/shaders/resources/shaders/glsl120/{write_depth.fs => depth_write.fs} (100%) rename examples/shaders/resources/shaders/glsl330/{depth.fs => depth_render.fs} (100%) rename examples/shaders/resources/shaders/glsl330/{write_depth.fs => depth_write.fs} (100%) diff --git a/examples/shaders/resources/shaders/glsl100/depth.fs b/examples/shaders/resources/shaders/glsl100/depth_render.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl100/depth.fs rename to examples/shaders/resources/shaders/glsl100/depth_render.fs diff --git a/examples/shaders/resources/shaders/glsl100/write_depth.fs b/examples/shaders/resources/shaders/glsl100/depth_write.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl100/write_depth.fs rename to examples/shaders/resources/shaders/glsl100/depth_write.fs diff --git a/examples/shaders/resources/shaders/glsl120/depth.fs b/examples/shaders/resources/shaders/glsl120/depth_render.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl120/depth.fs rename to examples/shaders/resources/shaders/glsl120/depth_render.fs diff --git a/examples/shaders/resources/shaders/glsl120/write_depth.fs b/examples/shaders/resources/shaders/glsl120/depth_write.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl120/write_depth.fs rename to examples/shaders/resources/shaders/glsl120/depth_write.fs diff --git a/examples/shaders/resources/shaders/glsl330/depth.fs b/examples/shaders/resources/shaders/glsl330/depth_render.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl330/depth.fs rename to examples/shaders/resources/shaders/glsl330/depth_render.fs diff --git a/examples/shaders/resources/shaders/glsl330/write_depth.fs b/examples/shaders/resources/shaders/glsl330/depth_write.fs similarity index 100% rename from examples/shaders/resources/shaders/glsl330/write_depth.fs rename to examples/shaders/resources/shaders/glsl330/depth_write.fs diff --git a/examples/shaders/shaders_depth_rendering.c b/examples/shaders/shaders_depth_rendering.c index 0e69dba88..866135020 100644 --- a/examples/shaders/shaders_depth_rendering.c +++ b/examples/shaders/shaders_depth_rendering.c @@ -58,7 +58,7 @@ int main(void) RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight); // Load depth shader and get depth texture shader location - Shader depthShader = LoadShader(0, TextFormat("resources/shaders/glsl%i/depth.fs", GLSL_VERSION)); + Shader depthShader = LoadShader(0, TextFormat("resources/shaders/glsl%i/depth_render.fs", GLSL_VERSION)); int depthLoc = GetShaderLocation(depthShader, "depthTexture"); int flipTextureLoc = GetShaderLocation(depthShader, "flipY"); SetShaderValue(depthShader, flipTextureLoc, (int[]){ 1 }, SHADER_UNIFORM_INT); // Flip Y texture diff --git a/examples/shaders/shaders_depth_writing.c b/examples/shaders/shaders_depth_writing.c index 6934dc2c0..e1112e9c2 100644 --- a/examples/shaders/shaders_depth_writing.c +++ b/examples/shaders/shaders_depth_writing.c @@ -60,7 +60,7 @@ int main(void) // Load depth writting shader // NOTE: The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z;` - Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/write_depth.fs", GLSL_VERSION)); + Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/depth_write.fs", GLSL_VERSION)); SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- From b8420d48219ada274fdde5ac07cd406edc3ca878 Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 13 Sep 2025 10:46:14 +0200 Subject: [PATCH 10/10] REXM: Update examples --- examples/Makefile | 4 ++-- examples/Makefile.Web | 14 +++++++------- examples/shaders/shaders_depth_writing.c | 2 +- src/platforms/rcore_desktop_glfw.c | 2 +- tools/rexm/examples_report.md | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 68111fa41..c15a70c5b 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -633,6 +633,7 @@ SHADERS = \ shaders/shaders_custom_uniform \ shaders/shaders_deferred_rendering \ shaders/shaders_depth_rendering \ + shaders/shaders_depth_writing \ shaders/shaders_eratosthenes_sieve \ shaders/shaders_fog_rendering \ shaders/shaders_hot_reloading \ @@ -655,8 +656,7 @@ SHADERS = \ shaders/shaders_texture_rendering \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ - shaders/shaders_vertex_displacement \ - shaders/shaders_depth_writing + shaders/shaders_vertex_displacement AUDIO = \ audio/audio_mixed_processor \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 79fc04a78..9c5863471 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -633,6 +633,7 @@ SHADERS = \ shaders/shaders_custom_uniform \ shaders/shaders_deferred_rendering \ shaders/shaders_depth_rendering \ + shaders/shaders_depth_writing \ shaders/shaders_eratosthenes_sieve \ shaders/shaders_fog_rendering \ shaders/shaders_hot_reloading \ @@ -655,8 +656,7 @@ SHADERS = \ shaders/shaders_texture_rendering \ shaders/shaders_texture_tiling \ shaders/shaders_texture_waves \ - shaders/shaders_vertex_displacement \ - shaders/shaders_depth_writing + shaders/shaders_vertex_displacement AUDIO = \ audio/audio_mixed_processor \ @@ -1167,7 +1167,11 @@ shaders/shaders_deferred_rendering: shaders/shaders_deferred_rendering.c shaders/shaders_depth_rendering: shaders/shaders_depth_rendering.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ - --preload-file shaders/resources/shaders/glsl100/depth.fs@resources/shaders/glsl100/depth.fs + --preload-file shaders/resources/shaders/glsl100/depth_render.fs@resources/shaders/glsl100/depth_render.fs + +shaders/shaders_depth_writing: shaders/shaders_depth_writing.c + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ + --preload-file shaders/resources/shaders/glsl100/depth_write.fs@resources/shaders/glsl100/depth_write.fs shaders/shaders_eratosthenes_sieve: shaders/shaders_eratosthenes_sieve.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ @@ -1298,10 +1302,6 @@ shaders/shaders_vertex_displacement: shaders/shaders_vertex_displacement.c --preload-file shaders/resources/shaders/glsl100/vertex_displacement.vs@resources/shaders/glsl100/vertex_displacement.vs \ --preload-file shaders/resources/shaders/glsl100/vertex_displacement.fs@resources/shaders/glsl100/vertex_displacement.fs -shaders/shaders_depth_writing: shaders/shaders_depth_writing.c - $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ - --preload-file shaders/resources/shaders/glsl100/write_depth.fs@resources/shaders/glsl100/write_depth.fs - # Compile AUDIO examples audio/audio_mixed_processor: audio/audio_mixed_processor.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ diff --git a/examples/shaders/shaders_depth_writing.c b/examples/shaders/shaders_depth_writing.c index e1112e9c2..ec887ae09 100644 --- a/examples/shaders/shaders_depth_writing.c +++ b/examples/shaders/shaders_depth_writing.c @@ -58,7 +58,7 @@ int main(void) // Load custom render texture with writable depth texture buffer RenderTexture2D target = LoadRenderTextureDepthTex(screenWidth, screenHeight); - // Load depth writting shader + // Load depth writing shader // NOTE: The shader inverts the depth buffer by writing into it by `gl_FragDepth = 1 - gl_FragCoord.z;` Shader shader = LoadShader(0, TextFormat("resources/shaders/glsl%i/depth_write.fs", GLSL_VERSION)); SetTargetFPS(60); // Set our game to run at 60 frames-per-second diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 6cf5ffb84..cfddf75b7 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -81,7 +81,7 @@ #define Font X11Font // Hack to fix 'Font' name collision // The definition and references to the X11 Font type will be replaced by 'X11Font' // Works as long as the current file consistently references any X11 Font as X11Font - // Since it is never referenced (as of writting), this does not pose an issue + // Since it is never referenced (as of writing), this does not pose an issue #endif #if defined(_GLFW_WAYLAND) diff --git a/tools/rexm/examples_report.md b/tools/rexm/examples_report.md index 2c1555049..df515917a 100644 --- a/tools/rexm/examples_report.md +++ b/tools/rexm/examples_report.md @@ -163,7 +163,7 @@ Example elements validated: | shaders_texture_tiling | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | shaders_shadowmap_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | shaders_vertex_displacement | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | -| shaders_write_depth | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | +| shaders_depth_writing | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | shaders_basic_pbr | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | shaders_lightmap_rendering | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | shaders_rounded_rectangle | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |