diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-01-13 18:07:13 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-01-13 18:07:13 +0100 |
commit | 654972bb3feb1f451a820afbc7c46e7e502ce687 (patch) | |
tree | f154d0dab2415f0494a4d976f7226118039d9661 /macosx | |
parent | 16d0c83df2b1a882eae1c4d988a84bca5fe84e9a (diff) | |
download | qtlocation-mapboxgl-654972bb3feb1f451a820afbc7c46e7e502ce687.tar.gz |
cmake + tile loading
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/CMakeLists.txt | 37 | ||||
-rw-r--r-- | macosx/main.mm | 36 |
2 files changed, 61 insertions, 12 deletions
diff --git a/macosx/CMakeLists.txt b/macosx/CMakeLists.txt new file mode 100644 index 0000000000..2a839c0c1d --- /dev/null +++ b/macosx/CMakeLists.txt @@ -0,0 +1,37 @@ +FIND_LIBRARY(COCOA_LIBRARY Cocoa) +FIND_LIBRARY(OPENGL_LIBRARY OpenGL) +FIND_LIBRARY(IOKIT_LIBRARY IOKit) +FIND_LIBRARY(COREVIDEO_LIBRARY CoreVidoe) + +FIND_PACKAGE(PkgConfig REQUIRED) +PKG_SEARCH_MODULE(GLFW REQUIRED glfw3) + + +SET(macosx_SOURCES + main.mm +) + +SET(macosx_HEADERS +) + +INCLUDE_DIRECTORIES( + ../include + ${GLFW_INCLUDE_DIRS} +) + +LINK_DIRECTORIES( + ${GLFW_LIBRARY_DIRS} +) + +ADD_EXECUTABLE(macosx + ${macosx_SOURCES} +) + +TARGET_LINK_LIBRARIES(macosx + llmr + ${COCOA_LIBRARY} + ${OPENGL_LIBRARY} + ${IOKIT_LIBRARY} + ${COREVIDOE_LIBRARY} + ${GLFW_LIBRARIES} +) diff --git a/macosx/main.mm b/macosx/main.mm index 3119d2b869..20b6cc174a 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -11,8 +11,10 @@ public: tracking(false), rotating(false), last_click(-1), - platform(new llmr::platform(this)), - map(new llmr::map(platform)) { + map(new llmr::map()) { + } + + void init() { if (!glfwInit()) { fprintf(stderr, "Failed to initialize glfw\n"); exit(1); @@ -143,7 +145,6 @@ public: ~MapView() { delete map; - delete platform; glfwTerminate(); } @@ -158,19 +159,25 @@ public: double last_click; GLFWwindow *window; - llmr::platform *platform; llmr::map *map; }; -void llmr::platform::restart() { - ((MapView *)obj)->dirty = true; + +MapView *view; + +namespace llmr { +namespace platform { + +void restart(void *) { + view->dirty = true; } -void llmr::platform::request(tile *tile) { +void request(void *, tile *tile) { fprintf(stderr, "request %d/%d/%d\n", tile->z, tile->x, tile->y); fprintf(stderr, "requesting tile\n"); - NSString *urlTemplate = @"http://api.tiles.mapbox.com/v3/mapbox.mapbox-streets-v4/%d/%d/%d.vector.pbf"; + // NSString *urlTemplate = @"http://api.tiles.mapbox.com/v3/mapbox.mapbox-streets-v4/%d/%d/%d.vector.pbf"; + NSString *urlTemplate = @"http://localhost:3333/gl/tiles/%d-%d-%d.vector.pbf"; NSString *urlString = [NSString stringWithFormat:urlTemplate, tile->z, @@ -192,20 +199,25 @@ void llmr::platform::request(tile *tile) { tile->setData((uint8_t *)[data bytes], [data length]); if (tile->parse()) { dispatch_async(dispatch_get_main_queue(), ^ { - ((MapView *)obj)->map->tileLoaded(tile); + view->map->tileLoaded(tile); }); return; } } dispatch_async(dispatch_get_main_queue(), ^ { - ((MapView *)obj)->map->tileFailed(tile); + view->map->tileFailed(tile); }); }]; } +} +} int main() { - MapView view; - return view.run(); + view = new MapView(); + view->init(); + int ret = view->run(); + delete view; + return ret; } |