[package]
name = "sdl3"
description = "Bindings to SDL3, a cross-platform library to abstract the platform-specific details for building applications."
repository = "https://github.com/vhspace/sdl3-rs"
documentation = "https://docs.rs/sdl3/latest/sdl3/"
version = "0.18.4"
license = "MIT"
authors = [
    "Tony Aldridge <tony@angry-lawyer.com>",
    "Cobrand <cobrandw@gmail.com>",
    "Mischa Spiegelmock <me@mish.dev>",
    "Lokathor <@Lokathor@mastodon.social>",
]
keywords = ["graphics", "engine", "cross-platform", "input", "audio"]
categories = ["rendering", "api-bindings", "game-engines", "multimedia"]
readme = "README.md"
resolver = "2"
edition = "2021"

[lib]
name = "sdl3"
path = "src/sdl3/lib.rs"

[dependencies]
bitflags = "2.11.1"
libc = "0.2.186"

[dependencies.sdl3-sys]
version = "0.6.5"
features = ["metadata"]

[dependencies.sdl3-image-sys]
version = "0.6"
optional = true

[dependencies.sdl3-ttf-sys]
version = "0.6"
optional = true

[dependencies.sdl3-mixer-sys]
version = "0.6"
optional = true

[dependencies.sdl3-main]
version = "0.6"
optional = true

[dependencies.c_vec]
version = "2"
optional = true

[dependencies.raw-window-handle]
version = "0.6.2"
optional = true

[target.'cfg(target_os = "macos")'.dependencies.objc2]
version = "0.6.4"
optional = true

[dev-dependencies]
rand = "0.10.1"
wgpu = { version = "29.0.1", features = ["spirv"] }
pollster = "0.4.0"
env_logger = "0.11.10"

# wgpu-hal 29.0.1 has two Windows-only resolution problems that we paper over
# from this side via Cargo's feature unification / version selection:
#
# 1. `windows-core` is pulled in with `default-features = false`, which turns
#    off the `std` feature and drops the `core::error::Error` impl on
#    `windows_core::Error`. wgpu-hal's gles backend (wgl.rs) then fails to
#    compile because `InstanceError::with_source` requires `impl Error`.
# 2. wgpu-hal asks for `windows = "0.62"` while gpu-allocator 0.28 accepts
#    `>=0.53, <=0.62` and the resolver picks 0.58 for gpu-allocator. The two
#    versions then collide in wgpu-hal's dx12 backend (gpu-allocator wants
#    `windows@0.58::ID3D12Device`, wgpu-hal hands it `windows@0.62::ID3D12Device`).
#    Pinning `windows = "0.62"` here forces gpu-allocator onto the same version.
[target.'cfg(windows)'.dev-dependencies]
windows-core = { version = "0.62", features = ["std"] }
windows = "0.62"

[build-dependencies]
sdl3-sys = { version = "0.6.5", features = ["only-metadata"] }


[features]

# various ways to link to libsdl3
# provided by sdl3-sys: https://github.com/maia-s/sdl3-sys-rs/tree/main/sdl3-sys#usage
use-pkg-config = ["sdl3-sys/use-pkg-config"]
use-vcpkg = ["sdl3-sys/use-vcpkg"]
static-link = ["sdl3-sys/link-static"]
link-framework = ["sdl3-sys/link-framework"]
build-from-source = [
    "sdl3-sys/build-from-source",
    "sdl3-image-sys?/build-from-source",
    "sdl3-ttf-sys?/build-from-source",
    "sdl3-mixer-sys?/build-from-source",
]
build-from-source-static = [
    "sdl3-sys/build-from-source-static",
    "sdl3-image-sys?/build-from-source-static",
    "sdl3-ttf-sys?/build-static-vendored",
    "sdl3-mixer-sys?/build-static-vendored",
]
build-from-source-unix-console = ["sdl3-sys/sdl-unix-console-build"]
ash = ["sdl3-sys/use-ash-v0-38"]
default = []
unsafe_textures = []
# DEPRECATED: gfx feature is non-functional - SDL_gfx has not been ported to SDL3 yet.
# See: https://github.com/vhspace/sdl3-rs/issues/160
gfx = ["c_vec"] #, "sdl3-sys/gfx"]
mixer = ["dep:sdl3-mixer-sys"]
image = ["dep:sdl3-image-sys"]
ttf = ["dep:sdl3-ttf-sys"]
# Use hidapi support in SDL. Only 2.0.12 and after
hidapi = []
# test_mode allows SDL to be initialised from a thread that is not the main thread
test-mode = []
# allows sdl3 to be used with wgpu
raw-window-handle = ["dep:raw-window-handle", "dep:objc2"]
# integration with sdl3-main, for using SDL's callback interface with types from this crate
main = ["dep:sdl3-main"]

