Skip to content

Commit

Permalink
Merge pull request #13 from tangrams/tile-management
Browse files Browse the repository at this point in the history
Tile management merged to master (finally)
  • Loading branch information
tallytalwar committed Oct 28, 2014
2 parents 6ae1e3c + 020f550 commit c97cdd6
Show file tree
Hide file tree
Showing 56 changed files with 1,884 additions and 548 deletions.
4 changes: 3 additions & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
android:versionName="1.0">
<uses-sdk android:minSdkVersion="17"/>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher" android:debuggable="true">
<activity android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
Expand Down
24 changes: 21 additions & 3 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
# "my-dir" is a macro function which will return the path of the current directory (where Android.mk resides)
LOCAL_PATH := $(call my-dir)

# prepare libtess2
include $(CLEAR_VARS)
LOCAL_MODULE := libtess2
LOCAL_SRC_FILES := precompiled/$(TARGET_ARCH_ABI)/libtess2.a
include $(PREBUILT_STATIC_LIBRARY)

# Clear contents of the LOCAL_* variables
include $(CLEAR_VARS)

# prepare libcurl
# prebuilt binaries from https://github.com/minggo/libcurl-build/tree/master/prebuild-with-ssl
include $(CLEAR_VARS)
Expand All @@ -13,19 +22,28 @@ include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)

