GithubHelp home page GithubHelp logo

gordon-f / crossplatform_gfx_hal_example Goto Github PK

View Code? Open in Web Editor NEW
46.0 2.0 7.0 105 KB

Gfx-hal quad example running on Windows, Linux, Mac, iOS, Android

License: Apache License 2.0

Shell 0.30% Objective-C 0.25% Rust 97.74% GLSL 1.72%
rust ios gfx gfx-rs android metal vulkan

crossplatform_gfx_hal_example's Introduction

Cross-platform gfx-hal example project

Gfx-hal quad example running on Windows, Linux, Mac, iOS, Android.

Desktop (Windows, Linux, Mac)

cd rust/game_desktop/
cargo run --features target

Where target: mac (Metal), linux (Vulkan), pc_dx12 (DirectX 12) or pc_dx11 (DirectX 11).

iOS (Metal)

  1. Install Rust iOS target: rustup target add aarch64-apple-ios
  2. Install XcodeGen
  3. cd to the ios directory
  4. Run XcodeGen
  5. Open project in Xcode
  6. Run example on device (with metal support)
cd ios/
xcodegen

Android (Vulkan)

  1. Install Rust Android targets: rustup target add armv7-linux-androideabi
  2. Install cargo-apk: cargo install --git https://github.com/rust-windowing/android-rs-glue.git cargo-apk
  3. Install the OpenJDK (1.8)
  4. Install the CMake
  5. Install Android SDK
  6. Install API level 24 support
  7. Install Android NDK 17c (why 17c? see issue)
  8. Install Gradle (4.6)
  9. Set the environment variables JAVA_HOME, NDK_HOME, ANDROID_HOME, GRADLE_HOME.
  10. cd to the rust/game_android directory
  11. Run cargo-apk build
  12. Install Vulkan validation layers:
    1. cd to the project_root/target/android-artifacts directory
    2. cp -fr $NDK_HOME/sources/third_party/vulkan/src/build-android/jniLibs/armeabi-v7a app/src/main/
  13. Run gradle assembleDebug
  14. Run gradle installDebug
  15. Run adb logcat | grep RustAndroidGlueStdouterr
  16. Run example on connected device

crossplatform_gfx_hal_example's People

Contributors

gordon-f avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crossplatform_gfx_hal_example's Issues

Build failed on iOS

I follow your instructions in readme but failed to compile the project on ios. Messages as follow:

Ld /Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Products/Debug-iphoneos/game.app/game normal arm64 (in target 'game' from project 'rust-game')
    cd /Users/hourann/dev/rustProj/crossplatform_gfx_hal_example/ios
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios12.2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk -L/Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Products/Debug-iphoneos -L../target/aarch64-apple-ios/debug -L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS13.2.sdk/usr/lib/swift -F/Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Products/Debug-iphoneos -filelist /Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Intermediates.noindex/rust-game.build/Debug-iphoneos/game.build/Objects-normal/arm64/game.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Intermediates.noindex/rust-game.build/Debug-iphoneos/game.build/Objects-normal/arm64/game_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -lgame_bindings -lswiftMetal -lresolv -framework Metal -lc++ -Xlinker -dependency_info -Xlinker /Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Intermediates.noindex/rust-game.build/Debug-iphoneos/game.build/Objects-normal/arm64/game_dependency_info.dat -o /Users/hourann/Library/Developer/Xcode/DerivedData/rust-game-cpybqcegtojvuxauxbomurqanfwg/Build/Products/Debug-iphoneos/game.app/game

Undefined symbols for architecture arm64:
  "_MTLCopyAllDevices", referenced from:
      metal::device::Device::all::hc2f28b2de4b611e7 in libgame_bindings.a(metal-faab903976c6e7f1.metal.32kvuh4k-cgu.2.rcgu.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I found a similar issue on gfx-rs/metal-rs#103 , which gives a solution by linking with "-framework Metal". I don't know how to do this on XCode. I've tried to add Metal.framework under dependencies in project.yml but it didn't work.

My system version is 10.15.1 and xcode version 11.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.