tangram-es is a C++ library for rendering 2D and 3D maps from vector data using OpenGL ES, it is a counterpart to tangram focused on mobile and embedded devices.
This repository contains both the core rendering library and sample applications that use the library on Android, iOS, Mac OS X, Ubuntu, and Raspberry Pi.
tangram-es is in active development and is not yet feature-complete
This project uses CMake (minimum version 3.0), you can download it here or use your favorite installation package tool like homebrew.
brew install cmake
Make sure to update git submodules before you build:
git submodule update --init --recursive
Currently we are targeting five platforms: OS X, Ubuntu Linux, iOS, Android, and Raspberry Pi.
To build a runnable OS X application bundle, run:
make osx
And open the application with:
open build/osx/bin/tangram.app
For running on OS X from Xcode you will need Xcode version 6.0 or higher. Generate and compile an Xcode project:
make xcode
Then just open the Xcode project and run/debug from there:
open build/xcode/tangram.xcodeproj
Note that any Xcode configuration change you make to the project won't be preserved when CMake runs again. Build configuration is defined only in the CMakeLists file(s).
You can easily run and debug from CLion if you prefer.
After cloning and updating your git submodules, open CLion and Import Project from Sources. Select the root of this repo. Choose Open Project. Do not overwrite CMakeLists.txt.
CLion will automatically set everything up, all you have to do is wait a minute for the project to get initialized. Then, select the tangram target and hit run / debug.
To build on Ubuntu or Debian you will need a C++ toolchain with support for C++14. GCC 5 (or higher) and Clang 3.4 (or higher) are known to work.
You will also need to install development packages for libcurl, x11, and opengl. On Ubuntu 16.04 or Debian Stretch all the required packages can be installed with
sudo apt-get install make g++ pkg-config libcurl4-openssl-dev \
libx11-dev libxrandr-dev libxinerama-dev libxcursor-dev libgl1-mesa-dev
Then build an executable:
make linux
And run it from the output folder:
cd build/linux/bin/ && ./tangram
Note that any Xcode configuration change you make to the project won't be preserved when CMake runs again. Build configuration is defined only in the CMakeLists file(s).
Building the iOS demo application requires Xcode 8.0 or newer. First, run:
make ios
This will generate an Xcode project that you can use to deploy on device or simulator:
open build/ios/tangram.xcodeproj
If you want to run on a device, be sure to set up the code signing identity and code sign the framework on copy (select target tangram > Build Phases > Copy Files > TangramMap.framework > Code Sign On Copy).
An iOS binary framework bundle targeted for ARM architectures can be produced by running the following:
make ios-framework [RELEASE=1|DEBUG=1]
The framework will be available in the configuration build type in /build/ios-framework/lib/
.
To build a universal binary working on both device and simulator architectures run the following:
make ios-framework-universal [RELEASE=1|DEBUG=1]
The universal framework will be available in the configuration build type in /build/ios-framework-universal/
.
To build for Android you'll need to have installed both the Android SDK and the Android NDK. Please verify that you have version r10e of the NDK installed. Set an ANDROID_HOME
environment variable with the root directory of your SDK and an ANDROID_NDK
environment variable with the root directory of your NDK.
Build an APK of the demo application and optionally specify an architecture (default is armeabi-v7a):
make android [ANDROID_ARCH=[x86|armeabi-v7a|armeabi]]
Then install to a connected device or emulator. You can (re)install and run the APK with a small script:
./android/run.sh
To build on Rasberry Pi you will need a C++ toolchain with support for C++14. GCC 4.9 (or higher) is known to work (refer here for instructions on getting GCC 4.9).
First, install CMake and libcurl:
sudo apt-get install cmake libcurl4-openssl-dev
Before compiling, choose which compiler to use:
export CXX=/usr/bin/g++-4.9
Then compile and run:
make rpi
cd build/rpi/bin
./tangram
Tangram will be rendered directly to the screen without a window manager, if you want see the mouse cursor run the application with the -m
argument like this:
cd build/rpi/bin
./tangram -m
You can also move the map with w
, a
, s
, and z
, zoom in and out with -
and =
, and quit with q
.
To build in RELEASE
or DEBUG
run the following:
make [platform] DEBUG=1
or
make [platform] RELEASE=1
In general, code changes should follow the style of the surrounding code.
When in doubt, you can use the provided clang-format style file for automatic styling.
Install clang-format (available through brew or apt-get):
brew install clang-format
or
sudo apt-get install clang-format
Run clang-format with specified style (use -i to modify the contents of the specified file):
clang-format -i -style=file [file]