Skip to content
This repository has been archived by the owner on Nov 13, 2018. It is now read-only.

Working Glutin + Opengl + android example to get people started.

Notifications You must be signed in to change notification settings

snsvrno/rust-opengl-android

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is intended to be a minimal working example of desktop + android cross platform graphic app using glutin and gl

What it Does

Simple opengl example taken from tomka/glutin's window example to draw on both desktop and mobile.

Modified to check for mouse & touch input. Click / press inside the window to change the background color!

Requirements

Docker

This example uses of tomaka/cargo-apk's docker image to build the apk. You can do it without docker, but it is more intensive and not as portable of a setup. I haven't testing it without the docker, but I assume it would work as its the same stuff going on inside and outside the docker image. I would recommend the docker image though, might be a hastle to setup but it does help in the future with building for specific environments.

I use docker-compose instead of a Dockerfile or command because it makes it easier to declare specific tasks for the docker image.

Just

I also use just for all the commands to run. You don't need this as the justfile is fairly easy to see whats actually going on, but for convinence I recommend checking it out in your own projects.

Using this Example

Building for Android

First you need to build for android, everything is setup in the docker image so nothing additional is required. If you will use libraries that need to compile for android, you will need to do that in a custom docker image (or you can have then prebuilt as *.so files), and list their location in a .cargo/config file in the project directory. In the case of the example there are no libraries.

To build for android using the just runner

just build-android

Or if you just want to use docker, with docker-compose,

docker-compose run android

Or plain docker if you don't want to use docker-compose,

docker run --rm -v .:/root/src tomaka/cargo-apk cargo apk build

Sometimes the above command doesn't work in windows because of a docker pathing issue. If this gives you an error about path being too short, then just change . to the absolute path to the directory: C:\Users\parent\directory\of\toml.

Installing

Then you can install to android using ADB

The command is already listed in just, which will uninstall the previous version and install the newer version.

just install-android

Random list of references & Links

Not all links here are part of this working example, but they all got me here. I wanted to keep them because I found them useful on the journey and might need to reference them again as I go further down this rabbithole.

OpenGL

SDL2

Rust & Graphics on Mobile

Building Rust for Android

About

Working Glutin + Opengl + android example to get people started.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages