summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-05-19 10:48:11 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-05-19 10:48:36 +0200
commit13575330f7d32630f6dbf4244405c46b453152fe (patch)
treec5bc7f3a25774c2d8f6783d77fbd0654e0554acc /common
parent24bd0bb667e6c2570838cd64992ffa388e8fb941 (diff)
downloadqtlocation-mapboxgl-13575330f7d32630f6dbf4244405c46b453152fe.tar.gz
use sprite atlas
Diffstat (limited to 'common')
-rw-r--r--common/glfw_view.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/glfw_view.cpp b/common/glfw_view.cpp
index 7ec5d3b083..2542e6cf93 100644
--- a/common/glfw_view.cpp
+++ b/common/glfw_view.cpp
@@ -231,5 +231,34 @@ void show_debug_image(std::string name, const char *data, size_t width, size_t h
glfwMakeContextCurrent(current_window);
}
+
+void show_color_debug_image(std::string name, const char *data, size_t width, size_t height) {
+ static GLFWwindow *debug_window = nullptr;
+ if (!debug_window) {
+ debug_window = glfwCreateWindow(width, height, name.c_str(), nullptr, nullptr);
+ if (!debug_window) {
+ glfwTerminate();
+ fprintf(stderr, "Failed to initialize window\n");
+ exit(1);
+ }
+ }
+
+ GLFWwindow *current_window = glfwGetCurrentContext();
+
+ glfwSetWindowSize(debug_window, width, height);
+ glfwMakeContextCurrent(debug_window);
+
+ int fb_width, fb_height;
+ glfwGetFramebufferSize(debug_window, &fb_width, &fb_height);
+ float scale = (float)fb_width / (float)width;
+
+ glPixelZoom(scale, -scale);
+ glRasterPos2f(-1.0f, 1.0f);
+ glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, data);
+ glfwSwapBuffers(debug_window);
+
+ glfwMakeContextCurrent(current_window);
+}
+
}
}