summaryrefslogtreecommitdiff
path: root/macosx/main.mm
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-08-10 17:14:00 +0300
committerKonstantin Käfer <mail@kkaefer.com>2015-08-11 16:40:40 +0300
commit21ec5056489f53601b3d45a0b1c79a85add42b0b (patch)
treea408abd442adf33facad99e1c50fdd5c8d3e331d /macosx/main.mm
parentca8ffcc4562b830a02e1087e8d951b556ae315d9 (diff)
downloadqtlocation-mapboxgl-21ec5056489f53601b3d45a0b1c79a85add42b0b.tar.gz
add benchmark mode that shows the real frame time rather than the vsync time
Diffstat (limited to 'macosx/main.mm')
-rw-r--r--macosx/main.mm53
1 files changed, 48 insertions, 5 deletions
diff --git a/macosx/main.mm b/macosx/main.mm
index 4a786f5772..24251e6d4f 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -12,6 +12,19 @@
#import <Foundation/Foundation.h>
+#pragma GCC diagnostic push
+#ifndef __clang__
+#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
+#pragma GCC diagnostic ignored "-Wshadow"
+#endif
+#include <boost/program_options.hpp>
+#pragma GCC diagnostic pop
+
+#include <iostream>
+
+namespace po = boost::program_options;
+
+
@interface URLHandler : NSObject
@property (nonatomic) mbgl::Map *map;
@@ -101,8 +114,33 @@ const std::string &defaultCacheDatabase() {
return path;
}
-int main() {
- GLFWView view;
+int main(int argc, char* argv[]) {
+ bool fullscreen = false;
+ bool benchmark = false;
+ std::string style;
+
+ po::options_description desc("Allowed options");
+ desc.add_options()
+ ("fullscreen,f", po::bool_switch(&fullscreen)->default_value(fullscreen), "Fullscreen mode")
+ ("style,s", po::value(&style)->value_name("json"), "Map stylesheet")
+ ("benchmark,b", po::bool_switch(&benchmark)->default_value(benchmark), "Benchmark mode")
+ ;
+
+ try {
+ auto parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().run();
+ po::variables_map vm;
+ po::store(parsed, vm);
+ po::notify(vm);
+ } catch(std::exception& e) {
+ std::cout << "Error: " << e.what() << std::endl << desc;
+ exit(1);
+ }
+
+ if (benchmark) {
+ mbgl::Log::Info(mbgl::Event::General, "BENCHMARK MODE: Some optimizations are disabled.");
+ }
+
+ GLFWView view(fullscreen, benchmark);
mbgl::SQLiteCache cache(defaultCacheDatabase());
mbgl::DefaultFileSource fileSource(&cache);
@@ -146,10 +184,15 @@ int main() {
mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.first);
});
+
// Load style
- const auto& newStyle = mbgl::util::defaultStyles.front();
- map.setStyleURL(newStyle.first);
- view.setWindowTitle(newStyle.second);
+ if (style.empty()) {
+ const auto& newStyle = mbgl::util::defaultStyles.front();
+ style = newStyle.first;
+ view.setWindowTitle(newStyle.second);
+ }
+
+ map.setStyleURL(style);
view.run();