Skip to content

Commit fb2c80b

Browse files
mathislogesopyer
authored andcommitted
Windows port
1 parent 92c5688 commit fb2c80b

34 files changed

+607
-98
lines changed

.gitignore

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Created by http://www.gitignore.io
22

3+
### Windows ###
4+
.vscode/
5+
.vs/
6+
ipch/
7+
build/
8+
out/
9+
10+
CMakeSettings.json
11+
*.suo
12+
*.user
13+
*.userosscache
14+
*.sln.docstates
15+
*.ncb
16+
*.opendb
17+
*.opensdf
18+
*.sdf
19+
*.VC.db
20+
*.vspx
21+
322
### OSX ###
423
.DS_Store
524
.AppleDouble

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.2)
1+
cmake_minimum_required(VERSION 3.10)
22

33
project(tangram)
44

@@ -19,7 +19,7 @@ option(TANGRAM_DEV_MODE "For developers only: Don't omit the frame pointer" OFF)
1919
message(STATUS "Build type configuration: ${CMAKE_BUILD_TYPE}")
2020

2121
# Check that submodules are present.
22-
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README")
22+
if(NOT MSVC AND NOT EXISTS "${PROJECT_SOURCE_DIR}/core/deps/harfbuzz-icu-freetype/harfbuzz/README")
2323
message(SEND_ERROR "Missing submodules - Please run:\n 'git submodule update --init'")
2424
return()
2525
endif()

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ For more information about building Tangram ES or using it in your project, see
1919
- [Mac OS X](platforms/osx)
2020
- [Ubuntu Linux](platforms/linux)
2121
- [Raspberry Pi](platforms/rpi)
22+
- [Windows](platforms/windows)
2223

2324
## Support
2425

cmake/utils.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ function(check_unsupported_compiler_version)
33
set(MIN_GCC 4.9)
44
set(MIN_CLANG 3.4)
55
set(MIN_APPLECLANG 6.0)
6+
set(MIN_MSVC 19.0)
67

78
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
89
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_GCC})
@@ -16,8 +17,12 @@ function(check_unsupported_compiler_version)
1617
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_APPLECLANG})
1718
message(FATAL_ERROR "Your Xcode version does not support C++14, please install version ${MIN_APPLECLANG} or higher")
1819
endif()
20+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
21+
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${MIN_MSVC})
22+
message(FATAL_ERROR "Your MSVC version does not support C++14, please install version ${MIN_MSVC} or higher")
23+
endif()
1924
else()
20-
message(WARNING "Compilation has only been tested with Clang, AppleClang, and GCC")
25+
message(WARNING "Compilation has only been tested with Clang, AppleClang, GCC and MSVC")
2126
endif()
2227

2328
endfunction(check_unsupported_compiler_version)

core/CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
project(tangram-core)
22

33
# Build core library dependencies.
4+
find_package(ZLIB REQUIRED)
5+
if (MSVC)
6+
find_package(yaml-cpp CONFIG REQUIRED)
7+
endif()
8+
49
add_subdirectory(deps)
510

