diff --git a/build.zig b/build.zig index b67ff49d9..d7d118003 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,69 @@ 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}); + + var libcData = std.ArrayList(u8).init(b.allocator); + const writer = libcData.writer(); + try (std.zig.LibCInstallation{ + .include_dir = androidIncludePath, + .sys_include_dir = androidIncludePath, + .crt_dir = androidApiSpecificPath, + }).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", .{}); + 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 +292,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 +384,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 +403,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 +442,7 @@ pub const PlatformBackend = enum { rgfw, sdl, drm, + android }; pub fn build(b: *std.Build) !void { 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 000000000..a5c353939 Binary files /dev/null and b/examples/core/core_high_dpi.png differ diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c index ec4f6aac6..fb4058a9f 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 @@ -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)) @@ -131,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; @@ -163,9 +169,9 @@ 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); + 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); @@ -176,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(); //----------------------------------------------------- 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/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}" 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..517e43914 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); @@ -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 } @@ -1349,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 @@ -1670,7 +1687,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])); 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