add debug window showing the glyph atlas

This commit is contained in:
Konstantin Käfer
2014-03-14 12:43:42 +01:00
parent 99cef810ac
commit 3c5bac0f6b
6 changed files with 43 additions and 11 deletions

View File

@@ -68,12 +68,10 @@ public:
glfwSetKeyCallback(window, key);
}
static void character(GLFWwindow *window, unsigned int codepoint) {
}
static void key(GLFWwindow *window, int key, int scancode, int action, int mods) {
MapView *mapView = (MapView *)glfwGetWindowUserPointer(window);
@@ -95,7 +93,6 @@ public:
}
}
static void scroll(GLFWwindow *window, double xoffset, double yoffset) {
MapView *mapView = (MapView *)glfwGetWindowUserPointer(window);
double delta = yoffset * 40;
@@ -234,3 +231,38 @@ public:
llmr::Settings& settings;
llmr::Map map;
};
namespace llmr {
namespace platform {
double time() {
return glfwGetTime();
}
void show_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);
glPixelZoom(1.0, -1.0);
glRasterPos2f(-1.0f, 1.0f);
glDrawPixels(width, height, GL_LUMINANCE, GL_UNSIGNED_BYTE, data);
glfwSwapBuffers(debug_window);
glfwMakeContextCurrent(current_window);
}
}
}