diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp index 6556cae87..57cfd8f21 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/llmr/renderer/painter.hpp @@ -40,6 +40,8 @@ public: void renderLine(LineBucket& bucket, const std::string& layer_name, const Tile::ID& id); void renderPoint(PointBucket& bucket, const std::string& layer_name, const Tile::ID& id); + void resize(int width, int height); + void prepareClippingMask(); void drawClippingMask(const mat4& matrix, uint8_t clip_id); void finishClippingMask(); diff --git a/linux/main.cpp b/linux/main.cpp index a6814ab92..319dcf24b 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -1,8 +1,6 @@ #include #include #include -#include -#include #include "settings.hpp" #include "request.hpp" @@ -26,10 +24,24 @@ public: exit(1); } + GLFWmonitor *monitor = nullptr; + +#ifdef GL_ES_VERSION_2_0 + monitor = glfwGetPrimaryMonitor(); + + glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); +#endif + + glfwWindowHint(GLFW_RED_BITS, 8); + glfwWindowHint(GLFW_GREEN_BITS, 8); + glfwWindowHint(GLFW_BLUE_BITS, 8); + glfwWindowHint(GLFW_ALPHA_BITS, 8); glfwWindowHint(GLFW_STENCIL_BITS, 8); glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwCreateWindow(1024, 768, "llmr", NULL, NULL); + window = glfwCreateWindow(1024, 768, "llmr", monitor, NULL); if (!window) { glfwTerminate(); fprintf(stderr, "Failed to initialize window\n"); @@ -47,9 +59,9 @@ public: settings.load(); map.setup((double)fb_width / width); - resize(window, 0, 0); + settings.load(); - glfwSwapInterval(1); + resize(window, 0, 0); map.loadSettings(); @@ -60,7 +72,6 @@ public: glfwSetScrollCallback(window, scroll); glfwSetCharCallback(window, character); glfwSetKeyCallback(window, key); - } static void character(GLFWwindow *window, unsigned int codepoint) { diff --git a/src/map/map.cpp b/src/map/map.cpp index 48b7a844e..ebe10c76e 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -57,6 +57,7 @@ void Map::resize(uint32_t width, uint32_t height, uint32_t fb_width, uint32_t fb transform.fb_width = fb_width; transform.fb_height = fb_height; transform.pixelRatio = pixel_ratio; + painter.resize(fb_width, fb_height); update(); } diff --git a/src/renderer/painter.cpp b/src/renderer/painter.cpp index d521d22b5..ca8389c3c 100644 --- a/src/renderer/painter.cpp +++ b/src/renderer/painter.cpp @@ -63,6 +63,10 @@ void Painter::setupShaders() { pointShader = std::make_unique(); } +void Painter::resize(int width, int height) { + glViewport(0, 0, width, height); +} + void Painter::useProgram(uint32_t program) { if (gl_program != program) { glUseProgram(program);