summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore17
-rw-r--r--emscripten/main.cpp154
-rw-r--r--emscripten/main.html9
-rw-r--r--enable-emscripten2
-rw-r--r--include/llmr/platform/gl.hpp4
-rw-r--r--src/renderer/shader.cpp4
6 files changed, 10 insertions, 180 deletions
diff --git a/.gitignore b/.gitignore
index bbd74195c0..7a261599a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,8 @@
-*.o
-/emscripten/main.js
-/emscripten/main.js.map
-/build
-*.sublime-*
-config.gypi
-config.mk
-.DS_Store
-out
-mapnik-packaging
*.xcodeproj
+/out
+/mapnik-packaging
+/macosx/build
+/ios/build
+/config.gypi
+/config.mk
+/build \ No newline at end of file
diff --git a/emscripten/main.cpp b/emscripten/main.cpp
deleted file mode 100644
index ffdef046b3..0000000000
--- a/emscripten/main.cpp
+++ /dev/null
@@ -1,154 +0,0 @@
-#include <emscripten/emscripten.h>
-#include <GL/glfw.h>
-#include <cstdio>
-#include <cstdlib>
-#include <cmath>
- #include <unistd.h>
-
-#include <llmr/llmr.hpp>
-#include <llmr/map/tile.hpp>
-
-bool dirty = true;
-
-class MapView;
-
-static MapView *view;
-
-class MapView {
-public:
- MapView() :
- dirty(true),
- platform(new llmr::platform(this)),
- map(new llmr::map(platform)) {
-
- // Initialize GLFW
- if (!glfwInit()) {
- fprintf(stderr, "Failed to initialize GLFW\n");
- exit(1);
- }
-
- int width, height;
- emscripten_get_canvas_size(&width, &height, nullptr);
-
- glfwSetMousePosCallback(mousemove);
- glfwSetMouseButtonCallback(mouseclick);
- glfwSetMouseWheelCallback(scroll);
-
- // Open a window and create its OpenGL context
- if (!glfwOpenWindow(width, height, 8, 8, 8, 8, 16, 8, GLFW_WINDOW)) {
- fprintf(stderr, "Failed to open GLFW window\n");
-
- glfwTerminate();
- exit(1);
- }
-
- map->setup();
- map->resize(width, height);
-
- }
-
- ~MapView() {
- delete map;
- delete platform;
- glfwTerminate();
- }
-
- static void mousemove(int x, int y) {
- if (view->tracking) {
- view->map->moveBy(x - view->last_x, y - view->last_y);
- }
- view->last_x = x;
- view->last_y = y;
- }
-
- static void scroll(float pos) {
- double delta = pos;
-
- // bool is_wheel = delta != 0 && fmod(delta, 4.000244140625) == 0;
-
- double absdelta = delta < 0 ? -delta : delta;
- double scale = 2.0 / (1.0 + exp(-absdelta / 100.0));
-
- // Make the scroll wheel a bit slower.
- // if (!is_wheel) {
- // scale = (scale - 1.0) / 2.0 + 1.0;
- // }
-
- // Zooming out.
- if (delta < 0 && scale != 0) {
- scale = 1.0 / scale;
- }
-
- view->map->scaleBy(scale, view->last_x, view->last_y);
- }
-
- static void mouseclick(int button, int action) {
- if (button == GLFW_MOUSE_BUTTON_1) {
- view->tracking = action == GLFW_PRESS;
- } else if (button == GLFW_MOUSE_BUTTON_RIGHT) {
- fprintf(stderr, "right mouse\n");
- }
- }
-
- int run() {
- emscripten_set_main_loop(render, 60, 1);
- return 0;
- }
-
- static void render() {
- if (view->dirty) {
- view->map->render();
- // glClearColor(1, 1, 0, 1);
- // glClear(GL_COLOR_BUFFER_BIT);
-
- view->dirty = false;
- }
- }
-
- bool dirty;
- double last_x, last_y;
- bool tracking;
-
-
- llmr::platform *platform;
- llmr::map *map;
-
-};
-
-
-void llmr::platform::restart() {
- view->dirty = true;
-}
-
-void ontileload(void* custom, void* bytes, int length) {
- fprintf(stderr, "data loaded successfully: length: %d\n", length);
- llmr::tile *tile = (llmr::tile *)custom;
- tile->setData((uint8_t *)bytes, length);
- if (tile->parse()) {
- view->map->tileLoaded(tile);
- return;
- }
-}
-
-void ontileerror(void* custom) {
- fprintf(stderr, "data load error\n");
- llmr::tile *tile = (llmr::tile *)custom;
- view->map->tileFailed(tile);
-}
-
-void llmr::platform::request(tile *tile) {
- const char *urlTemplate = "http://api.tiles.mapbox.com/v3/mapbox.mapbox-streets-v4/%d/%d/%d.vector.pbf";
- char urlString[255];
- snprintf(urlString, 255, urlTemplate, tile->z, tile->x, tile->y);
- fprintf(stderr, "requesting %s\n", urlString);
-
- emscripten_async_wget_data(urlString, tile, ontileload, ontileerror);
-}
-
-
-int main() {
- view = new MapView();
- int ret = view->run();
- delete view;
- return ret;
-}
diff --git a/emscripten/main.html b/emscripten/main.html
deleted file mode 100644
index 9676130527..0000000000
--- a/emscripten/main.html
+++ /dev/null
@@ -1,9 +0,0 @@
-<body>
-<script>
-var canvas = document.createElement('canvas');
-canvas.width = 600;
-canvas.height = 400;
-document.body.appendChild(canvas);
-Module = { canvas: canvas };
-</script>
-<script src="main.js"></script>
diff --git a/enable-emscripten b/enable-emscripten
deleted file mode 100644
index d7feba1eab..0000000000
--- a/enable-emscripten
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-export PATH="`emsdk active_path`:$PATH"
diff --git a/include/llmr/platform/gl.hpp b/include/llmr/platform/gl.hpp
index 4074fa081a..a0d059c756 100644
--- a/include/llmr/platform/gl.hpp
+++ b/include/llmr/platform/gl.hpp
@@ -1,9 +1,7 @@
#ifndef LLMR_RENDERER_GL
#define LLMR_RENDERER_GL
-#ifdef EMSCRIPTEN
- #include <GLES2/gl2.h>
-#elif __APPLE__
+#if __APPLE__
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#include <OpenGLES/ES2/gl.h>
diff --git a/src/renderer/shader.cpp b/src/renderer/shader.cpp
index cdb8e9a9f6..679931004f 100644
--- a/src/renderer/shader.cpp
+++ b/src/renderer/shader.cpp
@@ -105,8 +105,8 @@ bool Shader::compileShader(GLuint *shader, GLenum type, const GLchar *source) {
*shader = glCreateShader(type);
-#if defined(EMSCRIPTEN) || defined(GL_ES_VERSION_2_0)
- // Add WebGL GLSL / OpenGL ES precision premable
+#if defined(GL_ES_VERSION_2_0)
+ // Add OpenGL ES precision premable
const GLchar *preamble = "precision highp float;\n\n";
#else
// Desktop GLSL