611
add_library(tangram-core
@@ -222,6 +227,10 @@ target_include_directories(tangram-core
222227
deps/double-conversion/include
223228
)
224229

230+
if (WIN32)
231+
target_compile_definitions(tangram-core PUBLIC _USE_MATH_DEFINES)
232+
endif()
233+
225234
# Link core library dependencies.
226235
target_link_libraries(tangram-core
227236
PRIVATE
@@ -231,7 +240,7 @@ target_link_libraries(tangram-core
231240
alfons
232241
double-conversion
233242
miniz
234-
z
243+
ZLIB::ZLIB
235244
)
236245

237246
# Add JavaScript implementation.

core/deps/CMakeLists.txt

+21-12
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ target_compile_definitions(glm INTERFACE GLM_FORCE_CTOR_INIT)
1313

1414
## yaml-cpp ##
1515
##############
16-
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
17-
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
18-
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
19-
set(YAML_CPP_INSTALL OFF CACHE BOOL "")
20-
add_subdirectory(yaml-cpp)
21-
22-
target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
16+
if (NOT MSVC)
17+
set(YAML_CPP_BUILD_TESTS OFF CACHE BOOL "")
18+
set(YAML_CPP_BUILD_TOOLS OFF CACHE BOOL "")
19+
set(YAML_CPP_BUILD_CONTRIB OFF CACHE BOOL "")
20+
set(YAML_CPP_INSTALL OFF CACHE BOOL "")
21+
add_subdirectory(yaml-cpp)
22+
23+
target_include_directories(yaml-cpp PUBLIC yaml-cpp/include)
24+
endif()
2325

2426
## css-color-parser-cpp ##
2527
##########################
@@ -48,14 +50,21 @@ target_include_directories(miniz
4850
if(NOT TANGRAM_USE_SYSTEM_FONT_LIBS)
4951
## Harfbuzz - ICU-Common - Freetype2 ##
5052
#######################################
51-
set(HARFBUZZ_BUILD_ICU ON CACHE BOOL "Enable building of ICU")
52-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/harfbuzz-icu-freetype)
53-
54-
message(STATUS "harfbuzz" ${HARFBUZZ_LIBRARIES})
53+
if(MSVC)
54+
#find_package(ICU REQUIRED COMPONENTS common)
55+
find_package(harfbuzz CONFIG REQUIRED)
56+
set(HARFBUZZ_LIB_NAME harfbuzz::harfbuzz)
57+
else()
58+
set(HARFBUZZ_BUILD_ICU ON CACHE BOOL "Enable building of ICU")
59+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/harfbuzz-icu-freetype)
60+
61+
message(STATUS "harfbuzz" ${HARFBUZZ_LIBRARIES})
62+
set(HARFBUZZ_LIB_NAME harfbuzz ${HARFBUZZ_LIBRARIES})
63+
endif()
5564

5665
set(ALFONS_DEPS_LIBRARIES
5766
${ALFONS_DEPS_LIBRARIES}
58-
harfbuzz ${HARFBUZZ_LIBRARIES}
67+
${HARFBUZZ_LIB_NAME}
5968
CACHE INTERNAL "alfons-libs" FORCE)
6069
endif()
6170

core/deps/pbf/pbf.hpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
#endif
2727

2828
namespace protobuf {
29-
29+
#if defined(__GNUC__)
3030
#define FORCEINLINE inline __attribute__((always_inline))
3131
#define NOINLINE __attribute__((noinline))
32+
#else
33+
#define FORCEINLINE inline
34+
#define NOINLINE
35+
#endif
3236
#define PBF_INLINE FORCEINLINE
3337

3438
class message {

core/include/tangram/log.h

+4
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ static constexpr const char * past_last_slash(const char * const str) {
2727
return past_last_slash(str, str);
2828
}
2929

30+
#ifdef TANGRAM_WINDOWS
31+
#define __FILENAME__ __FILE__
32+
#else
3033
#define __FILENAME__ ({constexpr const char * const sf__ {past_last_slash(__FILE__)}; sf__;})
34+
#endif
3135

3236
#define TANGRAM_MAX_BUFFER_LOG_SIZE 99999
3337

core/include/tangram/tile/tileID.h

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <cassert>
44
#include <cstdint>
55
#include <string>
6+
#include <algorithm>
67

78
/* An immutable identifier for a map tile
89
*

core/include/tangram/util/url.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Url {
131131
// parts describes URL components by their location within the buffer.
132132
struct Parts {
133133
struct Range {
134-
uint16_t start = 0, count = 0;
134+
size_t start = 0, count = 0;
135135
} scheme, location, path, parameters, query, fragment, media, data;
136136
} parts;
137137

core/include/tangram/util/variant.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,15 @@ using Value = variant<none_type, double, std::string>;
5555

5656
class Value : public detail::Value {
5757
using Base = detail::Value;
58-
using Base::Base;
58+
59+
public:
60+
Value(): Base() {}
61+
62+
template<typename T>
63+
Value(const T& val): Base(val) {}
64+
65+
template<typename T>
66+
Value(T&& val): Base(val) {}
5967
};
6068

6169
const static Value NOT_A_VALUE(none_type{});

core/src/data/rasterSource.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ std::shared_ptr<Texture> RasterSource::cacheTexture(const TileID& _tileId, std::
208208
}
209209

210210
texture = std::shared_ptr<Texture>(_texture.release(),
211-
[c = std::weak_ptr<Cache>(m_textures), id](auto t) {
211+
[c = std::weak_ptr<Cache>(m_textures), id](auto* t) {
212212
if (auto cache = c.lock()) {
213213
cache->erase(id);
214214
LOGD("%d - remove %s", cache->size(), id.toString().c_str());

core/src/debug/textDisplay.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void TextDisplay::draw(RenderState& rs, const std::string& _text, int _posx, int
8989
std::vector<glm::vec2> vertices;
9090
int nquads;
9191

92-
nquads = stb_easy_font_print(_posx, _posy, _text.c_str(), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);
92+
nquads = stb_easy_font_print(_posx, _posy, const_cast<char*>(_text.c_str()), NULL, m_vertexBuffer, VERTEX_BUFFER_SIZE);
9393

9494
float* data = reinterpret_cast<float*>(m_vertexBuffer);
9595

core/src/gl/framebuffer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void FrameBuffer::init(RenderState& _rs) {
147147
}
148148

149149
GLenum status = GL::checkFramebufferStatus(GL_FRAMEBUFFER);
150-
GL_CHECK();
150+
GL_CHECK({});
151151

152152
if (status != GL_FRAMEBUFFER_COMPLETE) {
153153
LOGE("Framebuffer status is incomplete:");

core/src/scene/importer.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@ void Importer::addSceneYaml(const Url& sceneUrl, const char* sceneYaml, size_t l
188188
auto& sceneNode = m_sceneNodes[sceneUrl];
189189

190190
try {
191+
#ifdef _MSC_VER
192+
sceneNode.yaml = YAML::Load(sceneYaml);
193+
#else
191194
sceneNode.yaml = YAML::Load(sceneYaml, length);
195+
#endif
192196
} catch (const YAML::ParserException& e) {
193197
LOGE("Parsing scene config '%s'", e.what());
194198
return;

core/src/scene/sceneLoader.cpp

+15-15
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void SceneLoader::applyScene(const Node& _node, Color& backgroundColor,
145145
Stops& backgroundStops, Scene::animate& animated) {
146146
if (!_node) { return; }
147147
if (!_node.IsMap()) {
148-
LOGNode("Invalid 'scene' section", _node);
148+
LOGNode("Invalid 'scene' section", _node, "");
149149
return;
150150
}
151151

@@ -302,7 +302,7 @@ Scene::Lights SceneLoader::applyLights(const Node& _node) {
302302
}
303303
}
304304
} else if (_node) {
305-
LOGNode("Invalid 'lights'", _node);
305+
LOGNode("Invalid 'lights'", _node, "");
306306
}
307307

308308
if (lights.empty()) {
@@ -436,14 +436,14 @@ void SceneLoader::parseLightPosition(const Node& _positionNode, PointLight& _lig
436436
}
437437
_light.setPosition(positionResult);
438438
} else {
439-
LOGNode("Invalid light position parameter:", _positionNode);
439+
LOGNode("Invalid light position parameter:", _positionNode, "");
440440
}
441441
}
442442

443443
void SceneLoader::applyTextures(const Node& _node, SceneTextures& _textures) {
444444
if (!_node) { return; }
445445
if (!_node.IsMap()) {
446-
LOGNode("Invalid 'textures' section", _node);
446+
LOGNode("Invalid 'textures' section", _node, "");
447447
return;
448448
}
449449

@@ -543,7 +543,7 @@ bool SceneLoader::parseTexFiltering(const Node& _filteringNode, TextureOptions&
543543
void SceneLoader::applyFonts(const Node& _node, SceneFonts& _fonts) {
544544
if (!_node) { return; }
545545
if (!_node.IsMap()) {
546-
LOGNode("Invalid 'fonts' section", _node);
546+
LOGNode("Invalid 'fonts' section", _node, "");
547547
return;
548548
}
549549

@@ -570,7 +570,7 @@ void SceneLoader::applyFonts(const Node& _node, SceneFonts& _fonts) {
570570
void SceneLoader::loadFontDescription(const Node& _node, const std::string& _family, SceneFonts& _fonts) {
571571
if (!_node) { return; }
572572
if (!_node.IsMap()) {
573-
LOGNode("Invalid 'font' section", _node);
573+
LOGNode("Invalid 'font' section", _node, "");
574574
return;
575575
}
576576

@@ -634,18 +634,18 @@ Scene::TileSources SceneLoader::applySources(const Node& _config, const SceneOpt
634634

635635
if (const Node& rasters = source.second["rasters"]) {
636636
if (!rasters.IsSequence()) {
637-
LOGNode("Invalid 'rasters'", rasters);
637+
LOGNode("Invalid 'rasters'", rasters, "");
638638
continue;
639639
}
640640
for (const auto& raster : rasters) {
641641
if (!raster.IsScalar()) {
642-
LOGNode("Invalid 'raster'", raster);
642+
LOGNode("Invalid 'raster'", raster, "");
643643
continue;
644644
}
645645
if (auto rasterSource = getTileSource(raster.Scalar())) {
646646
tileSource->addRasterSource(rasterSource);
647647
} else {
648-
LOGNode("Missing raster source", raster);
648+
LOGNode("Missing raster source", raster, "");
649649
}
650650
}
651651
}
@@ -676,7 +676,7 @@ Scene::TileSources SceneLoader::applySources(const Node& _config, const SceneOpt
676676
if (!data_source) { continue;}
677677

678678
if (!data_source.IsScalar()) {
679-
LOGNode("Invalid 'source", data);
679+
LOGNode("Invalid 'source", data, "");
680680
continue;
681681
}
682682
auto source = data_source.Scalar();
@@ -875,7 +875,7 @@ Scene::Styles SceneLoader::applyStyles(const Node& _node, SceneTextures& _textur
875875

876876
if (!_node) { return styles; }
877877
if (!_node.IsMap()) {
878-
LOGNode("Invalid 'styles' section", _node);
878+
LOGNode("Invalid 'styles' section", _node, "");
879879
return styles;
880880
}
881881

@@ -1256,7 +1256,7 @@ void SceneLoader::loadShaderConfig(const Node& _shaders, Style& _style, SceneTex
12561256

12571257
_style.styleUniforms().emplace_back(name, styleUniform.value);
12581258
} else {
1259-
LOGNode("Style uniform parsing failure", uniform.second);
1259+
LOGNode("Style uniform parsing failure", uniform.second, "");
12601260
}
12611261
}
12621262
}
@@ -1387,7 +1387,7 @@ void SceneLoader::loadMaterial(const Node& _matNode, Material& _material, Style&
13871387
// Handled as texture
13881388
break;
13891389
default:
1390-
LOGNode("Invalid 'material'", prop);
1390+
LOGNode("Invalid 'material'", prop, "");
13911391
break;
13921392
}
13931393
return glm::vec4(0.0);
@@ -1441,7 +1441,7 @@ MaterialTexture SceneLoader::loadMaterialTexture(const Node& _matCompNode, Style
14411441

14421442
Node textureNode = _matCompNode["texture"];
14431443
if (!textureNode) {
1444-
LOGNode("Expected a 'texture' parameter", _matCompNode);
1444+
LOGNode("Expected a 'texture' parameter", _matCompNode, "");
14451445

14461446
return MaterialTexture{};
14471447
}
@@ -1501,7 +1501,7 @@ std::vector<DataLayer> SceneLoader::applyLayers(const Node& _node, SceneFunctio
15011501
SceneStops& _stops, DrawRuleNames& _ruleNames) {
15021502
if (!_node) { return {}; }
15031503
if (!_node.IsMap()) {
1504-
LOGNode("Invalid 'layers' section", _node);
1504+
LOGNode("Invalid 'layers' section", _node, "");
15051505
return {};
15061506
}
15071507

0 commit comments

Comments
 (0)