piston icon indicating copy to clipboard operation
piston copied to clipboard

Android support

Open dobkeratops opened this issue 10 years ago • 12 comments

Interesting; have you considered tablet/phone-friendliness in the framework? ( e.g. android, iOS ) (how do i specify 'discussion' label?)

So far I've been doing cross platform (iOS/android/windows) in C++, with some simple functions that can be called from a platform specific stub (init, update, render) ..but also 'display_init' and 'display_close') for android.

using 'extern "C"' I could just slot Rust code into the same desktop/android framework as my existing C/C++ work.

I haven't attempted to make any "android NDK application stub" in Rust as yet... I also haven't looked into GLFW for android. Perhaps the ambition of this project would be to do a complete back-end on every platform , natively in rust, eventually ..

supposedly rust tries to emit the same name-mangling as C++. however C++ doesn't have a standard for that. extern "C" loses the elegance of either language (rust or c++) but does allow crossover which is nice.

I think it would be pretty interesting to have a simple cross platform 2d library (including some sort of input) designed for mobiles from the ground up.. menus that easily map onto touchscreen/desktop and so on. This is not trivial to design , and you'd have to consider the touchscreen as the "lowest common denominator" really, but add keyboard and mouse buttons as intelligent shortcuts (so many laptops have touch screens now); of course you wouldn't want to compromise the ability to make something that works well on a specific system.

dobkeratops avatar May 20 '14 14:05 dobkeratops

In theory Piston can run on Android/iOS because it use SDL2 as back-end but we haven't do it. One of the goal of Piston is support multi platform including mobile/tablet

coeuvre avatar May 20 '14 14:05 coeuvre

We are try to design the interface to work with different back-ends, to make as much code as possible reusable across projects and platforms.

bvssvni avatar May 20 '14 20:05 bvssvni

https://github.com/dobkeratops/android_rust_gl

for reference here's a minimal rust-android-gl sample, should compile on both android & linux/mac desktop. if there's a cleaner way to do it i'd like to know - (e.g., i haven't looked into glfw on android lately). I'm told android doesn't suit a library where you have your own main loop - you'd have to setup a thread handling the native event loop , passing that to your app to work that way. Doable, just more work, and possibly more to go wrong

dobkeratops avatar May 25 '14 02:05 dobkeratops

Nice! @dobkeratops would you mind open up an issue labeled with "Information" about how to set up an Android emulator? Just adding links would be nice.

bvssvni avatar May 25 '14 09:05 bvssvni

I actually found it easier to run on real hardware than on the emulator - I seem to remember you had a fair amount of config to specify what type of device.. I gave up on that myself . Plenty of second hand devices of nice enough spec around. Actually running on android hardware is ok, the pain is the slightly convoluted build process... thanks to NDK being an afterthought really. I've updated info on the rust wiki (with answers I found on stack overflow) r.e adapting their makefiles.

dobkeratops avatar May 25 '14 15:05 dobkeratops

This is perhaps a bit too far stretch goal to worry about now.

Closing for now.

bvssvni avatar Jun 22 '14 11:06 bvssvni

@bvssvni - Is this viable now? I'm really interested in playing with game dev on mobile with rust.

beatgammit avatar Aug 24 '15 19:08 beatgammit

@beatgammit Yeah, it is time to think about it again. There has been a few experiments but I have not tried it myself.

bvssvni avatar Aug 24 '15 20:08 bvssvni

Any progress on this, I'd love to use this to make a cross-platform Linux/Mac/Android game!

ghost avatar Jul 29 '16 18:07 ghost

Any updates on this please? I'm toying with a game idea and it would be great to be able to run on android/ios. Thanks for wonderful work so far.

opensourcegeek avatar Dec 11 '16 16:12 opensourcegeek

I was able to get an older version of Piston able to be cross compiled to android using cargo-apk.

I create a window with glutin that requests OpenGLES as a fallback. I then wrap it in a modified version of the wrapper from glutin_window (that takes an existing window). Then, I swap out graphics backends between opengl_graphics and opengles_graphics using #[cfg(target_os = "android")].

This is using graphics version v0.21.0 to work with opengles_graphics which is targeting this older version.

dylanhart avatar Nov 28 '17 06:11 dylanhart

Unfortunately opengles_graphics is ancient compared to the ecosystem now (3 years since last change) and deprecated. Is there another kind backend for opengles that can be used?

OptimisticPeach avatar Oct 09 '19 01:10 OptimisticPeach

Closing as outdated. Feel free to open up a new issue.

bvssvni avatar Apr 30 '24 17:04 bvssvni