Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into getdisplays
Browse files Browse the repository at this point in the history
  • Loading branch information
revmischa committed Feb 8, 2025
2 parents 1c53924 + 755e587 commit d6b9220
Show file tree
Hide file tree
Showing 115 changed files with 8,905 additions and 1,534 deletions.
27 changes: 27 additions & 0 deletions .github/actions/install-linux-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copied from https://github.com/bevyengine/bevy/blob/main/.github/actions/install-linux-deps/action.yml
#
# This action installs the necessary dependencies to build sdl3 on Ubuntu.
#
# List of required dependencies taken from https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md#build-dependencies
#
# This action will only install dependencies when the current operating system is Linux. It will do
# nothing on any other OS (macOS, Windows).

name: Install Linux dependencies
description: Installs the dependencies necessary to build sdl3 on Linux.
runs:
using: composite
steps:
- name: Install Linux dependencies
shell: bash
if: ${{ runner.os == 'linux' }}
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends \
build-essential git make \
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev \
libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev \
libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev \
libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev \
libpipewire-0.3-dev libwayland-dev libdecor-0-dev liburing-dev
64 changes: 8 additions & 56 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,27 @@ on:
pull_request:

jobs:
build-vcpkg:
name: build vcpkg
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Install cargo-vcpkg
run: cargo install cargo-vcpkg
- name: Install dependencies
run: cargo vcpkg -v build
- name: Build sdl3
shell: bash
env:
CI_BUILD_FEATURES: "use-vcpkg static-link gfx image ttf mixer"
RUST_TEST_THREADS: 1
run: |
set -xeuo pipefail
rustc --version
cargo --version
cargo build --features "${CI_BUILD_FEATURES}"
cargo build --examples --features "${CI_BUILD_FEATURES}"
cargo test --features "${CI_BUILD_FEATURES}"
build-bundled:
name: build bundled
build-from-source:
name: build from source
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
feature: ["", "static-link"]
build_mode: ["", "--release"]
os: [macos-latest, ubuntu-latest, windows-latest]
feature: ["build-from-source"]
build_mode: [""]
os: [macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Install Linux dependencies
uses: ./.github/actions/install-linux-deps
- name: Build sdl3
shell: bash
env:
# Bundled doesn't yet support gfx, image, ttf, mixer.
CI_BUILD_FEATURES: "bundled"
CI_BUILD_FEATURES: "raw-window-handle"
RUST_TEST_THREADS: 1
run: |
set -xeuo pipefail
rustc --version
cargo --version
cargo build --features "${CI_BUILD_FEATURES} ${{matrix.feature}}" ${{matrix.build_mode}}
cargo build --examples --features "${CI_BUILD_FEATURES} ${{matrix.feature}}" ${{matrix.build_mode}}
cargo test --features "${CI_BUILD_FEATURES} ${{matrix.feature}}" ${{matrix.build_mode}}
build-linux:
name: build linux pkg-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt-get update -y -qq
sudo apt-get install -y libsdl3-dev libsdl3-mixer-dev libsdl3-gfx-dev libsdl3-image-dev libsdl3-ttf-dev
- name: Build sdl3
shell: bash
env:
CI_BUILD_FEATURES: "gfx image ttf mixer"
RUST_TEST_THREADS: 1
run: |
set -xeuo pipefail
rustc --version
cargo --version
# SDL 2.0.10 so no hidapi
cargo build --no-default-features --features "${CI_BUILD_FEATURES}"
cargo test --no-default-features --features "${CI_BUILD_FEATURES}"
115 changes: 93 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "sdl3"
description = "Cross-platform multimedia"
repository = "https://github.com/revmischa/sdl3-rs"
documentation = "https://crates.io/crates/sdl3"
version = "0.11.1"
repository = "https://github.com/vhspace/sdl3-rs"
documentation = "https://docs.rs/sdl3/latest/sdl3/"
version = "0.14.7"
license = "MIT"
authors = [
"Tony Aldridge <[email protected]>",
Expand All @@ -22,29 +22,39 @@ name = "sdl3"
path = "src/sdl3/lib.rs"

[dependencies]
bitflags = "1.2.1"
libc = "0.2.92"
bitflags = "2.8.0"
libc = "0.2.169"
lazy_static = "1.4.0"

[dependencies.sdl3-sys]
version = "0.1.3+SDL3-preview-3.1.6"
version = "0.4"

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

[dependencies.c_vec]
# allow both 1.* and 2.0 versions
version = ">= 1.0"
optional = true

[dev-dependencies]
rand = "0.7"
wgpu = { version = "0.14", features = ["spirv"] }
pollster = "0.2.4"
env_logger = "0.9.0"

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

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

[dev-dependencies]
rand = "0.8.5"
wgpu = { version = "24.0.0", features = ["spirv"] }
pollster = "0.4.0"
env_logger = "0.11.6"


[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"]
Expand All @@ -53,21 +63,26 @@ static-link = ["sdl3-sys/link-static"]
link-framework = ["sdl3-sys/link-framework"]
build-from-source = ["sdl3-sys/build-from-source"]
build-from-source-static = ["sdl3-sys/build-from-source-static"]

unsafe_textures = []
build-from-source-unix-console = ["sdl3-sys/sdl-unix-console-build"]
ash = ["sdl3-sys/use-ash-v0-38"]
default = []
unsafe_textures = []
gfx = ["c_vec"] #, "sdl3-sys/gfx"]
#mixer = ["sdl3-sys/mixer"]
#image = ["sdl3-sys/image"]
image = ["dep:sdl3-image-sys"]
#ttf = ["sdl3-sys/ttf"]
# 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"]


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

[[example]]
name = "animation"
Expand All @@ -91,6 +106,9 @@ name = "audio-whitenoise"
required-features = ["image"]
name = "cursor"

[[example]]
name = "draw_triangle"

[[example]]
name = "demo"

Expand Down Expand Up @@ -143,6 +161,56 @@ name = "renderer-target"
[[example]]
name = "events"

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

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

[[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 = "renderer-texture"

Expand All @@ -157,6 +225,9 @@ name = "resource-manager"
required-features = ["hidapi"]
name = "sensors"

[[example]]
name = "spinning_cube"

[[example]]
required-features = ["ttf"]
name = "ttf-demo"
Expand All @@ -174,13 +245,13 @@ 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",
# "sdl3-image[libjpeg-turbo,tiff,libwebp]",
# "sdl3-ttf",
# "sdl3-gfx",
# "sdl3-mixer",
]
git = "https://github.com/microsoft/vcpkg"
rev = "acc3bcf" # release 2022.08.15
rev = "b322364" # 2024.12.16 Release

[package.metadata.vcpkg.target]
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-md" }
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# SDL3 ![Crates.io Version](https://img.shields.io/crates/v/sdl3)
# SDL3 ![Crates.io Version](https://img.shields.io/crates/v/sdl3) [![](https://dcbadge.limes.pink/api/server/https://discord.gg/RE93FmF6Um?style=flat)](https://discord.gg/RE93FmF6Um)



Bindings for SDL3 in Rust.

Expand All @@ -19,8 +21,8 @@ Feel free to create issues or work on them yourself.

- [x] Update all modules to SDL3, use new [sdl3-sys](https://github.com/maia-s/sdl3-sys-rs) bindings,
follow [migration guide](https://github.com/libsdl-org/SDL/blob/main/docs/README-migration.md).
- [ ] Fix tests.
- [ ] Update examples to SDL3.
- [x] Fix tests.
- [x] Update examples to SDL3.
- [ ] Add [new features](https://wiki.libsdl.org/SDL3/NewFeatures) from SDL3.
- [ ] Update documentation.

Expand Down
Binary file added assets/SDL_logo.bmp
Binary file not shown.
Binary file added assets/sample640_426.bmp
Binary file not shown.
Binary file added assets/texture.bmp
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use sdl3::keyboard::Keycode;
use sdl3::render::FRect;
use std::time::Duration;

fn main() -> Result<(), String> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
let sdl_context = sdl3::init()?;
let video_subsystem = sdl_context.video()?;

Expand Down
Loading

0 comments on commit d6b9220

Please sign in to comment.