piston
piston copied to clipboard
Android support
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.
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
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.
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
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.
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.
This is perhaps a bit too far stretch goal to worry about now.
Closing for now.
@bvssvni - Is this viable now? I'm really interested in playing with game dev on mobile with rust.
@beatgammit Yeah, it is time to think about it again. There has been a few experiments but I have not tried it myself.
Any progress on this, I'd love to use this to make a cross-platform Linux/Mac/Android game!
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.
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.
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?
Closing as outdated. Feel free to open up a new issue.