From 36f17fdb09b56400259b552ff8b6bc7a66afbc9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charlotte=20=F0=9F=8C=B8?= Date: Sat, 13 Dec 2025 05:13:26 -0800 Subject: [PATCH 1/4] Add x11 and split out surface methods. --- Cargo.lock | 847 +----------------------- Cargo.toml | 11 +- crates/processing_ffi/Cargo.toml | 5 + crates/processing_ffi/src/lib.rs | 76 ++- crates/processing_pyo3/Cargo.toml | 8 +- crates/processing_pyo3/src/glfw.rs | 42 +- crates/processing_pyo3/src/graphics.rs | 5 +- crates/processing_render/Cargo.toml | 5 + crates/processing_render/src/lib.rs | 79 ++- crates/processing_render/src/surface.rs | 413 ++++++++---- examples/background_image.rs | 4 +- examples/glfw.rs | 42 +- examples/rectangle.rs | 4 +- examples/update_pixels.rs | 4 +- 14 files changed, 524 insertions(+), 1021 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4bd9636..02f66e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -121,28 +121,6 @@ dependencies = [ "equator", ] -[[package]] -name = "alsa" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7572b7ba83a31e20d1b48970ee402d2e3e0537dcfe0a3ff4d6eb7508617d43" -dependencies = [ - "alsa-sys", - "bitflags 2.10.0", - "cfg-if", - "libc", -] - -[[package]] -name = "alsa-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8fee663d06c4e303404ef5f40488a53e062f89ba8bfed81f42325aafad1527" -dependencies = [ - "libc", - "pkg-config", -] - [[package]] name = "android-activity" version = "0.6.0" @@ -157,9 +135,9 @@ dependencies = [ "jni-sys", "libc", "log", - "ndk 0.9.0", + "ndk", "ndk-context", - "ndk-sys 0.6.0+11769913", + "ndk-sys", "num_enum", "thiserror 1.0.69", ] @@ -437,7 +415,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom 8.0.0", + "nom", "num-rational", "v_frame", ] @@ -451,12 +429,6 @@ dependencies = [ "arrayvec", ] -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "bevy" version = "0.18.0-dev" @@ -485,48 +457,6 @@ dependencies = [ "android-activity", ] -[[package]] -name = "bevy_animation" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_animation_macros", - "bevy_app", - "bevy_asset", - "bevy_color", - "bevy_derive", - "bevy_ecs", - "bevy_math", - "bevy_mesh", - "bevy_platform", - "bevy_reflect", - "bevy_time", - "bevy_transform", - "bevy_utils", - "blake3", - "derive_more", - "downcast-rs 2.0.2", - "either", - "petgraph", - "ron", - "serde", - "smallvec", - "thiserror 2.0.17", - "thread_local", - "tracing", - "uuid", -] - -[[package]] -name = "bevy_animation_macros" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_macro_utils", - "quote", - "syn", -] - [[package]] name = "bevy_anti_alias" version = "0.18.0-dev" @@ -622,23 +552,6 @@ dependencies = [ "syn", ] -[[package]] -name = "bevy_audio" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_ecs", - "bevy_math", - "bevy_reflect", - "bevy_transform", - "coreaudio-sys", - "cpal", - "rodio", - "tracing", -] - [[package]] name = "bevy_camera" version = "0.18.0-dev" @@ -757,7 +670,6 @@ dependencies = [ "const-fnv1a-hash", "log", "serde", - "sysinfo", ] [[package]] @@ -807,21 +719,6 @@ dependencies = [ "encase_derive_impl", ] -[[package]] -name = "bevy_gilrs" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_app", - "bevy_ecs", - "bevy_input", - "bevy_platform", - "bevy_time", - "gilrs", - "thiserror 2.0.17", - "tracing", -] - [[package]] name = "bevy_gizmos" version = "0.18.0-dev" @@ -868,47 +765,12 @@ dependencies = [ "bevy_pbr", "bevy_render", "bevy_shader", - "bevy_sprite_render", "bevy_transform", "bevy_utils", "bytemuck", "tracing", ] -[[package]] -name = "bevy_gltf" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "base64", - "bevy_animation", - "bevy_app", - "bevy_asset", - "bevy_camera", - "bevy_color", - "bevy_ecs", - "bevy_image", - "bevy_light", - "bevy_math", - "bevy_mesh", - "bevy_pbr", - "bevy_platform", - "bevy_reflect", - "bevy_render", - "bevy_scene", - "bevy_tasks", - "bevy_transform", - "fixedbitset", - "gltf", - "itertools 0.14.0", - "percent-encoding", - "serde", - "serde_json", - "smallvec", - "thiserror 2.0.17", - "tracing", -] - [[package]] name = "bevy_image" version = "0.18.0-dev" @@ -928,9 +790,7 @@ dependencies = [ "guillotiere", "half", "image", - "ktx2", "rectangle-pack", - "ruzstd", "serde", "thiserror 2.0.17", "tracing", @@ -963,7 +823,6 @@ dependencies = [ "bevy_ecs", "bevy_input", "bevy_math", - "bevy_picking", "bevy_reflect", "bevy_ui", "bevy_window", @@ -978,11 +837,9 @@ source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e dependencies = [ "bevy_a11y", "bevy_android", - "bevy_animation", "bevy_anti_alias", "bevy_app", "bevy_asset", - "bevy_audio", "bevy_camera", "bevy_color", "bevy_core_pipeline", @@ -990,35 +847,24 @@ dependencies = [ "bevy_dev_tools", "bevy_diagnostic", "bevy_ecs", - "bevy_gilrs", "bevy_gizmos", "bevy_gizmos_render", - "bevy_gltf", "bevy_image", "bevy_input", - "bevy_input_focus", "bevy_light", "bevy_log", "bevy_math", "bevy_mesh", "bevy_pbr", - "bevy_picking", "bevy_platform", - "bevy_post_process", "bevy_ptr", "bevy_reflect", "bevy_render", - "bevy_scene", "bevy_shader", - "bevy_sprite", "bevy_sprite_render", - "bevy_state", "bevy_tasks", - "bevy_text", "bevy_time", "bevy_transform", - "bevy_ui", - "bevy_ui_render", "bevy_utils", "bevy_window", "bevy_winit", @@ -1082,7 +928,7 @@ dependencies = [ "bevy_reflect", "derive_more", "glam", - "itertools 0.14.0", + "itertools", "libm", "rand", "rand_distr", @@ -1168,13 +1014,11 @@ dependencies = [ "bevy_ecs", "bevy_input", "bevy_math", - "bevy_mesh", "bevy_platform", "bevy_reflect", "bevy_time", "bevy_transform", "bevy_window", - "crossbeam-channel", "tracing", "uuid", ] @@ -1198,35 +1042,6 @@ dependencies = [ "web-time", ] -[[package]] -name = "bevy_post_process" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_camera", - "bevy_color", - "bevy_core_pipeline", - "bevy_derive", - "bevy_ecs", - "bevy_image", - "bevy_math", - "bevy_platform", - "bevy_reflect", - "bevy_render", - "bevy_shader", - "bevy_transform", - "bevy_utils", - "bevy_window", - "bitflags 2.10.0", - "nonmax", - "radsort", - "smallvec", - "thiserror 2.0.17", - "tracing", -] - [[package]] name = "bevy_ptr" version = "0.18.0-dev" @@ -1249,7 +1064,6 @@ dependencies = [ "foldhash 0.2.0", "glam", "inventory", - "petgraph", "serde", "smallvec", "smol_str", @@ -1332,27 +1146,6 @@ dependencies = [ "syn", ] -[[package]] -name = "bevy_scene" -version = "0.18.0-dev" -source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" -dependencies = [ - "bevy_app", - "bevy_asset", - "bevy_camera", - "bevy_derive", - "bevy_ecs", - "bevy_platform", - "bevy_reflect", - "bevy_transform", - "bevy_utils", - "derive_more", - "ron", - "serde", - "thiserror 2.0.17", - "uuid", -] - [[package]] name = "bevy_shader" version = "0.18.0-dev" @@ -1383,7 +1176,6 @@ dependencies = [ "bevy_image", "bevy_math", "bevy_mesh", - "bevy_picking", "bevy_reflect", "bevy_text", "bevy_transform", @@ -1459,7 +1251,6 @@ dependencies = [ "async-task", "atomic-waker", "bevy_platform", - "concurrent-queue", "crossbeam-queue", "derive_more", "futures-lite", @@ -1539,7 +1330,6 @@ dependencies = [ "bevy_image", "bevy_input", "bevy_math", - "bevy_picking", "bevy_platform", "bevy_reflect", "bevy_sprite", @@ -1552,7 +1342,6 @@ dependencies = [ "taffy", "thiserror 2.0.17", "tracing", - "uuid", ] [[package]] @@ -1601,9 +1390,7 @@ version = "0.18.0-dev" source = "git+https://github.com/bevyengine/bevy?branch=main#8ca07c4727ee2cde23e7129014208cf96a08a2b6" dependencies = [ "bevy_app", - "bevy_asset", "bevy_ecs", - "bevy_image", "bevy_input", "bevy_math", "bevy_platform", @@ -1624,10 +1411,8 @@ dependencies = [ "bevy_a11y", "bevy_android", "bevy_app", - "bevy_asset", "bevy_derive", "bevy_ecs", - "bevy_image", "bevy_input", "bevy_input_focus", "bevy_log", @@ -1636,34 +1421,14 @@ dependencies = [ "bevy_reflect", "bevy_tasks", "bevy_window", - "bytemuck", "cfg-if", "js-sys", "tracing", "wasm-bindgen", "web-sys", - "wgpu-types", "winit", ] -[[package]] -name = "bindgen" -version = "0.72.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895" -dependencies = [ - "bitflags 2.10.0", - "cexpr", - "clang-sys", - "itertools 0.13.0", - "proc-macro2", - "quote", - "regex", - "rustc-hash 2.1.1", - "shlex", - "syn", -] - [[package]] name = "bit-set" version = "0.8.0" @@ -1873,15 +1638,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom 7.1.3", -] - [[package]] name = "cfg-if" version = "1.0.4" @@ -1894,17 +1650,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" -[[package]] -name = "clang-sys" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" -dependencies = [ - "glob", - "libc", - "libloading", -] - [[package]] name = "clap" version = "4.5.53" @@ -2109,26 +1854,6 @@ dependencies = [ "libm", ] -[[package]] -name = "coreaudio-rs" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321077172d79c662f64f5071a03120748d5bb652f5231570141be24cfcd2bace" -dependencies = [ - "bitflags 1.3.2", - "core-foundation-sys", - "coreaudio-sys", -] - -[[package]] -name = "coreaudio-sys" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceec7a6067e62d6f931a2baf6f3a751f4a892595bcec1461a3c94ef9949864b6" -dependencies = [ - "bindgen", -] - [[package]] name = "cosmic-text" version = "0.15.0" @@ -2141,7 +1866,7 @@ dependencies = [ "linebender_resource_handle", "log", "rangemap", - "rustc-hash 1.1.0", + "rustc-hash", "self_cell", "skrifa", "smol_str", @@ -2153,29 +1878,6 @@ dependencies = [ "unicode-segmentation", ] -[[package]] -name = "cpal" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873dab07c8f743075e57f524c583985fbaf745602acbe916a01539364369a779" -dependencies = [ - "alsa", - "core-foundation-sys", - "coreaudio-rs", - "dasp_sample", - "jni", - "js-sys", - "libc", - "mach2", - "ndk 0.8.0", - "ndk-context", - "oboe", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "windows 0.54.0", -] - [[package]] name = "crc32fast" version = "1.5.0" @@ -2257,12 +1959,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" -[[package]] -name = "dasp_sample" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f" - [[package]] name = "data-encoding" version = "2.9.0" @@ -2544,12 +2240,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "foldhash" version = "0.1.5" @@ -2717,51 +2407,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "gilrs" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb2c998745a3c1ac90f64f4f7b3a54219fd3612d7705e7798212935641ed18f" -dependencies = [ - "fnv", - "gilrs-core", - "log", - "uuid", - "vec_map", -] - -[[package]] -name = "gilrs-core" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be11a71ac3564f6965839e2ed275bf4fcf5ce16d80d396e1dfdb7b2d80bd587e" -dependencies = [ - "core-foundation 0.10.1", - "inotify", - "io-kit-sys", - "js-sys", - "libc", - "libudev-sys", - "log", - "nix", - "uuid", - "vec_map", - "wasm-bindgen", - "web-sys", - "windows 0.62.2", -] - -[[package]] -name = "gl_generator" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" -dependencies = [ - "khronos_api", - "log", - "xml-rs", -] - [[package]] name = "glam" version = "0.30.9" @@ -2799,69 +2444,6 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "glob" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" - -[[package]] -name = "glow" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" -dependencies = [ - "js-sys", - "slotmap", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "gltf" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ce1918195723ce6ac74e80542c5a96a40c2b26162c1957a5cd70799b8cacf7" -dependencies = [ - "byteorder", - "gltf-json", - "lazy_static", - "serde_json", -] - -[[package]] -name = "gltf-derive" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14070e711538afba5d6c807edb74bcb84e5dbb9211a3bf5dea0dfab5b24f4c51" -dependencies = [ - "inflections", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "gltf-json" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6176f9d60a7eab0a877e8e96548605dedbde9190a7ae1e80bbcc1c9af03ab14" -dependencies = [ - "gltf-derive", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "glutin_wgl_sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" -dependencies = [ - "gl_generator", -] - [[package]] name = "gpu-alloc" version = "0.6.0" @@ -3071,8 +2653,6 @@ checksum = "0ad4bb2b565bca0645f4d68c5c9af97fba094e9791da685bf83cb5f3ce74acf2" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", ] [[package]] @@ -3084,32 +2664,6 @@ dependencies = [ "rustversion", ] -[[package]] -name = "inflections" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" - -[[package]] -name = "inotify" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" -dependencies = [ - "bitflags 2.10.0", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - [[package]] name = "interpolate_name" version = "0.2.4" @@ -3122,22 +2676,12 @@ dependencies = [ ] [[package]] -name = "inventory" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc61209c082fbeb19919bee74b176221b27223e27b65d781eb91af24eb1fb46e" -dependencies = [ - "rustversion", -] - -[[package]] -name = "io-kit-sys" -version = "0.4.1" +name = "inventory" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617ee6cf8e3f66f3b4ea67a4058564628cde41901316e19f559e14c7c72c5e7b" +checksum = "bc61209c082fbeb19919bee74b176221b27223e27b65d781eb91af24eb1fb46e" dependencies = [ - "core-foundation-sys", - "mach2", + "rustversion", ] [[package]] @@ -3146,15 +2690,6 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.14.0" @@ -3212,32 +2747,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "khronos-egl" -version = "6.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" -dependencies = [ - "libc", - "libloading", - "pkg-config", -] - -[[package]] -name = "khronos_api" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" - -[[package]] -name = "ktx2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff7f53bdf698e7aa7ec916411bbdc8078135da11b66db5182675b2227f6c0d07" -dependencies = [ - "bitflags 2.10.0", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -3250,17 +2759,6 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a79a3332a6609480d7d0c9eab957bca6b455b91bb84e66d19f5ff66294b85b8" -[[package]] -name = "lewton" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "777b48df9aaab155475a83a7df3070395ea1ac6902f5cd062b8f2b028075c030" -dependencies = [ - "byteorder", - "ogg", - "tinyvec", -] - [[package]] name = "libc" version = "0.2.178" @@ -3304,16 +2802,6 @@ dependencies = [ "redox_syscall 0.5.18", ] -[[package]] -name = "libudev-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" -dependencies = [ - "libc", - "pkg-config", -] - [[package]] name = "linebender_resource_handle" version = "0.1.1" @@ -3414,15 +2902,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "mach2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" -dependencies = [ - "libc", -] - [[package]] name = "malloc_buf" version = "0.0.6" @@ -3490,12 +2969,6 @@ dependencies = [ "paste", ] -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3537,7 +3010,7 @@ dependencies = [ "num-traits", "once_cell", "pp-rs", - "rustc-hash 1.1.0", + "rustc-hash", "spirv", "thiserror 2.0.17", "unicode-ident", @@ -3554,26 +3027,12 @@ dependencies = [ "indexmap", "naga", "regex", - "rustc-hash 1.1.0", + "rustc-hash", "thiserror 2.0.17", "tracing", "unicode-ident", ] -[[package]] -name = "ndk" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2076a31b7010b17a38c01907c45b945e8f11495ee4dd588309718901b1f7a5b7" -dependencies = [ - "bitflags 2.10.0", - "jni-sys", - "log", - "ndk-sys 0.5.0+25.2.9519653", - "num_enum", - "thiserror 1.0.69", -] - [[package]] name = "ndk" version = "0.9.0" @@ -3583,7 +3042,7 @@ dependencies = [ "bitflags 2.10.0", "jni-sys", "log", - "ndk-sys 0.6.0+11769913", + "ndk-sys", "num_enum", "raw-window-handle", "thiserror 1.0.69", @@ -3595,15 +3054,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" -[[package]] -name = "ndk-sys" -version = "0.5.0+25.2.9519653" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" -dependencies = [ - "jni-sys", -] - [[package]] name = "ndk-sys" version = "0.6.0+11769913" @@ -3631,16 +3081,6 @@ dependencies = [ "libc", ] -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "nom" version = "8.0.0" @@ -3662,15 +3102,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi", -] - [[package]] name = "nu-ansi-term" version = "0.50.3" @@ -3995,16 +3426,6 @@ dependencies = [ "objc2-core-foundation", ] -[[package]] -name = "objc2-io-kit" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15" -dependencies = [ - "libc", - "objc2-core-foundation", -] - [[package]] name = "objc2-io-surface" version = "0.3.2" @@ -4119,29 +3540,6 @@ dependencies = [ "objc2-foundation 0.2.2", ] -[[package]] -name = "oboe" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8b61bebd49e5d43f5f8cc7ee2891c16e0f41ec7954d36bcb6c14c5e0de867fb" -dependencies = [ - "jni", - "ndk 0.8.0", - "ndk-context", - "num-derive", - "num-traits", - "oboe-sys", -] - -[[package]] -name = "oboe-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8bb09a4a2b1d668170cfe0a7d5bc103f8999fb316c98099b6a9939c9f2e79d" -dependencies = [ - "cc", -] - [[package]] name = "offset-allocator" version = "0.2.0" @@ -4152,15 +3550,6 @@ dependencies = [ "nonmax", ] -[[package]] -name = "ogg" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6951b4e8bf21c8193da321bcce9c9dd2e13c858fe078bf9054a288b419ae5d6e" -dependencies = [ - "byteorder", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -4247,19 +3636,6 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "petgraph" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" -dependencies = [ - "fixedbitset", - "hashbrown 0.15.5", - "indexmap", - "serde", - "serde_derive", -] - [[package]] name = "pin-project" version = "1.1.10" @@ -4656,7 +4032,7 @@ dependencies = [ "built", "cfg-if", "interpolate_name", - "itertools 0.14.0", + "itertools", "libc", "libfuzzer-sys", "log", @@ -4792,16 +4168,6 @@ version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6a884d2998352bb4daf0183589aec883f16a6da1f4dde84d8e2e9a5409a1ce" -[[package]] -name = "rodio" -version = "0.20.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ceb6607dd738c99bc8cb28eff249b7cd5c8ec88b9db96c0608c1480d140fb1" -dependencies = [ - "cpal", - "lewton", -] - [[package]] name = "ron" version = "0.12.0" @@ -4828,12 +4194,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc-hash" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" - [[package]] name = "rustc_version" version = "0.4.1" @@ -4875,15 +4235,6 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" -[[package]] -name = "ruzstd" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ff0cc5e135c8870a775d3320910cd9b564ec036b4dc0b8741629020be63f01" -dependencies = [ - "twox-hash", -] - [[package]] name = "ryu" version = "1.0.20" @@ -5177,20 +4528,6 @@ dependencies = [ "libc", ] -[[package]] -name = "sysinfo" -version = "0.37.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f" -dependencies = [ - "libc", - "memchr", - "ntapi", - "objc2-core-foundation", - "objc2-io-kit", - "windows 0.61.3", -] - [[package]] name = "taffy" version = "0.9.2" @@ -5478,12 +4815,6 @@ dependencies = [ "core_maths", ] -[[package]] -name = "twox-hash" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" - [[package]] name = "typeid" version = "1.0.3" @@ -5590,12 +4921,6 @@ dependencies = [ "syn", ] -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.5" @@ -5862,11 +5187,10 @@ dependencies = [ "portable-atomic", "profiling", "raw-window-handle", - "rustc-hash 1.1.0", + "rustc-hash", "smallvec", "thiserror 2.0.17", "wgpu-core-deps-apple", - "wgpu-core-deps-wasm", "wgpu-core-deps-windows-linux-android", "wgpu-hal", "wgpu-types", @@ -5881,15 +5205,6 @@ dependencies = [ "wgpu-hal", ] -[[package]] -name = "wgpu-core-deps-wasm" -version = "26.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03b9f9e1a50686d315fc6debe4980cc45cd37b0e919351917df494e8fdc8885" -dependencies = [ - "wgpu-hal", -] - [[package]] name = "wgpu-core-deps-windows-linux-android" version = "26.0.0" @@ -5915,20 +5230,15 @@ dependencies = [ "cfg-if", "cfg_aliases", "core-graphics-types 0.2.0", - "glow", - "glutin_wgl_sys", "gpu-alloc", "gpu-allocator", "gpu-descriptor", "hashbrown 0.15.5", - "js-sys", - "khronos-egl", "libc", "libloading", "log", "metal", "naga", - "ndk-sys 0.6.0+11769913", "objc", "ordered-float", "parking_lot", @@ -5940,8 +5250,6 @@ dependencies = [ "renderdoc-sys", "smallvec", "thiserror 2.0.17", - "wasm-bindgen", - "web-sys", "wgpu-types", "windows 0.58.0", "windows-core 0.58.0", @@ -5993,16 +5301,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49" -dependencies = [ - "windows-core 0.54.0", - "windows-targets 0.52.6", -] - [[package]] name = "windows" version = "0.58.0" @@ -6019,23 +5317,11 @@ version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-collections 0.2.0", + "windows-collections", "windows-core 0.61.2", - "windows-future 0.2.1", + "windows-future", "windows-link 0.1.3", - "windows-numerics 0.2.0", -] - -[[package]] -name = "windows" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" -dependencies = [ - "windows-collections 0.3.2", - "windows-core 0.62.2", - "windows-future 0.3.2", - "windows-numerics 0.3.1", + "windows-numerics", ] [[package]] @@ -6047,25 +5333,6 @@ dependencies = [ "windows-core 0.61.2", ] -[[package]] -name = "windows-collections" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" -dependencies = [ - "windows-core 0.62.2", -] - -[[package]] -name = "windows-core" -version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65" -dependencies = [ - "windows-result 0.1.2", - "windows-targets 0.52.6", -] - [[package]] name = "windows-core" version = "0.58.0" @@ -6092,19 +5359,6 @@ dependencies = [ "windows-strings 0.4.2", ] -[[package]] -name = "windows-core" -version = "0.62.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" -dependencies = [ - "windows-implement 0.60.2", - "windows-interface 0.59.3", - "windows-link 0.2.1", - "windows-result 0.4.1", - "windows-strings 0.5.1", -] - [[package]] name = "windows-future" version = "0.2.1" @@ -6113,18 +5367,7 @@ checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ "windows-core 0.61.2", "windows-link 0.1.3", - "windows-threading 0.1.0", -] - -[[package]] -name = "windows-future" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" -dependencies = [ - "windows-core 0.62.2", - "windows-link 0.2.1", - "windows-threading 0.2.1", + "windows-threading", ] [[package]] @@ -6193,25 +5436,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-numerics" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" -dependencies = [ - "windows-core 0.62.2", - "windows-link 0.2.1", -] - -[[package]] -name = "windows-result" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" -dependencies = [ - "windows-targets 0.52.6", -] - [[package]] name = "windows-result" version = "0.2.0" @@ -6230,15 +5454,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-result" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" -dependencies = [ - "windows-link 0.2.1", -] - [[package]] name = "windows-strings" version = "0.1.0" @@ -6258,15 +5473,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-strings" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" -dependencies = [ - "windows-link 0.2.1", -] - [[package]] name = "windows-sys" version = "0.45.0" @@ -6343,15 +5549,6 @@ dependencies = [ "windows-link 0.1.3", ] -[[package]] -name = "windows-threading" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" -dependencies = [ - "windows-link 0.2.1", -] - [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" @@ -6464,7 +5661,7 @@ dependencies = [ "js-sys", "libc", "memmap2", - "ndk 0.9.0", + "ndk", "objc2 0.5.2", "objc2-app-kit 0.2.2", "objc2-foundation 0.2.2", @@ -6566,12 +5763,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" -[[package]] -name = "xml-rs" -version = "0.8.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ae8337f8a065cfc972643663ea4279e04e7256de865aa66fe25cec5fb912d3f" - [[package]] name = "y4m" version = "0.8.0" diff --git a/Cargo.toml b/Cargo.toml index 0331c5f..07cec72 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,11 @@ autoexamples = false [lints] workspace = true +[features] +default = ["wayland"] +wayland = ["processing_render/wayland"] +x11 = ["processing_render/x11"] + [workspace] resolver = "3" members = ["crates/*"] @@ -16,9 +21,13 @@ type_complexity = "allow" too_many_arguments = "allow" [workspace.dependencies] -bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", no-default-features = true, features = [ +bevy = { git = "https://github.com/bevyengine/bevy", branch = "main", default-features = false, features = [ "bevy_render", "bevy_color", + "bevy_pbr", + "bevy_log", + "bevy_window", + "bevy_winit", ] } processing = { path = "." } processing_pyo3 = { path = "crates/processing_pyo3" } diff --git a/crates/processing_ffi/Cargo.toml b/crates/processing_ffi/Cargo.toml index a08e38b..645eb2c 100644 --- a/crates/processing_ffi/Cargo.toml +++ b/crates/processing_ffi/Cargo.toml @@ -10,6 +10,11 @@ workspace = true name = "processing" crate-type = ["cdylib"] +[features] +default = [] +wayland = ["processing/wayland"] +x11 = ["processing/x11"] + [dependencies] processing = { workspace = true } bevy = { workspace = true } diff --git a/crates/processing_ffi/src/lib.rs b/crates/processing_ffi/src/lib.rs index 977cdc5..23f2f03 100644 --- a/crates/processing_ffi/src/lib.rs +++ b/crates/processing_ffi/src/lib.rs @@ -20,16 +20,82 @@ pub extern "C" fn processing_init() { error::check(init); } -/// Create a WebGPU surface from a native window handle. -/// Returns a window ID (entity ID) that should be used for subsequent operations. -/// Returns 0 on failure. +/// Create a WebGPU surface from a macOS NSWindow handle. /// /// SAFETY: /// - Init has been called. -/// - window_handle is a valid GLFW window pointer. +/// - window_handle is a valid NSWindow pointer. /// - This is called from the same thread as init. +#[cfg(target_os = "macos")] #[unsafe(no_mangle)] pub extern "C" fn processing_surface_create( + window_handle: u64, + _display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> u64 { + error::clear_error(); + error::check(|| surface_create_macos(window_handle, width, height, scale_factor)) + .map(|e| e.to_bits()) + .unwrap_or(0) +} + +/// Create a WebGPU surface from a Windows HWND handle. +/// +/// SAFETY: +/// - Init has been called. +/// - window_handle is a valid HWND. +/// - This is called from the same thread as init. +#[cfg(target_os = "windows")] +#[unsafe(no_mangle)] +pub extern "C" fn processing_surface_create( + window_handle: u64, + _display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> u64 { + error::clear_error(); + error::check(|| surface_create_windows(window_handle, width, height, scale_factor)) + .map(|e| e.to_bits()) + .unwrap_or(0) +} + +/// Create a WebGPU surface from a Wayland window and display handle. +/// +/// SAFETY: +/// - Init has been called. +/// - window_handle is a valid wl_surface pointer. +/// - display_handle is a valid wl_display pointer. +/// - This is called from the same thread as init. +#[cfg(all(target_os = "linux", feature = "wayland"))] +#[unsafe(no_mangle)] +pub extern "C" fn processing_surface_create_wayland( + window_handle: u64, + display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> u64 { + error::clear_error(); + error::check(|| { + surface_create_wayland(window_handle, display_handle, width, height, scale_factor) + }) + .map(|e| e.to_bits()) + .unwrap_or(0) +} + +/// Create a WebGPU surface from an X11 window and display handle. +/// +/// SAFETY: +/// - Init has been called. +/// - window_handle is a valid X11 Window ID. +/// - display_handle is a valid X11 Display pointer. +/// - This is called from the same thread as init. +#[cfg(all(target_os = "linux", feature = "x11"))] +#[unsafe(no_mangle)] +pub extern "C" fn processing_surface_create_x11( window_handle: u64, display_handle: u64, width: u32, @@ -37,7 +103,7 @@ pub extern "C" fn processing_surface_create( scale_factor: f32, ) -> u64 { error::clear_error(); - error::check(|| surface_create(window_handle, display_handle, width, height, scale_factor)) + error::check(|| surface_create_x11(window_handle, display_handle, width, height, scale_factor)) .map(|e| e.to_bits()) .unwrap_or(0) } diff --git a/crates/processing_pyo3/Cargo.toml b/crates/processing_pyo3/Cargo.toml index 1f83db5..b1ee530 100644 --- a/crates/processing_pyo3/Cargo.toml +++ b/crates/processing_pyo3/Cargo.toml @@ -10,6 +10,11 @@ workspace = true name = "processing" crate-type = ["cdylib"] +[features] +default = [] +wayland = ["processing/wayland", "glfw/wayland"] +x11 = ["processing/x11"] + [dependencies] pyo3 = "0.27.0" processing = { workspace = true } @@ -18,6 +23,3 @@ glfw = { version = "0.60.0"} [target.'cfg(target_os = "macos")'.dependencies] glfw = { version = "0.60.0", features = ["static-link"] } - -[target.'cfg(target_os = "linux")'.dependencies] -glfw = { version = "0.60.0", features = ["wayland"] } diff --git a/crates/processing_pyo3/src/glfw.rs b/crates/processing_pyo3/src/glfw.rs index 3c4363b..ef6adbd 100644 --- a/crates/processing_pyo3/src/glfw.rs +++ b/crates/processing_pyo3/src/glfw.rs @@ -1,4 +1,5 @@ /// Minimal GLFW helper for Processing examples +use bevy::prelude::Entity; use glfw::{Glfw, GlfwReceiver, PWindow, WindowEvent, WindowMode}; use processing::prelude::error::Result; @@ -30,28 +31,39 @@ impl GlfwContext { } #[cfg(target_os = "macos")] - pub fn get_window(&self) -> u64 { - self.window.get_cocoa_window() as u64 + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing::prelude::surface_create_macos; + surface_create_macos(self.window.get_cocoa_window() as u64, width, height, scale_factor) } #[cfg(target_os = "windows")] - pub fn get_window(&self) -> u64 { - self.window.get_win32_window() as u64 + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing::prelude::surface_create_windows; + surface_create_windows(self.window.get_win32_window() as u64, width, height, scale_factor) } - #[cfg(target_os = "linux")] - pub fn get_window(&self) -> u64 { - self.window.get_wayland_window() as u64 + #[cfg(all(target_os = "linux", feature = "wayland"))] + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing::prelude::surface_create_wayland; + surface_create_wayland( + self.window.get_wayland_window() as u64, + self.glfw.get_wayland_display() as u64, + width, + height, + scale_factor, + ) } - #[cfg(not(target_os = "linux"))] - pub fn get_display(&self) -> u64 { - 0 - } - - #[cfg(target_os = "linux")] - pub fn get_display(&self) -> u64 { - self.glfw.get_wayland_display() as u64 + #[cfg(all(target_os = "linux", feature = "x11"))] + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing::prelude::surface_create_x11; + surface_create_x11( + self.window.get_x11_window() as u64, + self.glfw.get_x11_display() as u64, + width, + height, + scale_factor, + ) } pub fn poll_events(&mut self) -> bool { diff --git a/crates/processing_pyo3/src/graphics.rs b/crates/processing_pyo3/src/graphics.rs index 55e0479..b511237 100644 --- a/crates/processing_pyo3/src/graphics.rs +++ b/crates/processing_pyo3/src/graphics.rs @@ -44,9 +44,8 @@ impl Graphics { init().map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; - let window_handle = glfw_ctx.get_window(); - let display_handle = glfw_ctx.get_display(); - let surface = surface_create(window_handle, display_handle, width, height, 1.0) + let surface = glfw_ctx + .create_surface(width, height, 1.0) .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?; let surface = Surface { diff --git a/crates/processing_render/Cargo.toml b/crates/processing_render/Cargo.toml index fd56f6a..72272e3 100644 --- a/crates/processing_render/Cargo.toml +++ b/crates/processing_render/Cargo.toml @@ -6,6 +6,11 @@ edition = "2024" [lints] workspace = true +[features] +default = [] +wayland = ["bevy/wayland"] +x11 = ["bevy/x11"] + [dependencies] bevy = { workspace = true } lyon = "1.0" diff --git a/crates/processing_render/src/lib.rs b/crates/processing_render/src/lib.rs index 330e8be..32a1d06 100644 --- a/crates/processing_render/src/lib.rs +++ b/crates/processing_render/src/lib.rs @@ -42,12 +42,35 @@ fn app_mut(cb: impl FnOnce(&mut App) -> error::Result) -> error::Result Ok(res) } -/// Create a WebGPU surface from a native window handle. -/// -/// Currently, this just creates a bevy window with the given parameters and -/// stores the raw window handle for later use by the renderer, which will -/// actually create the surface. -pub fn surface_create( +/// Create a WebGPU surface from a macOS NSWindow handle. +#[cfg(target_os = "macos")] +pub fn surface_create_macos( + window_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> error::Result { + app_mut(|app| { + surface::create_surface_macos(app.world_mut(), window_handle, width, height, scale_factor) + }) +} + +/// Create a WebGPU surface from a Windows HWND handle. +#[cfg(target_os = "windows")] +pub fn surface_create_windows( + window_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> error::Result { + app_mut(|app| { + surface::create_surface_windows(app.world_mut(), window_handle, width, height, scale_factor) + }) +} + +/// Create a WebGPU surface from a Wayland window and display handle. +#[cfg(all(target_os = "linux", feature = "wayland"))] +pub fn surface_create_wayland( window_handle: u64, display_handle: u64, width: u32, @@ -55,7 +78,7 @@ pub fn surface_create( scale_factor: f32, ) -> error::Result { app_mut(|app| { - surface::create( + surface::create_surface_wayland( app.world_mut(), window_handle, display_handle, @@ -66,6 +89,40 @@ pub fn surface_create( }) } +/// Create a WebGPU surface from an X11 window and display handle. +#[cfg(all(target_os = "linux", feature = "x11"))] +pub fn surface_create_x11( + window_handle: u64, + display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> error::Result { + app_mut(|app| { + surface::create_surface_x11( + app.world_mut(), + window_handle, + display_handle, + width, + height, + scale_factor, + ) + }) +} + +/// Create a WebGPU surface from a web canvas element pointer. +#[cfg(target_arch = "wasm32")] +pub fn surface_create_web( + window_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> error::Result { + app_mut(|app| { + surface::create_surface_web(app.world_mut(), window_handle, width, height, scale_factor) + }) +} + pub fn surface_create_offscreen( width: u32, height: u32, @@ -106,7 +163,7 @@ pub fn surface_create_from_canvas( // TODO: not sure if this is right to force here let scale_factor = 1.0; - surface_create(canvas_ptr, 0, width, height, scale_factor) + surface_create_web(canvas_ptr, width, height, scale_factor) } pub fn surface_destroy(graphics_entity: Entity) -> error::Result<()> { @@ -124,9 +181,8 @@ fn create_app() -> App { #[cfg(not(target_arch = "wasm32"))] let plugins = DefaultPlugins .build() - .disable::() .disable::() - .disable::() + .disable::() .set(WindowPlugin { primary_window: None, exit_condition: bevy::window::ExitCondition::DontExit, @@ -136,9 +192,8 @@ fn create_app() -> App { #[cfg(target_arch = "wasm32")] let plugins = DefaultPlugins .build() - .disable::() .disable::() - .disable::() + .disable::() .set(WindowPlugin { primary_window: None, exit_condition: bevy::window::ExitCondition::DontExit, diff --git a/crates/processing_render/src/surface.rs b/crates/processing_render/src/surface.rs index 64cdc66..ae5de56 100644 --- a/crates/processing_render/src/surface.rs +++ b/crates/processing_render/src/surface.rs @@ -6,6 +6,17 @@ //! //! In Bevy, we can consider a surface to be a [`RenderTarget`], which is either a window or a //! texture. +//! +//! ## Platform-specific surface creation +//! +//! On Linux, both X11 and Wayland are supported via feature flags: +//! - `x11`: Enable X11 surface creation via `create_surface_x11` +//! - `wayland`: Enable Wayland surface creation via `create_surface_wayland` +//! +//! On other platforms, use the platform-specific functions: +//! - macOS: `create_surface_macos` +//! - Windows: `create_surface_windows` +//! - WebAssembly: `create_surface_web` #[cfg(any(target_os = "linux", target_arch = "wasm32"))] use std::ffi::c_void; use std::ptr::NonNull; @@ -69,167 +80,268 @@ impl HasDisplayHandle for GlfwWindow { } } -/// Create a WebGPU surface from a native window handle. +/// Helper to spawn a surface entity from raw handles. +fn spawn_surface( + commands: &mut Commands, + raw_window_handle: RawWindowHandle, + raw_display_handle: RawDisplayHandle, + width: u32, + height: u32, + scale_factor: f32, +) -> Result { + let glfw_window = GlfwWindow { + window_handle: raw_window_handle, + display_handle: raw_display_handle, + }; + + let window_wrapper = WindowWrapper::new(glfw_window); + let handle_wrapper = RawHandleWrapper::new(&window_wrapper)?; + + Ok(commands + .spawn(( + Window { + resolution: WindowResolution::new(width, height) + .with_scale_factor_override(scale_factor), + ..default() + }, + handle_wrapper, + Surface, + )) + .id()) +} + +/// Create a WebGPU surface from a macOS NSWindow handle. /// -/// Currently, this just creates a bevy window with the given parameters and -/// stores the raw window handle for later use by the renderer, which will -/// actually create the surface. -pub fn create( +/// # Arguments +/// * `window_handle` - A pointer to the NSWindow (from GLFW's `get_cocoa_window()`) +#[cfg(target_os = "macos")] +pub fn create_surface_macos( world: &mut World, window_handle: u64, - display_handle: u64, width: u32, height: u32, scale_factor: f32, ) -> Result { fn create_inner( - In((window_handle, display_handle, width, height, scale_factor)): In<( - u64, - u64, - u32, - u32, - f32, - )>, + In((window_handle, width, height, scale_factor)): In<(u64, u32, u32, f32)>, mut commands: Commands, ) -> Result { - #[cfg(target_os = "macos")] - let (raw_window_handle, raw_display_handle) = { - use raw_window_handle::{AppKitDisplayHandle, AppKitWindowHandle}; - - // GLFW gives us NSWindow*, but AppKitWindowHandle needs NSView* - // so we have to do some objc magic to grab the right pointer - let ns_view_ptr = { - use objc2::rc::Retained; - use objc2_app_kit::{NSView, NSWindow}; - - // SAFETY: - // - window_handle is a valid NSWindow pointer from the GLFW window - let ns_window = window_handle as *mut NSWindow; - if ns_window.is_null() { - return Err(error::ProcessingError::InvalidWindowHandle); - } + use raw_window_handle::{AppKitDisplayHandle, AppKitWindowHandle}; + + // GLFW gives us NSWindow*, but AppKitWindowHandle needs NSView* + // so we have to do some objc magic to grab the right pointer + let ns_view_ptr = { + use objc2::rc::Retained; + use objc2_app_kit::{NSView, NSWindow}; + + // SAFETY: + // - window_handle is a valid NSWindow pointer from the GLFW window + let ns_window = window_handle as *mut NSWindow; + if ns_window.is_null() { + return Err(error::ProcessingError::InvalidWindowHandle); + } - // SAFETY: - // - The contentView is owned by NSWindow and remains valid as long as the window exists - let ns_window_ref = unsafe { &*ns_window }; - let content_view: Option> = ns_window_ref.contentView(); + // SAFETY: + // - The contentView is owned by NSWindow and remains valid as long as the window exists + let ns_window_ref = unsafe { &*ns_window }; + let content_view: Option> = ns_window_ref.contentView(); - match content_view { - Some(view) => Retained::as_ptr(&view) as *mut std::ffi::c_void, - None => { - return Err(error::ProcessingError::InvalidWindowHandle); - } + match content_view { + Some(view) => Retained::as_ptr(&view) as *mut std::ffi::c_void, + None => { + return Err(error::ProcessingError::InvalidWindowHandle); } - }; - - let window = AppKitWindowHandle::new(NonNull::new(ns_view_ptr).unwrap()); - let display = AppKitDisplayHandle::new(); - ( - RawWindowHandle::AppKit(window), - RawDisplayHandle::AppKit(display), - ) + } }; - #[cfg(target_os = "windows")] - let (raw_window_handle, raw_display_handle) = { - use std::num::NonZeroIsize; + let window = AppKitWindowHandle::new(NonNull::new(ns_view_ptr).unwrap()); + let display = AppKitDisplayHandle::new(); - use raw_window_handle::{Win32WindowHandle, WindowsDisplayHandle}; - use windows::Win32::{Foundation::HINSTANCE, System::LibraryLoader::GetModuleHandleW}; + spawn_surface( + &mut commands, + RawWindowHandle::AppKit(window), + RawDisplayHandle::AppKit(display), + width, + height, + scale_factor, + ) + } - if window_handle == 0 { - return Err(error::ProcessingError::InvalidWindowHandle); - } + world + .run_system_cached_with(create_inner, (window_handle, width, height, scale_factor)) + .unwrap() +} - // HWND is isize, so cast it - let hwnd_isize = window_handle as isize; - let hwnd_nonzero = match NonZeroIsize::new(hwnd_isize) { - Some(nz) => nz, - None => return Err(error::ProcessingError::InvalidWindowHandle), - }; +/// Create a WebGPU surface from a Windows HWND handle. +/// +/// # Arguments +/// * `window_handle` - The HWND value (from GLFW's `get_win32_window()`) +#[cfg(target_os = "windows")] +pub fn create_surface_windows( + world: &mut World, + window_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> Result { + fn create_inner( + In((window_handle, width, height, scale_factor)): In<(u64, u32, u32, f32)>, + mut commands: Commands, + ) -> Result { + use std::num::NonZeroIsize; - let mut window = Win32WindowHandle::new(hwnd_nonzero); + use raw_window_handle::{Win32WindowHandle, WindowsDisplayHandle}; + use windows::Win32::System::LibraryLoader::GetModuleHandleW; - // VK_KHR_win32_surface requires hinstance *and* hwnd - // SAFETY: GetModuleHandleW(NULL) is safe - let hinstance = unsafe { GetModuleHandleW(None) } - .map_err(|_| error::ProcessingError::InvalidWindowHandle)?; + if window_handle == 0 { + return Err(error::ProcessingError::InvalidWindowHandle); + } - let hinstance_nonzero = NonZeroIsize::new(hinstance.0 as isize) - .ok_or(error::ProcessingError::InvalidWindowHandle)?; - window.hinstance = Some(hinstance_nonzero); + // HWND is isize, so cast it + let hwnd_isize = window_handle as isize; + let hwnd_nonzero = match NonZeroIsize::new(hwnd_isize) { + Some(nz) => nz, + None => return Err(error::ProcessingError::InvalidWindowHandle), + }; - let display = WindowsDisplayHandle::new(); + let mut window = Win32WindowHandle::new(hwnd_nonzero); - ( - RawWindowHandle::Win32(window), - RawDisplayHandle::Windows(display), - ) - }; + // VK_KHR_win32_surface requires hinstance *and* hwnd + // SAFETY: GetModuleHandleW(NULL) is safe + let hinstance = unsafe { GetModuleHandleW(None) } + .map_err(|_| error::ProcessingError::InvalidWindowHandle)?; - #[cfg(target_os = "linux")] - let (raw_window_handle, raw_display_handle) = { - use raw_window_handle::{WaylandDisplayHandle, WaylandWindowHandle}; + let hinstance_nonzero = NonZeroIsize::new(hinstance.0 as isize) + .ok_or(error::ProcessingError::InvalidWindowHandle)?; + window.hinstance = Some(hinstance_nonzero); - if window_handle == 0 { - return Err(error::ProcessingError::HandleError( - HandleError::Unavailable, - )); - } - let window_handle_ptr = NonNull::new(window_handle as *mut c_void).unwrap(); - let window = WaylandWindowHandle::new(window_handle_ptr); + let display = WindowsDisplayHandle::new(); - if display_handle == 0 { - return Err(error::ProcessingError::HandleError( - HandleError::Unavailable, - )); - } - let display_handle_ptr = NonNull::new(display_handle as *mut c_void).unwrap(); - let display = WaylandDisplayHandle::new(display_handle_ptr); + spawn_surface( + &mut commands, + RawWindowHandle::Win32(window), + RawDisplayHandle::Windows(display), + width, + height, + scale_factor, + ) + } - ( - RawWindowHandle::Wayland(window), - RawDisplayHandle::Wayland(display), - ) - }; + world + .run_system_cached_with(create_inner, (window_handle, width, height, scale_factor)) + .unwrap() +} - #[cfg(target_arch = "wasm32")] - let (raw_window_handle, raw_display_handle) = { - use raw_window_handle::{WebCanvasWindowHandle, WebDisplayHandle}; +/// Create a WebGPU surface from a Wayland window and display handle. +/// +/// # Arguments +/// * `window_handle` - The wl_surface pointer (from GLFW's `get_wayland_window()`) +/// * `display_handle` - The wl_display pointer (from GLFW's `get_wayland_display()`) +#[cfg(all(target_os = "linux", feature = "wayland"))] +pub fn create_surface_wayland( + world: &mut World, + window_handle: u64, + display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> Result { + fn create_inner( + In((window_handle, display_handle, width, height, scale_factor)): In<( + u64, + u64, + u32, + u32, + f32, + )>, + mut commands: Commands, + ) -> Result { + use raw_window_handle::{WaylandDisplayHandle, WaylandWindowHandle}; - // For WASM, window_handle is a pointer to an HtmlCanvasElement - if window_handle == 0 { - return Err(error::ProcessingError::InvalidWindowHandle); - } - let canvas_ptr = NonNull::new(window_handle as *mut c_void).unwrap(); - let window = WebCanvasWindowHandle::new(canvas_ptr.cast()); - let display = WebDisplayHandle::new(); - - ( - RawWindowHandle::WebCanvas(window), - RawDisplayHandle::Web(display), - ) - }; + if window_handle == 0 { + return Err(error::ProcessingError::HandleError( + HandleError::Unavailable, + )); + } + let window_handle_ptr = NonNull::new(window_handle as *mut c_void).unwrap(); + let window = WaylandWindowHandle::new(window_handle_ptr); - let glfw_window = GlfwWindow { - window_handle: raw_window_handle, - display_handle: raw_display_handle, - }; + if display_handle == 0 { + return Err(error::ProcessingError::HandleError( + HandleError::Unavailable, + )); + } + let display_handle_ptr = NonNull::new(display_handle as *mut c_void).unwrap(); + let display = WaylandDisplayHandle::new(display_handle_ptr); + + spawn_surface( + &mut commands, + RawWindowHandle::Wayland(window), + RawDisplayHandle::Wayland(display), + width, + height, + scale_factor, + ) + } + + world + .run_system_cached_with( + create_inner, + (window_handle, display_handle, width, height, scale_factor), + ) + .unwrap() +} + +/// Create a WebGPU surface from an X11 window and display handle. +/// +/// # Arguments +/// * `window_handle` - The X11 Window ID (from GLFW's `get_x11_window()`) +/// * `display_handle` - The X11 Display pointer (from GLFW's `get_x11_display()`) +#[cfg(all(target_os = "linux", feature = "x11"))] +pub fn create_surface_x11( + world: &mut World, + window_handle: u64, + display_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> Result { + fn create_inner( + In((window_handle, display_handle, width, height, scale_factor)): In<( + u64, + u64, + u32, + u32, + f32, + )>, + mut commands: Commands, + ) -> Result { + use raw_window_handle::{XlibDisplayHandle, XlibWindowHandle}; + + if window_handle == 0 { + return Err(error::ProcessingError::HandleError( + HandleError::Unavailable, + )); + } + // X11 Window is a u32/u64 ID, not a pointer + let window = XlibWindowHandle::new(window_handle as std::ffi::c_ulong); - let window_wrapper = WindowWrapper::new(glfw_window); - let handle_wrapper = RawHandleWrapper::new(&window_wrapper)?; - - Ok(commands - .spawn(( - Window { - resolution: WindowResolution::new(width, height) - .with_scale_factor_override(scale_factor), - ..default() - }, - handle_wrapper, - Surface, - )) - .id()) + if display_handle == 0 { + return Err(error::ProcessingError::HandleError( + HandleError::Unavailable, + )); + } + let display_ptr = NonNull::new(display_handle as *mut c_void).unwrap(); + let display = XlibDisplayHandle::new(Some(display_ptr), 0); // screen 0 + + spawn_surface( + &mut commands, + RawWindowHandle::Xlib(window), + RawDisplayHandle::Xlib(display), + width, + height, + scale_factor, + ) } world @@ -240,6 +352,47 @@ pub fn create( .unwrap() } +/// Create a WebGPU surface from a web canvas element. +/// +/// # Arguments +/// * `window_handle` - A pointer to the HtmlCanvasElement +#[cfg(target_arch = "wasm32")] +pub fn create_surface_web( + world: &mut World, + window_handle: u64, + width: u32, + height: u32, + scale_factor: f32, +) -> Result { + fn create_inner( + In((window_handle, width, height, scale_factor)): In<(u64, u32, u32, f32)>, + mut commands: Commands, + ) -> Result { + use raw_window_handle::{WebCanvasWindowHandle, WebDisplayHandle}; + + // For WASM, window_handle is a pointer to an HtmlCanvasElement + if window_handle == 0 { + return Err(error::ProcessingError::InvalidWindowHandle); + } + let canvas_ptr = NonNull::new(window_handle as *mut c_void).unwrap(); + let window = WebCanvasWindowHandle::new(canvas_ptr.cast()); + let display = WebDisplayHandle::new(); + + spawn_surface( + &mut commands, + RawWindowHandle::WebCanvas(window), + RawDisplayHandle::Web(display), + width, + height, + scale_factor, + ) + } + + world + .run_system_cached_with(create_inner, (window_handle, width, height, scale_factor)) + .unwrap() +} + pub fn create_offscreen( world: &mut World, width: u32, diff --git a/examples/background_image.rs b/examples/background_image.rs index 10ed951..2f98eb6 100644 --- a/examples/background_image.rs +++ b/examples/background_image.rs @@ -25,9 +25,7 @@ fn sketch() -> error::Result<()> { let height = 400; let scale_factor = 1.0; - let window_handle = glfw_ctx.get_window(); - let display_handle = glfw_ctx.get_display(); - let surface = surface_create(window_handle, display_handle, width, height, scale_factor)?; + let surface = glfw_ctx.create_surface(width, height, scale_factor)?; let graphics = graphics_create(surface, width, height)?; let image = image_load("images/logo.png")?; diff --git a/examples/glfw.rs b/examples/glfw.rs index 5012300..958bcaf 100644 --- a/examples/glfw.rs +++ b/examples/glfw.rs @@ -1,4 +1,5 @@ /// Minimal GLFW helper for Processing examples +use bevy::prelude::Entity; use glfw::{Glfw, GlfwReceiver, PWindow, WindowEvent, WindowMode}; use processing_render::error::Result; @@ -30,28 +31,39 @@ impl GlfwContext { } #[cfg(target_os = "macos")] - pub fn get_window(&self) -> u64 { - self.window.get_cocoa_window() as u64 + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing_render::surface_create_macos; + surface_create_macos(self.window.get_cocoa_window() as u64, width, height, scale_factor) } #[cfg(target_os = "windows")] - pub fn get_window(&self) -> u64 { - self.window.get_win32_window() as u64 + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing_render::surface_create_windows; + surface_create_windows(self.window.get_win32_window() as u64, width, height, scale_factor) } - #[cfg(target_os = "linux")] - pub fn get_window(&self) -> u64 { - self.window.get_wayland_window() as u64 + #[cfg(all(target_os = "linux", feature = "wayland"))] + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing_render::surface_create_wayland; + surface_create_wayland( + self.window.get_wayland_window() as u64, + self.glfw.get_wayland_display() as u64, + width, + height, + scale_factor, + ) } - #[cfg(not(target_os = "linux"))] - pub fn get_display(&self) -> u64 { - 0 - } - - #[cfg(target_os = "linux")] - pub fn get_display(&self) -> u64 { - self.glfw.get_wayland_display() as u64 + #[cfg(all(target_os = "linux", feature = "x11"))] + pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { + use processing_render::surface_create_x11; + surface_create_x11( + self.window.get_x11_window() as u64, + self.glfw.get_x11_display() as u64, + width, + height, + scale_factor, + ) } pub fn poll_events(&mut self) -> bool { diff --git a/examples/rectangle.rs b/examples/rectangle.rs index 6e60e16..9e372e1 100644 --- a/examples/rectangle.rs +++ b/examples/rectangle.rs @@ -25,9 +25,7 @@ fn sketch() -> error::Result<()> { let height = 400; let scale_factor = 1.0; - let window_handle = glfw_ctx.get_window(); - let display_handle = glfw_ctx.get_display(); - let surface = surface_create(window_handle, display_handle, width, height, scale_factor)?; + let surface = glfw_ctx.create_surface(width, height, scale_factor)?; let graphics = graphics_create(surface, width, height)?; while glfw_ctx.poll_events() { diff --git a/examples/update_pixels.rs b/examples/update_pixels.rs index 287d6b8..60c7de9 100644 --- a/examples/update_pixels.rs +++ b/examples/update_pixels.rs @@ -25,9 +25,7 @@ fn sketch() -> error::Result<()> { let height = 100; let scale_factor = 1.0; - let window_handle = glfw_ctx.get_window(); - let display_handle = glfw_ctx.get_display(); - let surface = surface_create(window_handle, display_handle, width, height, scale_factor)?; + let surface = glfw_ctx.create_surface(width, height, scale_factor)?; let graphics = graphics_create(surface, width, height)?; let rect_w = 10; From 13eb28380b232133bb9b2a5b41a8464f69cf0527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charlotte=20=F0=9F=8C=B8?= Date: Sat, 13 Dec 2025 15:42:40 -0800 Subject: [PATCH 2/4] Wayland on pyo3. --- crates/processing_pyo3/Cargo.toml | 2 +- crates/processing_pyo3/src/glfw.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/processing_pyo3/Cargo.toml b/crates/processing_pyo3/Cargo.toml index b1ee530..4e0acb7 100644 --- a/crates/processing_pyo3/Cargo.toml +++ b/crates/processing_pyo3/Cargo.toml @@ -11,7 +11,7 @@ name = "processing" crate-type = ["cdylib"] [features] -default = [] +default = ["wayland"] wayland = ["processing/wayland", "glfw/wayland"] x11 = ["processing/x11"] diff --git a/crates/processing_pyo3/src/glfw.rs b/crates/processing_pyo3/src/glfw.rs index ef6adbd..b926623 100644 --- a/crates/processing_pyo3/src/glfw.rs +++ b/crates/processing_pyo3/src/glfw.rs @@ -1,5 +1,4 @@ /// Minimal GLFW helper for Processing examples -use bevy::prelude::Entity; use glfw::{Glfw, GlfwReceiver, PWindow, WindowEvent, WindowMode}; use processing::prelude::error::Result; From b59c855379123cb1464b6b1ac19708b60037b5ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charlotte=20=F0=9F=8C=B8?= Date: Sat, 13 Dec 2025 15:44:45 -0800 Subject: [PATCH 3/4] Fmt. --- crates/processing_pyo3/src/glfw.rs | 14 ++++++++++++-- examples/glfw.rs | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/crates/processing_pyo3/src/glfw.rs b/crates/processing_pyo3/src/glfw.rs index b926623..f23ebb1 100644 --- a/crates/processing_pyo3/src/glfw.rs +++ b/crates/processing_pyo3/src/glfw.rs @@ -32,13 +32,23 @@ impl GlfwContext { #[cfg(target_os = "macos")] pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { use processing::prelude::surface_create_macos; - surface_create_macos(self.window.get_cocoa_window() as u64, width, height, scale_factor) + surface_create_macos( + self.window.get_cocoa_window() as u64, + width, + height, + scale_factor, + ) } #[cfg(target_os = "windows")] pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { use processing::prelude::surface_create_windows; - surface_create_windows(self.window.get_win32_window() as u64, width, height, scale_factor) + surface_create_windows( + self.window.get_win32_window() as u64, + width, + height, + scale_factor, + ) } #[cfg(all(target_os = "linux", feature = "wayland"))] diff --git a/examples/glfw.rs b/examples/glfw.rs index 958bcaf..366640e 100644 --- a/examples/glfw.rs +++ b/examples/glfw.rs @@ -33,13 +33,23 @@ impl GlfwContext { #[cfg(target_os = "macos")] pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { use processing_render::surface_create_macos; - surface_create_macos(self.window.get_cocoa_window() as u64, width, height, scale_factor) + surface_create_macos( + self.window.get_cocoa_window() as u64, + width, + height, + scale_factor, + ) } #[cfg(target_os = "windows")] pub fn create_surface(&self, width: u32, height: u32, scale_factor: f32) -> Result { use processing_render::surface_create_windows; - surface_create_windows(self.window.get_win32_window() as u64, width, height, scale_factor) + surface_create_windows( + self.window.get_win32_window() as u64, + width, + height, + scale_factor, + ) } #[cfg(all(target_os = "linux", feature = "wayland"))] From df66f0344c8191f50068e015c30c5c50710b8e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?charlotte=20=F0=9F=8C=B8?= Date: Sat, 13 Dec 2025 15:48:03 -0800 Subject: [PATCH 4/4] Add missing import. --- crates/processing_pyo3/src/glfw.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/processing_pyo3/src/glfw.rs b/crates/processing_pyo3/src/glfw.rs index f23ebb1..7effad0 100644 --- a/crates/processing_pyo3/src/glfw.rs +++ b/crates/processing_pyo3/src/glfw.rs @@ -1,3 +1,4 @@ +use bevy::prelude::Entity; /// Minimal GLFW helper for Processing examples use glfw::{Glfw, GlfwReceiver, PWindow, WindowEvent, WindowMode}; use processing::prelude::error::Result;