# All the source files to include in this module
LOCAL_SRC_FILES := ../../core/tangram.cpp $(wildcard $(LOCAL_PATH)/../../core/util/*.cpp) jniExports.cpp platform_android.cpp
LOCAL_SRC_FILES := ../../core/src/tangram.cpp jniExports.cpp platform_android.cpp
LOCAL_SRC_FILES += ../../core/include/jsoncpp/jsoncpp.cpp
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/util/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/dataSource/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/mapTile/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/sceneDefinition/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/sceneDirector/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/style/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/tileManager/*.cpp)
LOCAL_SRC_FILES += $(wildcard $(LOCAL_PATH)/../../core/src/viewModule/*.cpp)

# The name of the module
LOCAL_MODULE := tangram

# Compilation flags
LOCAL_CFLAGS := -Werror -DPLATFORM_ANDROID -fexceptions

LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all include ../../core/ ../../core/include/
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all include ../../core/src/ ../../core/include/ ../../core/include/jsoncpp

# Static libraries to link with
LOCAL_LDLIBS := -llog -lGLESv2 -lz
LOCAL_STATIC_LIBRARIES := libcurl
LOCAL_STATIC_LIBRARIES := libcurl libtess2

# Build the module
include $(BUILD_SHARED_LIBRARY)
Binary file added android/jni/precompiled/armeabi-v7a/libtess2.a
Binary file not shown.
Binary file added android/jni/precompiled/armeabi/libtess2.a
Binary file not shown.
Binary file added android/jni/precompiled/x86/libtess2.a
Binary file not shown.
1 change: 1 addition & 0 deletions android/src/com/mapzen/tangram/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void onCreate(Bundle savedInstanceState)

view = new GLSurfaceView(getApplication());
view.setEGLContextClientVersion(2);
view.setEGLConfigChooser(8,8,8,8,16,0);
view.setRenderer(new TangramRenderer());
setContentView(view);

Expand Down
4 changes: 2 additions & 2 deletions android/src/com/mapzen/tangram/TangramRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
public class TangramRenderer implements GLSurfaceView.Renderer {

static {
System.loadLibrary("c++_shared");
System.loadLibrary("tangram");
}

Expand All @@ -22,13 +23,12 @@ public void onDrawFrame(GL10 gl)

public void onSurfaceChanged(GL10 gl, int width, int height)
{
init();
resize(width, height);
}

public void onSurfaceCreated(GL10 gl, EGLConfig config)
{
// Do nothing
init();
}

}
5 changes: 4 additions & 1 deletion build/toolchains/android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if(NOT DEFINED ANDROID_TARGET)
endif()
message(STATUS "Android target : ${ANDROID_TARGET}")

set(ANDROID_STL gnustl_shared)

include(${CMAKE_SOURCE_DIR}/build/toolchains/android.toolchain.cmake)

add_definitions(-DPLATFORM_ANDROID)
Expand All @@ -26,6 +28,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pedantic -llog -lz")
set(CXX_FLAGS_DEBUG "${CXX_FLAGS_DEBUG} -g -O0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -fPIC")
set(LIBCURL_PRECOMPILED_LIB ${CMAKE_SOURCE_DIR}/android/jni/precompiled/${ANDROID_ABI}/libcurl.a)
set(LIBTESS_PRECOMPILED_LIB ${CMAKE_SOURCE_DIR}/android/jni/precompiled/${ANDROID_ABI}/libtess2.a)

# include dependency headers
include_directories(${PROJECT_SOURCE_DIR}/android/jni/include)
Expand All @@ -41,7 +44,7 @@ set(ADDITIONNAL_TARGET_DEPENDENT_SRC_FILES
set(INSTALL_CORE_LIBRARY "ON")
set(CORE_LIB_TYPE SHARED)
set(CORE_INSTALLATION_PATH ${CMAKE_SOURCE_DIR}/android/libs/${ANDROID_ABI})
set(CORE_LIB_DEPS GLESv2 ${LIBCURL_PRECOMPILED_LIB})
set(CORE_LIB_DEPS GLESv2 ${LIBCURL_PRECOMPILED_LIB} ${LIBTESS_PRECOMPILED_LIB})
set(CORE_LIB_NAME tangram) # in order to have libtangram.so

include_directories(${PROJECT_SOURCE_DIR}/core/include/)
Expand Down
10 changes: 6 additions & 4 deletions build/toolchains/darwin.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# options
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -stdlib=libc++ -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -stdlib=libc++ -std=c++11 -lz")
set(CXX_FLAGS_DEBUG "-g -O0")
set(EXECUTABLE_NAME "tangram.out")

Expand All @@ -10,8 +10,9 @@ include_directories(/usr/local/include)

# load core library
include_directories(${PROJECT_SOURCE_DIR}/core/include/)
include_directories(${PROJECT_SOURCE_DIR}/core/include/jsoncpp/)
add_subdirectory(${PROJECT_SOURCE_DIR}/core)
include_recursive_dirs(${PROJECT_SOURCE_DIR}/core/*.h)
include_recursive_dirs(${PROJECT_SOURCE_DIR}/core/src/*.h)

# add sources and include headers
find_sources_and_include_directories(
Expand All @@ -32,11 +33,12 @@ function(link_libraries)
${OPENGL_FRAMEWORK}
${COCOA_FRAMEWORK}
${IOKIT_FRAMEWORK}
${CORE_FOUNDATION_FRAMEWORK}
${CORE_FOUNDATION_FRAMEWORK}
${CORE_VIDEO_FRAMEWORK}
${GLFW})

check_and_link_libraries(${EXECUTABLE_NAME} curl)
target_link_libraries(${EXECUTABLE_NAME} -lcurl) #use system libcurl
target_link_libraries(${EXECUTABLE_NAME} ${PROJECT_SOURCE_DIR}/osx/precompiled/libtess2/libtess2.a)
target_link_libraries(${EXECUTABLE_NAME} core ${GLFW_LIBRARIES})

endfunction()
Expand Down
4 changes: 3 additions & 1 deletion build/toolchains/iOS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ endif()
set(FRAMEWORKS CoreGraphics CoreFoundation QuartzCore UIKit OpenGLES Security CFNetwork GLKit)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.mapzen.\${PRODUCT_NAME:Tangram}")
set(APP_TYPE MACOSX_BUNDLE)
set(CORE_LIB_DEPS ${CMAKE_SOURCE_DIR}/ios/precompiled/libcurl.a)
set(CORE_LIB_DEPS ${CMAKE_SOURCE_DIR}/ios/precompiled/libcurl/libcurl.a)
file(GLOB_RECURSE RESOURCES ${PROJECT_SOURCE_DIR}/ios/resources/*.storyboard)

# load core library
include_directories(${PROJECT_SOURCE_DIR}/core/include/)
include_directories(${PROJECT_SOURCE_DIR}/core/include/jsoncpp)
add_subdirectory(${PROJECT_SOURCE_DIR}/core)
include_recursive_dirs(${PROJECT_SOURCE_DIR}/core/*.h)

Expand All @@ -52,6 +53,7 @@ endforeach()

# link and build functions
function(link_libraries)
target_link_libraries(${EXECUTABLE_NAME} ${CMAKE_SOURCE_DIR}/ios/precompiled/libtess2/libtess2.a)
target_link_libraries(${EXECUTABLE_NAME} core)
target_link_libraries(${EXECUTABLE_NAME} ${ZLIB_LIBRARIES})

Expand Down
4 changes: 2 additions & 2 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project(core)
set(INCLUDE_DIR include)
set(SOURCE_DIR src)

add_subdirectory("${INCLUDE_DIR}/json")
add_subdirectory("${INCLUDE_DIR}/jsoncpp")
add_subdirectory("${INCLUDE_DIR}/glm")

file(GLOB_RECURSE FOUND_HEADERS "${SOURCE_DIR}/*.h")
Expand All @@ -17,7 +17,7 @@ foreach(_headerFile ${FOUND_HEADERS})
endforeach()
list(REMOVE_DUPLICATES INCLUDE_DIRS)

include_directories(${INCLUDE_DIR}/json ${INCLUDE_DIR} ${INCLUDE_DIRS})
include_directories(${INCLUDE_DIR}/jsoncpp ${INCLUDE_DIR} ${INCLUDE_DIRS})

# adding some other dependent target files if needed
set(FOUND_SOURCES ${FOUND_SOURCES} ${ADDITIONNAL_TARGET_DEPENDENT_SRC_FILES})
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions core/include/stl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* Include a set of STL items
*
* Although it is typically not good practice to "use" namespace items, a few STL items are so frequently used in C++ that
* it becomes more troublesome to prefix them in every usage.
*/

#pragma once
#include "stl_util.hpp"

#include <string>
using std::string;

#include <memory>
using std::unique_ptr;
using std::shared_ptr;
using std::make_shared;
using std_patch::make_unique;
using std_patch::to_string;

#include <vector>
using std::vector;

#include <map>
using std::map;

#include <unordered_map>
using std::unordered_map;
21 changes: 21 additions & 0 deletions core/include/stl_util.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include <string>
#include <sstream>
#include <memory>

// some stuff that belongs in the c++ stllib, but isn't
namespace std_patch {
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}

// for some reason android doesn't ship with to_string
// implement it here
template<typename T>
std::string to_string( const T& n ) {
std::ostringstream stm ;
stm << n ;
return stm.str() ;
}
}
Loading

0 comments on commit c97cdd6

Please sign in to comment.