diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-05-19 11:13:22 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-05-19 11:13:22 +0200 |
commit | 898c6d6714bcbd1a8600deca1437a59f3c33f10e (patch) | |
tree | ba579763c5db564d8e77c2da55a281872cabacf6 /common | |
parent | 13575330f7d32630f6dbf4244405c46b453152fe (diff) | |
download | qtlocation-mapboxgl-898c6d6714bcbd1a8600deca1437a59f3c33f10e.tar.gz |
fix for retina screens
Diffstat (limited to 'common')
-rw-r--r-- | common/glfw_view.cpp | 11 |
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); |