summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-04-10 14:07:36 -0400
committerKonstantin Käfer <mail@kkaefer.com>2014-04-10 14:07:36 -0400
commit06bcab956018e0759d036de0f55145926a124382 (patch)
treeefcf5832b32caf67420a1c7ceb1f834ffcda912f
parenteb499e77c1f6cc77452cadd2445b7d99d1b6b7fa (diff)
downloadqtlocation-mapboxgl-06bcab956018e0759d036de0f55145926a124382.tar.gz
correctly update the map dimensions on rotate
refs #37
-rw-r--r--include/llmr/renderer/painter.hpp2
-rw-r--r--ios/MBXViewController.mm16
-rw-r--r--src/map/map.cpp4
-rw-r--r--src/renderer/painter.cpp4
4 files changed, 21 insertions, 5 deletions
diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp
index c5cf22c5e5..3a96f81001 100644
--- a/include/llmr/renderer/painter.hpp
+++ b/include/llmr/renderer/painter.hpp
@@ -43,7 +43,7 @@ public:
void renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id);
void renderText(TextBucket& bucket, const std::string& layer_name, const Tile::ID& id);
- void resize(int width, int height);
+ void resize();
void prepareClippingMask();
void drawClippingMask(const mat4& matrix, uint8_t clip_id, bool opaque = true);
diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm
index 3055eca981..140de2ebd0 100644
--- a/ios/MBXViewController.mm
+++ b/ios/MBXViewController.mm
@@ -162,6 +162,22 @@ class MBXMapView
}
}
+- (BOOL)shouldAutorotate {
+ return YES;
+}
+
+- (NSUInteger)supportedInterfaceOrientations {
+ return UIInterfaceOrientationMaskAll;
+}
+
+-(void)viewWillLayoutSubviews {
+ [super viewWillLayoutSubviews];
+
+ GLKView *view = (GLKView *)self.view;
+ CGRect rect = [view bounds];
+ mapView->map.resize(rect.size.width, rect.size.height, [view drawableWidth], [view drawableHeight]);
+}
+
- (void)togglePalette
{
if (self.palette.alpha < 1)
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 884e21146a..7939911c05 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -46,9 +46,9 @@ void Map::loadSettings() {
void Map::resize(uint16_t width, uint16_t height, uint16_t fb_width, uint16_t fb_height) {
transform.resize(width, height, fb_width, fb_height);
- painter.resize(fb_width, fb_height);
+ painter.resize();
- if (!style.sprite || style.sprite->pixelRatio) {
+ if (!style.sprite || style.sprite->pixelRatio != transform.getPixelRatio()) {
style.sprite = std::make_shared<Sprite>(transform.getPixelRatio());
style.sprite->load(kSpriteURL);
}
diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp
index b576a9dbcd..e86e5c8542 100644
--- a/src/renderer/painter.cpp
+++ b/src/renderer/painter.cpp
@@ -74,8 +74,8 @@ void Painter::setupShaders() {
textShader = std::make_unique<TextShader>();
}
-void Painter::resize(int width, int height) {
- glViewport(0, 0, width, height);
+void Painter::resize() {
+ glViewport(0, 0, transform.getFramebufferWidth(), transform.getFramebufferHeight());
}
void Painter::useProgram(uint32_t program) {