[package.metadata.docs.rs]
#features = ["default", "gfx", "mixer", "image", "ttf"]
#features = ["default", "gfx"]
features = ["default", "raw-window-handle"]

[[example]]
name = "animation"

[[example]]
name = "audio-capture-and-replay"

[[example]]
name = "audio-queue-squarewave"

[[example]]
name = "audio-squarewave"

[[example]]
name = "audio-wav"

[[example]]
name = "audio-whitenoise"

[[example]]
required-features = ["image"]
name = "cursor"

[[example]]
name = "draw_triangle"

[[example]]
name = "demo"

[[example]]
name = "gamepad"

[[example]]
required-features = ["unsafe_textures"]
name = "game-of-life-unsafe-textures"

[[example]]
name = "game-of-life"

[[example]]
required-features = ["gfx"]
name = "gfx-demo"

[[example]]
name = "haptic"

[[example]]
required-features = ["image"]
name = "image-demo"

[[example]]
name = "joystick"

[[example]]
name = "keyboard-state"

[[example]]
required-features = ["main"]
name = "main-callbacks-api"

[[example]]
name = "message-box"

[[example]]
required-features = ["mixer"]
name = "mixer-demo"

[[example]]
name = "mouse-state"

[[example]]
name = "no-renderer"

[[example]]
name = "relative-mouse-state"

[[example]]
name = "renderer-target"

[[example]]
name = "events"

[[example]]
name = "gpu-clear"

[[example]]
name = "gpu-triangle"

[[example]]
name = "gpu-particles"

[[example]]
name = "demo_games_02_woodeneye"
path = "examples/demo_games/a02_woodeneye_008.rs"

[[example]]
name = "renderer_01_change_the_color"
path = "examples/renderer/a01_change_the_color.rs"

[[example]]
name = "renderer_02_primitives"
path = "examples/renderer/a02_primitives.rs"

[[example]]
name = "renderer_03_lines"
path = "examples/renderer/a03_lines.rs"

[[example]]
name = "renderer_04_points"
path = "examples/renderer/a04_points.rs"

[[example]]
name = "renderer_05_rectangles"
path = "examples/renderer/a05_rectangles.rs"

[[example]]
required-features = ["unsafe_textures"]
name = "renderer_06_textures_lifetime_solution"
path = "examples/renderer/a06_textures_lifetime_solution.rs"

[[example]]
required-features = ["unsafe_textures"]
name = "renderer_07_streaming_textures"
path = "examples/renderer/a07_streaming_textures.rs"

[[example]]
required-features = ["unsafe_textures"]
name = "renderer_08_rotating_textures"
path = "examples/renderer/a08_rotating_textures.rs"

[[example]]
required-features = ["unsafe_textures"]
name = "renderer_09_scaling_textures"
path = "examples/renderer/a09_scaling_textures.rs"

[[example]]
name = "render-geometry"

[[example]]
name = "renderer-texture"

[[example]]
name = "renderer-yuv"

[[example]]
required-features = ["ttf", "image"]
name = "resource-manager"

[[example]]
required-features = ["hidapi"]
name = "sensors"

[[example]]
name = "spinning_cube"

[[example]]
required-features = ["ttf"]
name = "ttf-demo"

[[example]]
name = "window-properties"

[[example]]
required-features = ["raw-window-handle"]
name = "raw-window-handle-with-wgpu"

[[example]]
name = "virtual-joysticks"

[package.metadata.vcpkg]
dependencies = ["sdl3"]

# dependencies required when building examples and tests for this crate
dev-dependencies = [
    "sdl3",
    #    "sdl3-image[libjpeg-turbo,tiff,libwebp]",
    #    "sdl3-ttf",
    #    "sdl3-gfx",
    #    "sdl3-mixer",
]
git = "https://github.com/microsoft/vcpkg"
rev = "b322364" # 2024.12.16 Release

[package.metadata.vcpkg.target]
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-md" }
