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.
Platform | Build status |
---|---|
Linux/Android | |
iOS |
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).
Tangram ES can also be build with system font and GLFW libraries. This can be done with
CMAKE_OPTIONS=" -DUSE_SYSTEM_GLFW_LIBS=1 -DUSE_SYSTEM_FONT_LIBS=1" make linux
On Ubuntu 16.04 or Debian Stretch the additional packages required can be installed with
sudo apt-get install libglfw3-dev libicu-dev libfreetype6-dev libharfbuzz-dev
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 use Android Studio version 2.2 or newer on Mac OS X, Ubuntu, or Windows 10. Using the Android Studio SDK Manager, install or update the 'CMake', 'LLDB', and 'NDK' packages from the 'SDK Tools' tab. Once dependencies are installed, you can execute Android builds from either the command line or the Android Studio interface.
To build the demo application for the ARMv7 architecture (covers most Android devices), run:
make android
Or open the project in Android Studio and press the 'Run' button (^R). More options are provided through Gradle.
The Gradle project in the android/
directory contains two modules: a library module called tangram
containing the Tangram Android SDK and an application module called demo
, containing a demo application that uses the tangram
module. The tangram
module has two buildTypes
, debug
and release
, and two productFlavors
, slim
and full
. The slim
flavor includes native libraries for just the ARMv7 architecture, the full
flavor includes all supported architectures (ARMv6, ARMv7, ARM64, and x86).
To build the library or demo application from the android/
folder using Gradle, use the conventional syntax, e.g.:
./gradlew tangram:assembleFullRelease
Android Studio supports debugging both the Java and C++ parts of tangram-es on a connected device or emulator. Choose one of the 'debug' build variants, set your desired breakpoints, and press the 'Debug' button (^D).
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]