From 55c6864092979687ed30320a8ebb8ba608d9a138 Mon Sep 17 00:00:00 2001 From: MikiZX1 <161243635+MikiZX1@users.noreply.github.com> Date: Wed, 26 Mar 2025 14:06:58 +0100 Subject: [PATCH 01/11] Update rcore_desktop_sdl.c raylib app crashing when started and a gamepad is already connected to the PC (even if the gamepad is not used in the app). I only tested this with a gamepad that has a layout which is not recognized. Using SDL3 as backend. --- src/platforms/rcore_desktop_sdl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 97145b9dd..8979cc9e7 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1670,7 +1670,7 @@ void PollInputEvents(void) { int jid = event.jdevice.which; // Joystick device index - if (!CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS)) + if (CORE.Input.Gamepad.ready[jid] && (jid < MAX_GAMEPADS)) { platform.gamepad[jid] = SDL_GameControllerOpen(jid); platform.gamepadId[jid] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(platform.gamepad[jid])); From 8749ba9ebf7e918d3fbc4ef8ed0807e89e6521e2 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Wed, 26 Mar 2025 16:35:31 -0600 Subject: [PATCH 02/11] Uncomment SetTargetFPS in core_window_flags I think this line was accidently commented out in this commit: 3d1ae3500c731aa37d8f887cd165db480c4890eb The FPS limit is needed to get the desired wait time for the "hide window" test, which uses the frame counter to hide the window for 3 seconds. On my machine without this limit it runs at over 1000 FPS and it appears like the hide window state is broken. I also added some text that tells the user that it only hides the window for 3 seconds so they're not surprised when the window automatically reappears. --- examples/core/core_window_flags.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c index ec4f6aac6..571b43c48 100644 --- a/examples/core/core_window_flags.c +++ b/examples/core/core_window_flags.c @@ -52,7 +52,7 @@ int main(void) int framesCounter = 0; - //SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //---------------------------------------------------------- // Main game loop @@ -163,7 +163,7 @@ int main(void) if (IsWindowState(FLAG_WINDOW_UNDECORATED)) DrawText("[D] FLAG_WINDOW_UNDECORATED: on", 10, 120, 10, LIME); else DrawText("[D] FLAG_WINDOW_UNDECORATED: off", 10, 120, 10, MAROON); if (IsWindowState(FLAG_WINDOW_HIDDEN)) DrawText("[H] FLAG_WINDOW_HIDDEN: on", 10, 140, 10, LIME); - else DrawText("[H] FLAG_WINDOW_HIDDEN: off", 10, 140, 10, MAROON); + else DrawText("[H] FLAG_WINDOW_HIDDEN: off (hides for 3 seconds)", 10, 140, 10, MAROON); if (IsWindowState(FLAG_WINDOW_MINIMIZED)) DrawText("[N] FLAG_WINDOW_MINIMIZED: on", 10, 160, 10, LIME); else DrawText("[N] FLAG_WINDOW_MINIMIZED: off", 10, 160, 10, MAROON); if (IsWindowState(FLAG_WINDOW_MAXIMIZED)) DrawText("[M] FLAG_WINDOW_MAXIMIZED: on", 10, 180, 10, LIME); From 00fb09cebf9f870ea5fa3a017773985a2fd3dad1 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Wed, 26 Mar 2025 20:02:03 -0600 Subject: [PATCH 03/11] Prevent immediate window restore from minimize in core_window_flags The core_window_flags example automatically restores the window from being minimized after 3 seconds. However, it only resets the frameCounter if the window is minimized through the app from inputting KEY_N. This means if you miminize the window by other means (like pressing the minimize button) then the example will immediately restore the window because the frame counter wasn't reset. I've fixed this by setting the frameCounter back to 0 once it's expired. I also added a note in the UI that the example automatically restores the window so it's not a surprise. --- examples/core/core_window_flags.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c index ec4f6aac6..a3c986ed4 100644 --- a/examples/core/core_window_flags.c +++ b/examples/core/core_window_flags.c @@ -97,7 +97,10 @@ int main(void) if (IsWindowState(FLAG_WINDOW_MINIMIZED)) { framesCounter++; - if (framesCounter >= 240) RestoreWindow(); // Restore window after 3 seconds + if (framesCounter >= 240) { + RestoreWindow(); // Restore window after 3 seconds + framesCounter = 0; + } } if (IsKeyPressed(KEY_M)) @@ -165,7 +168,7 @@ int main(void) if (IsWindowState(FLAG_WINDOW_HIDDEN)) DrawText("[H] FLAG_WINDOW_HIDDEN: on", 10, 140, 10, LIME); else DrawText("[H] FLAG_WINDOW_HIDDEN: off", 10, 140, 10, MAROON); if (IsWindowState(FLAG_WINDOW_MINIMIZED)) DrawText("[N] FLAG_WINDOW_MINIMIZED: on", 10, 160, 10, LIME); - else DrawText("[N] FLAG_WINDOW_MINIMIZED: off", 10, 160, 10, MAROON); + else DrawText("[N] FLAG_WINDOW_MINIMIZED: off (restores after 3 seconds)", 10, 160, 10, MAROON); if (IsWindowState(FLAG_WINDOW_MAXIMIZED)) DrawText("[M] FLAG_WINDOW_MAXIMIZED: on", 10, 180, 10, LIME); else DrawText("[M] FLAG_WINDOW_MAXIMIZED: off", 10, 180, 10, MAROON); if (IsWindowState(FLAG_WINDOW_UNFOCUSED)) DrawText("[G] FLAG_WINDOW_UNFOCUSED: on", 10, 200, 10, LIME); From af16f7823a81708ea53b482762a58f9ae3308bc5 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Fri, 28 Mar 2025 10:37:32 -0600 Subject: [PATCH 04/11] Improve description of RestoreWindow Restore window currently says it sets the window state to: "not minimized/maximized" However, if a window is maximized and then minimized, it's typical that it would restore back to being maximized, which is what seems to happen from my testing. I've reworded the description to better reflect this behavior. --- parser/output/raylib_api.json | 2 +- parser/output/raylib_api.lua | 2 +- parser/output/raylib_api.txt | 2 +- parser/output/raylib_api.xml | 2 +- projects/Notepad++/raylib_npp_parser/raylib_npp.xml | 2 +- projects/Notepad++/raylib_npp_parser/raylib_to_parse.h | 2 +- src/platforms/rcore_android.c | 2 +- src/platforms/rcore_desktop_glfw.c | 2 +- src/platforms/rcore_desktop_rgfw.c | 2 +- src/platforms/rcore_desktop_sdl.c | 2 +- src/platforms/rcore_drm.c | 2 +- src/platforms/rcore_template.c | 2 +- src/platforms/rcore_web.c | 2 +- src/raylib.h | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/parser/output/raylib_api.json b/parser/output/raylib_api.json index f5872ec8a..567f9d980 100644 --- a/parser/output/raylib_api.json +++ b/parser/output/raylib_api.json @@ -3280,7 +3280,7 @@ }, { "name": "RestoreWindow", - "description": "Set window state: not minimized/maximized", + "description": "Restore window from being minimized/maximized", "returnType": "void" }, { diff --git a/parser/output/raylib_api.lua b/parser/output/raylib_api.lua index 81dd7f932..75c328da6 100644 --- a/parser/output/raylib_api.lua +++ b/parser/output/raylib_api.lua @@ -3223,7 +3223,7 @@ return { }, { name = "RestoreWindow", - description = "Set window state: not minimized/maximized", + description = "Restore window from being minimized/maximized", returnType = "void" }, { diff --git a/parser/output/raylib_api.txt b/parser/output/raylib_api.txt index c74a79a5f..0b0bf86c1 100644 --- a/parser/output/raylib_api.txt +++ b/parser/output/raylib_api.txt @@ -1085,7 +1085,7 @@ Function 017: MinimizeWindow() (0 input parameters) Function 018: RestoreWindow() (0 input parameters) Name: RestoreWindow Return type: void - Description: Set window state: not minimized/maximized + Description: Restore window from being minimized/maximized No input parameters Function 019: SetWindowIcon() (1 input parameters) Name: SetWindowIcon diff --git a/parser/output/raylib_api.xml b/parser/output/raylib_api.xml index b7af0c41a..ed6880dec 100644 --- a/parser/output/raylib_api.xml +++ b/parser/output/raylib_api.xml @@ -720,7 +720,7 @@ - + diff --git a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml index 0fada9c4f..4c6362162 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_npp.xml +++ b/projects/Notepad++/raylib_npp_parser/raylib_npp.xml @@ -65,7 +65,7 @@ - + diff --git a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h index c6b34b777..89cce66f9 100644 --- a/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h +++ b/projects/Notepad++/raylib_npp_parser/raylib_to_parse.h @@ -20,7 +20,7 @@ RLAPI void ToggleFullscreen(void); // Toggle wind RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed, resizes window to match monitor resolution RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable -RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized +RLAPI void RestoreWindow(void); // Restore window from being minimized/maximized RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit) RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit) RLAPI void SetWindowTitle(const char *title); // Set title for window diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index eac7f3256..ddf7802ba 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -337,7 +337,7 @@ void MinimizeWindow(void) TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform"); diff --git a/src/platforms/rcore_desktop_glfw.c b/src/platforms/rcore_desktop_glfw.c index 19ee78bf4..a08033a93 100644 --- a/src/platforms/rcore_desktop_glfw.c +++ b/src/platforms/rcore_desktop_glfw.c @@ -292,7 +292,7 @@ void MinimizeWindow(void) glfwIconifyWindow(platform.handle); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { if (glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) diff --git a/src/platforms/rcore_desktop_rgfw.c b/src/platforms/rcore_desktop_rgfw.c index aafe28a66..9a5841c83 100644 --- a/src/platforms/rcore_desktop_rgfw.c +++ b/src/platforms/rcore_desktop_rgfw.c @@ -339,7 +339,7 @@ void MinimizeWindow(void) RGFW_window_minimize(platform.window); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { if (!(CORE.Window.flags & FLAG_WINDOW_UNFOCUSED)) RGFW_window_focus(platform.window); diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 97145b9dd..21160b19e 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -508,7 +508,7 @@ void MinimizeWindow(void) if ((CORE.Window.flags & FLAG_WINDOW_MINIMIZED) == 0) CORE.Window.flags |= FLAG_WINDOW_MINIMIZED; } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { SDL_RestoreWindow(platform.window); diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c index baa51a8d8..74af3d453 100644 --- a/src/platforms/rcore_drm.c +++ b/src/platforms/rcore_drm.c @@ -277,7 +277,7 @@ void MinimizeWindow(void) TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform"); diff --git a/src/platforms/rcore_template.c b/src/platforms/rcore_template.c index 42c243746..36629fc69 100644 --- a/src/platforms/rcore_template.c +++ b/src/platforms/rcore_template.c @@ -114,7 +114,7 @@ void MinimizeWindow(void) TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { TRACELOG(LOG_WARNING, "RestoreWindow() not available on target platform"); diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 0972e9680..b3bb43b5b 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -350,7 +350,7 @@ void MinimizeWindow(void) TRACELOG(LOG_WARNING, "MinimizeWindow() not available on target platform"); } -// Set window state: not minimized/maximized +// Restore window from being minimized/maximized void RestoreWindow(void) { if ((glfwGetWindowAttrib(platform.handle, GLFW_RESIZABLE) == GLFW_TRUE) && (CORE.Window.flags & FLAG_WINDOW_MAXIMIZED)) diff --git a/src/raylib.h b/src/raylib.h index 7919db775..fc949a02d 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -987,7 +987,7 @@ RLAPI void ToggleFullscreen(void); // Toggle wind RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed, resizes window to match monitor resolution RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable -RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized +RLAPI void RestoreWindow(void); // Restore window from being minimized/maximized RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit) RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit) RLAPI void SetWindowTitle(const char *title); // Set title for window From 336fd78f7427cdbca9131a1cf86778e941e0b6eb Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Thu, 27 Mar 2025 10:52:32 -0600 Subject: [PATCH 05/11] Add core_highdpi example This example enables HIGHDPI and renders a scale showing how the logical size compares to the pixel size of the window. --- examples/Makefile | 1 + examples/Makefile.Web | 1 + examples/README.md | 1 + examples/core/core_high_dpi.c | 119 ++++ examples/core/core_high_dpi.png | Bin 0 -> 3286 bytes .../VS2022/examples/core_high_dpi.vcxproj | 569 ++++++++++++++++++ projects/VS2022/raylib.sln | 2 + 7 files changed, 693 insertions(+) create mode 100644 examples/core/core_high_dpi.c create mode 100644 examples/core/core_high_dpi.png create mode 100644 projects/VS2022/examples/core_high_dpi.vcxproj diff --git a/examples/Makefile b/examples/Makefile index 6a859eb5f..5f2a18c6f 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -508,6 +508,7 @@ CORE = \ core/core_custom_frame_control \ core/core_custom_logging \ core/core_drop_files \ + core/core_high_dpi \ core/core_input_gamepad \ core/core_input_gestures \ core/core_input_gestures_web \ diff --git a/examples/Makefile.Web b/examples/Makefile.Web index b9a521bb0..7ec6868e2 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -390,6 +390,7 @@ CORE = \ core/core_custom_frame_control \ core/core_custom_logging \ core/core_drop_files \ + core/core_high_dpi \ core/core_input_gamepad \ core/core_input_gestures \ core/core_input_gestures_web \ diff --git a/examples/README.md b/examples/README.md index c42a701a2..38daad717 100644 --- a/examples/README.md +++ b/examples/README.md @@ -59,6 +59,7 @@ Examples using raylib core platform functionality like window creation, inputs, | 33 | [core_basic_window_web](core/core_basic_window_web.c) | core_basic_window_web | ⭐️☆☆☆ | 1.3 | 1.3 | [Ray](https://github.com/raysan5) | | 34 | [core_input_gestures_web](core/core_input_gestures_web.c) | core_input_gestures_web | ⭐️⭐️☆☆ | 4.6-dev | 4.6-dev | [ubkp](https://github.com/ubkp) | | 35 | [core_automation_events](core/core_automation_events.c) | core_automation_events | ⭐️⭐️⭐️☆ | 5.0 | 5.0 | [Ray](https://github.com/raysan5) | +| 36 | [core_high_dpi](core/core_high_dpi.c) | core_high_dpi | ⭐️☆☆☆ | 5.0 | 5.0 | [Jonathan Marler](https://github.com/marler8997) | ### category: shapes diff --git a/examples/core/core_high_dpi.c b/examples/core/core_high_dpi.c new file mode 100644 index 000000000..db0d6e9e6 --- /dev/null +++ b/examples/core/core_high_dpi.c @@ -0,0 +1,119 @@ +/******************************************************************************************* +* +* raylib [core] example - HighDPI +* +* Example complexity rating: [★☆☆☆] e/4 +* +* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, +* BSD-like license that allows static linking with closed source software +* +* Copyright (c) 2013-2025 Ramon Santamaria (@raysan5) +* +********************************************************************************************/ + +#include "raylib.h" + +static void DrawTextCenter(const char *text, int x, int y, int fontSize, Color color) +{ + Vector2 size = MeasureTextEx(GetFontDefault(), text, fontSize, 3); + Vector2 pos = (Vector2){x - size.x/2, y - size.y/2 }; + DrawTextEx(GetFontDefault(), text, pos, fontSize, 3, color); +} + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main(void) +{ + // Initialization + //-------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE); + + InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi"); + SetWindowMinSize(450, 450); + + SetTargetFPS(60); // Set our game to run at 60 frames-per-second + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + int monitorCount = GetMonitorCount(); + if (monitorCount > 1 && IsKeyPressed(KEY_N)) { + SetWindowMonitor((GetCurrentMonitor() + 1) % monitorCount); + } + int currentMonitor = GetCurrentMonitor(); + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + Vector2 dpiScale = GetWindowScaleDPI(); + ClearBackground(RAYWHITE); + + int windowCenter = GetScreenWidth() / 2; + DrawTextCenter(TextFormat("Dpi Scale: %f", dpiScale.x), windowCenter, 30, 40, DARKGRAY); + DrawTextCenter(TextFormat("Monitor: %d/%d ([N] next monitor)", currentMonitor+1, monitorCount), windowCenter, 70, 16, LIGHTGRAY); + + const int logicalGridDescY = 120; + const int logicalGridLabelY = logicalGridDescY + 30; + const int logicalGridTop = logicalGridLabelY + 30; + const int logicalGridBottom = logicalGridTop + 80; + const int pixelGridTop = logicalGridBottom - 20; + const int pixelGridBottom = pixelGridTop + 80; + const int pixelGridLabelY = pixelGridBottom + 30; + const int pixelGridDescY = pixelGridLabelY + 30; + + const int cellSize = 50; + const float cellSizePx = ((float)cellSize) / dpiScale.x; + + DrawTextCenter(TextFormat("Window is %d \"logical points\" wide", GetScreenWidth()), windowCenter, logicalGridDescY, 20, ORANGE); + bool odd = true; + for (int i = cellSize; i < GetScreenWidth(); i += cellSize, odd = !odd) { + if (odd) { + DrawRectangle(i, logicalGridTop, cellSize, logicalGridBottom-logicalGridTop, ORANGE); + } + DrawTextCenter(TextFormat("%d", i), i, logicalGridLabelY, 12, LIGHTGRAY); + DrawLine(i, logicalGridLabelY + 10, i, logicalGridBottom, GRAY); + } + + odd = true; + const int minTextSpace = 30; + int last_text_x = -minTextSpace; + for (int i = cellSize; i < GetRenderWidth(); i += cellSize, odd = !odd) { + int x = ((float)i) / dpiScale.x; + if (odd) { + DrawRectangle(x, pixelGridTop, cellSizePx, pixelGridBottom-pixelGridTop, CLITERAL(Color){ 0, 121, 241, 100 }); + } + DrawLine(x, pixelGridTop, ((float)i) / dpiScale.x, pixelGridLabelY - 10, GRAY); + if (x - last_text_x >= minTextSpace) { + DrawTextCenter(TextFormat("%d", i), x, pixelGridLabelY, 12, LIGHTGRAY); + last_text_x = x; + } + } + + DrawTextCenter(TextFormat("Window is %d \"physical pixels\" wide", GetRenderWidth()), windowCenter, pixelGridDescY, 20, BLUE); + + { + const char *text = "Can you see this?"; + Vector2 size = MeasureTextEx(GetFontDefault(), text, 16, 3); + Vector2 pos = (Vector2){GetScreenWidth() - size.x - 5, GetScreenHeight() - size.y - 5}; + DrawTextEx(GetFontDefault(), text, pos, 16, 3, LIGHTGRAY); + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} diff --git a/examples/core/core_high_dpi.png b/examples/core/core_high_dpi.png new file mode 100644 index 0000000000000000000000000000000000000000..a5c3539396b19fb97cb1f292e73def480f73a6d2 GIT binary patch literal 3286 zcmd@WX;f2Z_OVzj2+?Ef0vceL76oKe*%C+*g@j!ZS=0m!%K$=K*+pMdphlpIcI*%{Fu4t-0v>mz2E(o z_wK#NW23{YEp06U0Iy-1PkVw!BN2g z&{AVHpSlE=?P4Q$@0gjHiH(iz?Cdmr4OCQA)ZSOdlwM<=#skIE=joS*V6*r0u}NeA zun`&2L`?cN4OXrx+>uxqN6ILqq!y$Dv8h>kh3?Tib~|i!_j31{euOm>a$_q2q`cc{ePo> z3JSo-K4k%z!xo<2n>|gw`gK*K$C9spUFi#$H-ag=j_IQ1E`L9md*|il>1mw3x3sMH z*+ChyyYFN@v5K?7OX8$<9V(DZmj1!4R@GoPkvv)Y z{nRFnqK{VhG1dTJ5r0>GvN%|R5;>|6pWw$l{6%}lsHECnbY_A6E(9D$fYnvyK&?Z< z1SM%!pM@=3`Md8(qE5wc;A`Y8tYP`@>Q$7XV>KZ;7fPTLKPveeNvi&ho_EEix?%s$ zig!`5l_ewC-#z|`v-s^E0N_PtH&4%kx)jUHyUd{u^Vcus$3)Y!@#Eb{XZ?Wl$+Hg! z8c2J-k#D?3PSNAB2sS^t&i%YADCSK}M{yFm%2g$ffv1jWNw>pUh+&F&l2FO(@RuV* zUj_d#>Srh()43g8b71M*4b!9_CF^k{5~w6_x>u&*2WT z2)Cqn21}e*P4d-kDl#|kb9wO`sjI(7XplEfY>~XSZOTJ_oT&^e+cv?hD#Rkv9EBSP zOWOPwi0-ri@zY0imGbDgKxwD#-(RX39&5~4xleW}*fiSp0LL;8Bn- zBc@rn%#CB;mJm4qTsY!7@8sHH0DwN-x|8H8=7+k0FHAAQY^^A{u`>`_A6gzqN-(6M|_<1CZ~;5~%0z2T#x%ki6N z-?`R?V+y4+pfhT3*092g)F&FGSd;Qj;|Ut3-;k5g-$2`hweKQLXoL#Q6zI%Nd?dU5 zSdgHNVw``acY*hXBhb&bqab+~B-N3r%3@XzGh@bI2r(AOL0sR-!ll^<$V_7R0n;*ho&jwIZ8t9f5`zfIwBbfvt#<84&q+`>KImN#=&|2^eP z7B`*;_JtWX&O6;}U0_Z3(ke&U7WA{oHPO@*KdAhFUg+Z()CpokyT>fQE~x67U3Lt{r{H;J-3VSc2kLs!#+=268X8`5?hW8#)=QT=6!wg!9Z@v z`V+SX=>e;9TCESe_2&Ht42{`peqh}IFZWBXhxoyuh*`NK?pkU+cmGX6dWeR)Q`F_x z5YvC%5;_j@o5gQ#6?K#-yM;}*U&`ru!z=>FG51iXRoJ?0CmUC%F9$w*RUJCd4#4{z z_z=Xg+GBKi918QEgsmyj2~wZ$v*d2=Kl~~r+i1zioUd9TrK=FAhIku~+K~@zeHQ3j zT+3DrBzJ~YJ=daUBxwhO10ba@jTy{*8d^j z!a}~3SXQKcf=1UduM$I%NY+U4&sr~}J)OAuy-5205yE2?5p}KTfU>*>)AYGNrRdu| zAHppVS}o5X%x;!~#YgLc*74VhvsT+?gRW%KW|TpEz&|7m#MQtZ4qU@*^g-yn?z7`5 z1?$Lp=L9!g^g|>c1zR~A`a)b}!yw;52IBb31Xbq>f~vvCEpXZ1M(r_Z{kBw#CmWQJ zx@T^!ID&j=A7(rHF(>9;CAS2>I*NMxQLgdhkNFlIDs_k z9$Lp zAg!)vuOjONSVaQqJ7O+{4f4iY~aJys6BY*-bU{&bH(fc<|Jn zy~zC|m_Ro1u43!tL~n1}mQwK#kVFb- literal 0 HcmV?d00001 diff --git a/projects/VS2022/examples/core_high_dpi.vcxproj b/projects/VS2022/examples/core_high_dpi.vcxproj new file mode 100644 index 000000000..9e4fa1406 --- /dev/null +++ b/projects/VS2022/examples/core_high_dpi.vcxproj @@ -0,0 +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 + + + + {BCB71111-8505-4B35-8CEF-EC6115DC9D4D} + Win32Proj + core_high_dpi + 10.0 + core_high_dpi + + + + 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\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + WindowsLocalDebugger + + + $(SolutionDir)..\..\examples\core + 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} + + + + + + diff --git a/projects/VS2022/raylib.sln b/projects/VS2022/raylib.sln index 3859c15b0..66c385ff1 100644 --- a/projects/VS2022/raylib.sln +++ b/projects/VS2022/raylib.sln @@ -41,6 +41,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_custom_logging", "exam EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_drop_files", "examples\core_drop_files.vcxproj", "{0199E349-0701-40BC-8A7F-06A54FFA3E7C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_high_dpi", "examples\core_high_dpi.vcxproj", "{BCB71111-8505-4B35-8CEF-EC6115DC9D4D}" +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_input_gamepad", "examples\core_input_gamepad.vcxproj", "{8F19E3DA-8929-4000-87B5-3CA6929636CC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core_input_gestures", "examples\core_input_gestures.vcxproj", "{51A00565-5787-4911-9CC0-28403AA4909D}" From f19d4c71ab071d089327d974e0af94ef0a988de0 Mon Sep 17 00:00:00 2001 From: Jonathan Marler Date: Mon, 31 Mar 2025 10:23:34 -0600 Subject: [PATCH 06/11] core_window_flags example: add borderless windowed toggle --- examples/core/core_window_flags.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c index bb5543b1d..fb4058a9f 100644 --- a/examples/core/core_window_flags.c +++ b/examples/core/core_window_flags.c @@ -134,6 +134,9 @@ int main(void) else SetWindowState(FLAG_VSYNC_HINT); } + if (IsKeyPressed(KEY_B)) ToggleBorderlessWindowed(); + + // Bouncing ball logic ballPosition.x += ballSpeed.x; ballPosition.y += ballSpeed.y; @@ -179,14 +182,16 @@ int main(void) else DrawText("[A] FLAG_WINDOW_ALWAYS_RUN: off", 10, 240, 10, MAROON); if (IsWindowState(FLAG_VSYNC_HINT)) DrawText("[V] FLAG_VSYNC_HINT: on", 10, 260, 10, LIME); else DrawText("[V] FLAG_VSYNC_HINT: off", 10, 260, 10, MAROON); + if (IsWindowState(FLAG_BORDERLESS_WINDOWED_MODE)) DrawText("[B] FLAG_BORDERLESS_WINDOWED_MODE: on", 10, 280, 10, LIME); + else DrawText("[B] FLAG_BORDERLESS_WINDOWED_MODE: off", 10, 280, 10, MAROON); - DrawText("Following flags can only be set before window creation:", 10, 300, 10, GRAY); - if (IsWindowState(FLAG_WINDOW_HIGHDPI)) DrawText("FLAG_WINDOW_HIGHDPI: on", 10, 320, 10, LIME); - else DrawText("FLAG_WINDOW_HIGHDPI: off", 10, 320, 10, MAROON); - if (IsWindowState(FLAG_WINDOW_TRANSPARENT)) DrawText("FLAG_WINDOW_TRANSPARENT: on", 10, 340, 10, LIME); - else DrawText("FLAG_WINDOW_TRANSPARENT: off", 10, 340, 10, MAROON); - if (IsWindowState(FLAG_MSAA_4X_HINT)) DrawText("FLAG_MSAA_4X_HINT: on", 10, 360, 10, LIME); - else DrawText("FLAG_MSAA_4X_HINT: off", 10, 360, 10, MAROON); + DrawText("Following flags can only be set before window creation:", 10, 320, 10, GRAY); + if (IsWindowState(FLAG_WINDOW_HIGHDPI)) DrawText("FLAG_WINDOW_HIGHDPI: on", 10, 340, 10, LIME); + else DrawText("FLAG_WINDOW_HIGHDPI: off", 10, 340, 10, MAROON); + if (IsWindowState(FLAG_WINDOW_TRANSPARENT)) DrawText("FLAG_WINDOW_TRANSPARENT: on", 10, 360, 10, LIME); + else DrawText("FLAG_WINDOW_TRANSPARENT: off", 10, 360, 10, MAROON); + if (IsWindowState(FLAG_MSAA_4X_HINT)) DrawText("FLAG_MSAA_4X_HINT: on", 10, 380, 10, LIME); + else DrawText("FLAG_MSAA_4X_HINT: off", 10, 380, 10, MAROON); EndDrawing(); //----------------------------------------------------- From d52687eeee6697336c084ada437b98fb2ebbdd7c Mon Sep 17 00:00:00 2001 From: Lumen Keyes Date: Mon, 31 Mar 2025 13:36:51 -0600 Subject: [PATCH 07/11] Add Android Target to build.zig Added an Android target to the zig build script. This allows a user to easily build with only Android-supported libraries. Library paths are automatically inferred as much as possible. --- build.zig | 88 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 16 deletions(-) diff --git a/build.zig b/build.zig index b67ff49d9..a5f88d2b5 100644 --- a/build.zig +++ b/build.zig @@ -16,6 +16,7 @@ fn setDesktopPlatform(raylib: *std.Build.Step.Compile, platform: PlatformBackend .glfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_GLFW", ""), .rgfw => raylib.root_module.addCMacro("PLATFORM_DESKTOP_RGFW", ""), .sdl => raylib.root_module.addCMacro("PLATFORM_DESKTOP_SDL", ""), + .android => raylib.root_module.addCMacro("PLATFORM_ANDROID", ""), else => {}, } } @@ -181,7 +182,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. .windows => { switch (options.platform) { .glfw => try c_source_files.append("src/rglfw.c"), - .rgfw, .sdl, .drm => {}, + .rgfw, .sdl, .drm, .android => {}, } raylib.linkSystemLibrary("winmm"); @@ -191,7 +192,71 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. setDesktopPlatform(raylib, options.platform); }, .linux => { - if (options.platform != .drm) { + + if (options.platform == .drm) { + if (options.opengl_version == .auto) { + raylib.linkSystemLibrary("GLESv2"); + raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); + } + + raylib.linkSystemLibrary("EGL"); + raylib.linkSystemLibrary("gbm"); + raylib.linkSystemLibrary2("libdrm", .{ .use_pkg_config = .force }); + + raylib.root_module.addCMacro("PLATFORM_DRM", ""); + raylib.root_module.addCMacro("EGL_NO_X11", ""); + raylib.root_module.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", ""); + } else if (target.result.abi == .android) { + + //these are the only tag options per https://developer.android.com/ndk/guides/other_build_systems + const hostTuple = switch(builtin.target.os.tag) { + .linux => "linux-x86_64", + .windows => "windows-x86_64", + .macos => "darwin-x86_64", + else => { + @panic("unsupported host OS"); + } + }; + + const androidTriple = try target.result.linuxTriple(b.allocator); + const androidNdkPathString: []const u8 = options.android_ndk; + if(androidNdkPathString.len < 1) @panic("no ndk path provided and ANDROID_NDK_HOME is not set"); + const androidApiLevel: []const u8 = options.android_api_version; + + const androidSysroot = try std.fs.path.join(b.allocator, &.{androidNdkPathString, "/toolchains/llvm/prebuilt/", hostTuple, "/sysroot"}); + const androidLibPath = try std.fs.path.join(b.allocator, &.{androidSysroot, "/usr/lib/", androidTriple}); + const androidApiSpecificPath = try std.fs.path.join(b.allocator, &.{androidLibPath, androidApiLevel}); + const androidIncludePath = try std.fs.path.join(b.allocator, &.{androidSysroot, "/usr/include"}); + const androidArchIncludePath = try std.fs.path.join(b.allocator, &.{androidIncludePath, androidTriple}); + const androidAsmPath = try std.fs.path.join(b.allocator, &.{androidIncludePath, "/asm-generic"}); + const androidGluePath = try std.fs.path.join(b.allocator, &.{androidNdkPathString, "/sources/android/native_app_glue/"}); + + raylib.addLibraryPath(.{ .cwd_relative = androidLibPath}); + raylib.root_module.addLibraryPath(.{ .cwd_relative = androidApiSpecificPath }); + raylib.addSystemIncludePath(.{ .cwd_relative = androidIncludePath }); + raylib.addSystemIncludePath(.{ .cwd_relative = androidArchIncludePath}); + raylib.addSystemIncludePath( .{ .cwd_relative = androidAsmPath}); + raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath}); + + const libcFile = try std.fs.cwd().createFile("android-libc.txt", .{}); + const writer = libcFile.writer(); + const libc = std.zig.LibCInstallation{ + .include_dir = androidIncludePath, + .sys_include_dir = androidIncludePath, + .crt_dir = androidApiSpecificPath, + }; + try libc.render(writer); + libcFile.close(); + + raylib.setLibCFile(b.path("android-libc.txt")); + + if (options.opengl_version == .auto) { + raylib.root_module.linkSystemLibrary("GLESv2", .{}); + raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); + } + + setDesktopPlatform(raylib, .android); + } else { try c_source_files.append("src/rglfw.c"); if (options.linux_display_backend == .X11 or options.linux_display_backend == .Both) { @@ -229,21 +294,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. waylandGenerate(b, raylib, "xdg-activation-v1.xml", "xdg-activation-v1-client-protocol"); waylandGenerate(b, raylib, "idle-inhibit-unstable-v1.xml", "idle-inhibit-unstable-v1-client-protocol"); } - setDesktopPlatform(raylib, options.platform); - } else { - if (options.opengl_version == .auto) { - raylib.linkSystemLibrary("GLESv2"); - raylib.root_module.addCMacro("GRAPHICS_API_OPENGL_ES2", ""); - } - - raylib.linkSystemLibrary("EGL"); - raylib.linkSystemLibrary("gbm"); - raylib.linkSystemLibrary2("libdrm", .{ .use_pkg_config = .force }); - - raylib.root_module.addCMacro("PLATFORM_DRM", ""); - raylib.root_module.addCMacro("EGL_NO_X11", ""); - raylib.root_module.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", ""); } }, .freebsd, .openbsd, .netbsd, .dragonfly => { @@ -335,6 +386,8 @@ pub const Options = struct { shared: bool = false, linux_display_backend: LinuxDisplayBackend = .Both, opengl_version: OpenglVersion = .auto, + android_ndk: []const u8 = "", + android_api_version: []const u8 = "35", /// config should be a list of space-separated cflags, eg, "-DSUPPORT_CUSTOM_FRAME_CONTROL" config: []const u8 = &.{}, @@ -352,6 +405,8 @@ pub const Options = struct { .linux_display_backend = b.option(LinuxDisplayBackend, "linux_display_backend", "Linux display backend to use") orelse defaults.linux_display_backend, .opengl_version = b.option(OpenglVersion, "opengl_version", "OpenGL version to use") orelse defaults.opengl_version, .config = b.option([]const u8, "config", "Compile with custom define macros overriding config.h") orelse &.{}, + .android_ndk = b.option([]const u8, "android_ndk", "specify path to android ndk") orelse std.process.getEnvVarOwned(b.allocator, "ANDROID_NDK_HOME") catch "", + .android_api_version = b.option([]const u8, "android_api_version", "specify target android API level") orelse defaults.android_api_version, }; } }; @@ -389,6 +444,7 @@ pub const PlatformBackend = enum { rgfw, sdl, drm, + android }; pub fn build(b: *std.Build) !void { From 1a67dcb578b26479254713b21cff07091077ed20 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 1 Apr 2025 01:26:51 +0200 Subject: [PATCH 08/11] REVIEWED: RGB order on SDL3 #3568 --- src/platforms/rcore_desktop_sdl.c | 46 ++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 6e62838e3..0164d15d9 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -702,70 +702,84 @@ void SetWindowIcon(Image image) switch (image.format) { case PIXELFORMAT_UNCOMPRESSED_GRAYSCALE: + { rmask = 0xFF, gmask = 0; bmask = 0, amask = 0; depth = 8, pitch = image.width; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA: + { rmask = 0xFF, gmask = 0xFF00; bmask = 0, amask = 0; depth = 16, pitch = image.width*2; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R5G6B5: + { rmask = 0xF800, gmask = 0x07E0; bmask = 0x001F, amask = 0; depth = 16, pitch = image.width*2; - break; - case PIXELFORMAT_UNCOMPRESSED_R8G8B8: // Uses BGR for 24-bit - rmask = 0x0000FF, gmask = 0x00FF00; - bmask = 0xFF0000, amask = 0; + } break; + case PIXELFORMAT_UNCOMPRESSED_R8G8B8: + { + // WARNING: SDL2 could be using BGR but SDL3 RGB + rmask = 0xFF0000, gmask = 0x00FF00; + bmask = 0x0000FF, amask = 0; depth = 24, pitch = image.width*3; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R5G5B5A1: + { rmask = 0xF800, gmask = 0x07C0; bmask = 0x003E, amask = 0x0001; depth = 16, pitch = image.width*2; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R4G4B4A4: + { rmask = 0xF000, gmask = 0x0F00; bmask = 0x00F0, amask = 0x000F; depth = 16, pitch = image.width*2; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R8G8B8A8: + { rmask = 0xFF000000, gmask = 0x00FF0000; bmask = 0x0000FF00, amask = 0x000000FF; depth = 32, pitch = image.width*4; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R32: + { rmask = 0xFFFFFFFF, gmask = 0; bmask = 0, amask = 0; depth = 32, pitch = image.width*4; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R32G32B32: + { rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF; bmask = 0xFFFFFFFF, amask = 0; depth = 96, pitch = image.width*12; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R32G32B32A32: + { rmask = 0xFFFFFFFF, gmask = 0xFFFFFFFF; bmask = 0xFFFFFFFF, amask = 0xFFFFFFFF; depth = 128, pitch = image.width*16; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R16: + { rmask = 0xFFFF, gmask = 0; bmask = 0, amask = 0; depth = 16, pitch = image.width*2; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R16G16B16: + { rmask = 0xFFFF, gmask = 0xFFFF; bmask = 0xFFFF, amask = 0; depth = 48, pitch = image.width*6; - break; + } break; case PIXELFORMAT_UNCOMPRESSED_R16G16B16A16: + { rmask = 0xFFFF, gmask = 0xFFFF; bmask = 0xFFFF, amask = 0xFFFF; depth = 64, pitch = image.width*8; - break; + } break; default: return; // Compressed formats are not supported } From 33b2829a89a9ff6d971fe8fcf323e1b4b90e4628 Mon Sep 17 00:00:00 2001 From: Lumen Keyes Date: Tue, 1 Apr 2025 10:43:22 -0600 Subject: [PATCH 09/11] fix android-libc.txt generation Previously, the libc paths file `android-libc.txt` was written to the folder from which the user ran `zig build`. This caused problems when using raylib as a dependency in other zig projects, since raylib is not built in the project root, but the `android-libc.txt` file was still generated in the project root. The file should now be generated in .zig-cache, which should fix the isssue (and leave the project root folder cleaner). --- build.zig | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index a5f88d2b5..dd0d6df6e 100644 --- a/build.zig +++ b/build.zig @@ -238,17 +238,15 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. raylib.addSystemIncludePath( .{ .cwd_relative = androidAsmPath}); raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath}); - const libcFile = try std.fs.cwd().createFile("android-libc.txt", .{}); - const writer = libcFile.writer(); - const libc = std.zig.LibCInstallation{ + var libcData = std.ArrayList(u8).init(b.allocator).writer(); + const writer = libcData.writer(); + try (std.zig.LibCInstallation{ .include_dir = androidIncludePath, .sys_include_dir = androidIncludePath, .crt_dir = androidApiSpecificPath, - }; - try libc.render(writer); - libcFile.close(); - - raylib.setLibCFile(b.path("android-libc.txt")); + }).render(writer); + const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice()); + raylib.setLibCFile(libcFile); if (options.opengl_version == .auto) { raylib.root_module.linkSystemLibrary("GLESv2", .{}); From d0cf8961d308cc7037df67d70ec1ea75cdf203b7 Mon Sep 17 00:00:00 2001 From: Lumen Keyes Date: Tue, 1 Apr 2025 10:54:51 -0600 Subject: [PATCH 10/11] fix typo --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index dd0d6df6e..d7d118003 100644 --- a/build.zig +++ b/build.zig @@ -238,7 +238,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std. raylib.addSystemIncludePath( .{ .cwd_relative = androidAsmPath}); raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath}); - var libcData = std.ArrayList(u8).init(b.allocator).writer(); + var libcData = std.ArrayList(u8).init(b.allocator); const writer = libcData.writer(); try (std.zig.LibCInstallation{ .include_dir = androidIncludePath, From 1c4aa1378f61e24b2699b24ce05d5a16db64f380 Mon Sep 17 00:00:00 2001 From: Eike Decker Date: Tue, 1 Apr 2025 23:07:59 +0200 Subject: [PATCH 11/11] [rcore][SDL2] First touch position is overwritten with mouse pos I believe it makes sense to only do this when there are no known touch points. I am not even sure if this should be done at all. See https://github.com/raysan5/raylib/issues/4872 for more information. --- src/platforms/rcore_desktop_sdl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/platforms/rcore_desktop_sdl.c b/src/platforms/rcore_desktop_sdl.c index 0164d15d9..517e43914 100644 --- a/src/platforms/rcore_desktop_sdl.c +++ b/src/platforms/rcore_desktop_sdl.c @@ -1363,7 +1363,10 @@ void PollInputEvents(void) for (int i = 0; i < MAX_TOUCH_POINTS; i++) CORE.Input.Touch.previousTouchState[i] = CORE.Input.Touch.currentTouchState[i]; // Map touch position to mouse position for convenience - CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; + if (CORE.Input.Touch.pointCount == 0) + { + CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; + } int touchAction = -1; // 0-TOUCH_ACTION_UP, 1-TOUCH_ACTION_DOWN, 2-TOUCH_ACTION_MOVE bool realTouch = false; // Flag to differentiate real touch gestures from mouse ones