Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using SDL_TTF #10

Open
trezm opened this issue Aug 2, 2018 · 2 comments
Open

Using SDL_TTF #10

trezm opened this issue Aug 2, 2018 · 2 comments

Comments

@trezm
Copy link

trezm commented Aug 2, 2018

Hey all! Amazing work done here, honestly!!! I've been looking for a good starting place to write a rust game in SDL2 for my Android phone and I've found it :)

That being said -- I was able to get a good build script working (see below,) but I can't seem to figure out how to include SDL_TTF in the bundle. Does anyone have a good idea of where I could start?

#!/bin/bash

###
#
# $1 is the ndk location
# $2 is the output for platform dependent toolchains
# $3 is the android sdk

export ANDROID_NDK_HOME=$1
export ANDROID_HOME=$3
echo "Building toolchain..."
$1/build/tools/make_standalone_toolchain.py --arch arm --install-dir $2/android-ndk-arm
$1/build/tools/make_standalone_toolchain.py --arch arm64 --install-dir $2/android-ndk-arm64
$1/build/tools/make_standalone_toolchain.py --arch x86 --install-dir $2/android-ndk-x86
$1/build/tools/make_standalone_toolchain.py --arch x86_64 --install-dir $2/android-ndk-x86_64

echo "Configuring..."
echo "
[target.armv7-linux-androideabi]
linker = \"$2/android-ndk-arm/bin/arm-linux-androideabi-gcc\"

[target.aarch64-linux-android]
linker = \"$2/android-ndk-arm64/bin/aarch64-linux-android-gcc\"

[target.i686-linux-android]
linker = \"$2/android-ndk-x86/bin/i686-linux-android-gcc\"

[target.x86_64-linux-android]
linker = \"$2/android-ndk-x86_64/bin/x86_64-linux-android-gcc\"
" > ./.cargo/config

echo "Building Android SDL..."
cd android/Minigame/sdl
../gradlew assemble
cd ../../..

echo "Building Rust Library..."
CC=$2/android-ndk-arm/bin/arm-linux-androideabi-gcc CXX=$2/android-ndk-arm/bin/arm-linux-androideabi-clang++ AR=$2/android-ndk-arm/bin/arm-linux-androideabi-ar cargo build --no-default-features --target armv7-linux-androideabi --lib
CC=$2/android-ndk-arm64/bin/aarch64-linux-android-gcc CXX=$2/android-ndk-arm64/bin/aarch64-linux-android-clang++ AR=$2/android-ndk-arm64/bin/aarch64-linux-android-ar cargo build --no-default-features --target aarch64-linux-android --lib
CC=$2/android-ndk-x86/bin/i686-linux-android-gcc CXX=$2/android-ndk-x86/bin/i686-linux-android-clang++ AR=$2/android-ndk-x86/bin/i686-linux-android-ar cargo build --no-default-features --target i686-linux-android --lib
CC=$2/android-ndk-x86_64/bin/x86_64-linux-android-gcc CXX=$2/android-ndk-x86_64/bin/x86_64-linux-android-clang++ AR=$2/android-ndk-x86_64/bin/x86_64-linux-android-ar cargo build --no-default-features --target x86_64-linux-android --lib

echo "Copying files..."
cp target/armv7-linux-androideabi/debug/libminigame.so android/Minigame/app/src/main/jniLibs/armeabi/
cp target/armv7-linux-androideabi/debug/libminigame.so android/Minigame/app/src/main/jniLibs/armeabi-v7a/
cp target/i686-linux-android/debug/libminigame.so android/Minigame/app/src/main/jniLibs/x86/
cp target/x86_64-linux-android/debug/libminigame.so android/Minigame/app/src/main/jniLibs/x86_64/

cp target/aarch64-linux-android/debug/libminigame.so android/Minigame/app/src/main/jniLibs/arm64-v8a/
cp $2/android-ndk-arm64/aarch64-linux-android/lib/libc++_shared.so android/Minigame/app/src/main/jniLibs/arm64-v8a/

echo "Building android app..."
cd android/Minigame/app
../gradlew assemble
cd ../../..
@tanis2000
Copy link
Owner

Nice script you've come up with. I might add something similar to this project, too. I'd still need to add the iOS stuff in there as well, but that's pretty easy.

Before venturing into trying to add SDL2_TTF, are you sure you don't want to use https://github.com/redox-os/rusttype instead? I stopped using SDL2_TTF a long time ago and switched to
https://github.com/nothings/stb/blob/master/stb_truetype.h which is also ported to Rust as
https://github.com/dylanede/stb_truetype-rs

@trezm
Copy link
Author

trezm commented Aug 3, 2018

I wasn't aware there were other options really! I'm new to game dev specifically, so I'll give those a shot. Great resources, I'll report back how they work out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants