summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-05-19 11:13:22 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-05-19 11:13:22 +0200
commit898c6d6714bcbd1a8600deca1437a59f3c33f10e (patch)
treeba579763c5db564d8e77c2da55a281872cabacf6 /common
parent13575330f7d32630f6dbf4244405c46b453152fe (diff)
downloadqtlocation-mapboxgl-898c6d6714bcbd1a8600deca1437a59f3c33f10e.tar.gz
fix for retina screens
Diffstat (limited to 'common')
-rw-r--r--common/glfw_view.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp
index 2542e6cf93..3ef7bc36a9 100644
--- a/common/glfw_view.cpp
+++ b/common/glfw_view.cpp
@@ -232,10 +232,10 @@ void show_debug_image(std::string name, const char *data, size_t width, size_t h
}
-void show_color_debug_image(std::string name, const char *data, size_t width, size_t height) {
+void show_color_debug_image(std::string name, const char *data, size_t logical_width, size_t logical_height, size_t width, size_t height) {
static GLFWwindow *debug_window = nullptr;
if (!debug_window) {
- debug_window = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
+ debug_window = glfwCreateWindow(logical_width, logical_height, name.c_str(), nullptr, nullptr);
if (!debug_window) {
glfwTerminate();
fprintf(stderr, "Failed to initialize window\n");
@@ -245,14 +245,15 @@ void show_color_debug_image(std::string name, const char *data, size_t width, si
GLFWwindow *current_window = glfwGetCurrentContext();
- glfwSetWindowSize(debug_window, width, height);
+ glfwSetWindowSize(debug_window, logical_width, logical_height);
glfwMakeContextCurrent(debug_window);
int fb_width, fb_height;
glfwGetFramebufferSize(debug_window, &fb_width, &fb_height);
- float scale = (float)fb_width / (float)width;
+ float x_scale = (float)fb_width / (float)width;
+ float y_scale = (float)fb_height / (float)height;
- glPixelZoom(scale, -scale);
+ glPixelZoom(x_scale, -y_scale);
glRasterPos2f(-1.0f, 1.0f);
glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
glfwSwapBuffers(debug_window);