{"id":13505331,"url":"https://github.com/jinleili/wgpu-in-app","last_synced_at":"2025-05-15T03:06:06.134Z","repository":{"id":37744745,"uuid":"404980128","full_name":"jinleili/wgpu-in-app","owner":"jinleili","description":"Integrate wgpu into existing iOS | Android apps.","archived":false,"fork":false,"pushed_at":"2025-03-16T03:58:49.000Z","size":23951,"stargazers_count":328,"open_issues_count":5,"forks_count":32,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-14T04:58:55.306Z","etag":null,"topics":["android-app","cargo-plugin","ios-app","rust","visionos","webgpu","wgpu","wgpu-step-by-step","wgpu-tutorial","xros"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinleili.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-09-10T06:33:42.000Z","updated_at":"2025-04-13T15:54:17.000Z","dependencies_parsed_at":"2024-05-02T04:45:24.174Z","dependency_job_id":"3d463461-f2ec-4826-ba89-6cfcede44665","html_url":"https://github.com/jinleili/wgpu-in-app","commit_stats":{"total_commits":116,"total_committers":4,"mean_commits":29.0,"dds":"0.025862068965517238","last_synced_commit":"5626a8059c7b1408f4f0c3006c6fd657fd3956b5"},"previous_names":["jinleili/wgpu-on-app"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinleili%2Fwgpu-in-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinleili%2Fwgpu-in-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinleili%2Fwgpu-in-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinleili%2Fwgpu-in-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinleili","download_url":"https://codeload.github.com/jinleili/wgpu-in-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264765,"owners_count":22041793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-app","cargo-plugin","ios-app","rust","visionos","webgpu","wgpu","wgpu-step-by-step","wgpu-tutorial","xros"],"created_at":"2024-08-01T00:01:02.918Z","updated_at":"2025-05-15T03:06:06.114Z","avatar_url":"https://github.com/jinleili.png","language":"Rust","funding_links":[],"categories":["Prototypes","Uncategorized"],"sub_categories":["Github Repos","Uncategorized"],"readme":"# wgpu in App\n\n![Minimum Rust Version](https://img.shields.io/badge/min%20rust-1.85-green.svg)\n[![Build Status](https://github.com/jinleili/wgpu-in-app/workflows/CI/badge.svg)](https://github.com/jinleili/wgpu-in-app/actions)\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jinleili/wgpu-in-app/blob/master/LICENSE.MIT)\n\nIntegrate wgpu into your existing iOS | Android apps.\n\nwgpu does not depend on any window program, so it does not provide window creation and management functions. Only when creating a window-based `Surface`, an argument that implements the [raw-window-handle](https://github.com/rust-windowing/raw-window-handle) abstract interface may be needed (_may be needed_ because on iOS/macOS, instance of `Surface` can be created directly by `CAMetalLayer`). The `winit` used by the wgpu examples is a cross-platform window creation and management crate that implements the raw-window-handle abstract interface. It will take over the window management and events loop of the entire app, there is no doubt that for game apps, the combination of wgpu + winit is very suitable.\n\nHowever, a large number of non-game apps also need to use graphics APIs (such as charts, image filters, etc.). These apps may require a large number of system components, as well as the ability to freely control various input devices (e.g., stylus, motion sensors). So, it would be very useful to integrate wgpu into these apps without using third-party window management libraries.\n\n#### [中文版文档](https://jinleili.github.io/learn-wgpu-zh/integration-and-debugging/)\n\n## Screenshot\n\n| ![wgpu in iOS](screenshot/on_ios.png) | ![wgpu in Android](screenshot/on_android.png) |\n| ------------------------------------- | --------------------------------------------- |\n\nhttps://github.com/jinleili/wgpu-in-app/assets/1001342/9209b81b-f336-4322-986e-70dd9bb155c3\n\n## **iOS | iPadOS | visionOS**\n\n### Add target\n\n```sh\n# Add Apple device (iOS | iPadOS | visionOS) target\n# Since iPhone 5 and later are all 64-bit devices, `armv7s-apple-ios` and `armv7-apple-ios` are not required.\nrustup target add aarch64-apple-ios\n\n# Add Apple Simulator target\n# M1+ Mac\nrustup target add aarch64-apple-ios-sim\n```\n\n### Build for Apple real device\n\n```sh\n# Build for iOS | iPadOS\nsh ./apple_lib_build.sh --release\n```\n\nThen, Open `Apple/wgpu_in_App.xcodeproj` with Xcode and run on iPhone、iPad.\n\n### Build for visionOS Simulator\n\n```sh\nsh ./apple_lib_build.sh aarch64-apple-ios-sim --release\n```\n\nThen, Open `Apple/wgpu_in_App.xcodeproj` with Xcode 15 Beta 2+ and run on visionOS Simulator.\n\n### About Rust and Swift Interaction\n\n[Passing Primitive Data Between Rust and iOS](https://bignerdranch.com/blog/building-an-ios-app-in-rust-part-2-passing-primitive-data-between-rust-and-ios/)\n\n[Passing Owned Objects between Rust and iOS](https://bignerdranch.com/blog/building-an-ios-app-in-rust-part-3-passing-owned-objects-between-rust-and-ios/)\n\n[Sending a boxed trait over FFI](https://users.rust-lang.org/t/sending-a-boxed-trait-over-ffi/21708)\n\n## **Android**\n\n### Set up Android environment\n\nAssuming your computer already has Android Studio installed, go to `Android Studio` \u003e `Tools` \u003e `SDK Manager` \u003e `Android SDK` \u003e `SDK Tools`. Check the following options for installation and click OK.\n\n- [x] Android SDK Build-Tools\n- [x] Android SDK Command-line Tools\n- [x] NDK(Side by side)\n\nThen, set two following environment variables:\n\n```sh\nexport ANDROID_SDK_ROOT=$HOME/Library/Android/sdk\n# Replace the NDK version number with the version you installed\nexport NDK_HOME=$ANDROID_SDK_ROOT/ndk/23.1.7779620\n```\n\n### Install cargo so subcommand\n\n```sh\n# from crates.io\ncargo install cargo-so\n# frome source code\ncargo install --path cargo-so\n```\n\n### Build\n\n```sh\n# Add build targets\n# Since simulator and virtual devices only support GLES, `x86_64-linux-android` and `i686-linux-android` targets are not necessary\nrustup target add aarch64-linux-android armv7-linux-androideabi\n\n# Build\nsh ./android_lib_build.sh --release\n```\n\n## **Desktop**\n\n```sh\n# Use primary backend (metal vulkan or dx12, depend on your computer OS).\ncargo run\n# Use OpenGL backend (platforms other than Linux, need to add the `angle` feature).\n# https://github.com/gfx-rs/wgpu/pull/2461\nWGPU_BACKEND=gl cargo run --features=angle\n# Use Vulkan backend (on macOS, need to add the `vulkan-portability` feature)\n# https://github.com/gfx-rs/wgpu/pull/2488\nWGPU_BACKEND=vk cargo run --features=vulkan-portability\n# Then, press 0, 1, 2, 3, 4 keys change running example.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinleili%2Fwgpu-in-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinleili%2Fwgpu-in-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinleili%2Fwgpu-in-app/lists"}