add debug window showing the glyph atlas
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,9 @@ double time();
|
||||
// Performs routine cleanup operation and is called on every loop iteration.
|
||||
void cleanup();
|
||||
|
||||
// Shows an RGBA image with the specified dimensions in a named window.
|
||||
void show_debug_image(std::string name, const char *data, size_t width, size_t height);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -110,9 +110,5 @@ void cancel_request_http(Request *request) {
|
||||
}
|
||||
}
|
||||
|
||||
double time() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,9 +84,5 @@ void cancel_request_http(Request *request)
|
||||
}];
|
||||
}
|
||||
|
||||
double time() {
|
||||
return glfwGetTime();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <llmr/geometry/glyph_atlas.hpp>
|
||||
#include <llmr/map/vector_tile.hpp>
|
||||
#include <llmr/platform/gl.hpp>
|
||||
#include <llmr/platform/platform.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
@@ -135,5 +136,7 @@ void GlyphAtlas::bind() {
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, data);
|
||||
dirty = false;
|
||||
|
||||
platform::show_debug_image("Glyph Atlas", data, width, height);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -432,6 +432,8 @@ bool Map::render() {
|
||||
transform.updateAnimations();
|
||||
}
|
||||
|
||||
glyphAtlas.bind();
|
||||
|
||||
bool changed = updateTiles();
|
||||
|
||||
painter.clear();
|
||||
|
||||
Reference in New Issue
Block a user