summaryrefslogtreecommitdiff
path: root/include/mbgl/platform/default/glfw_view.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/platform/default/glfw_view.hpp')
-rw-r--r--include/mbgl/platform/default/glfw_view.hpp34
1 files changed, 21 insertions, 13 deletions
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp
index 8662a90bf3..a115d03d7f 100644
--- a/include/mbgl/platform/default/glfw_view.hpp
+++ b/include/mbgl/platform/default/glfw_view.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mbgl/mbgl.hpp>
+#include <mbgl/map/backend.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/timer.hpp>
#include <mbgl/util/geometry.hpp>
@@ -11,20 +12,36 @@
#define GL_GLEXT_PROTOTYPES
#include <GLFW/glfw3.h>
-class GLFWView : public mbgl::View {
+class GLFWView : public mbgl::View, public mbgl::Backend {
public:
GLFWView(bool fullscreen = false, bool benchmark = false);
~GLFWView() override;
- float getPixelRatio() const override;
+ float getPixelRatio() const;
+
+ // Callback called when the user presses the key mapped to style change.
+ // The expected action is to set a new style, different to the current one.
+ void setChangeStyleCallback(std::function<void()> callback);
+
+ void setShouldClose();
+
+ void setWindowTitle(const std::string&);
+
+ void run();
+
+private:
+ // mbgl::View implementation
+ void initialize(mbgl::Map*) override;
+ void bind() override;
std::array<uint16_t, 2> getSize() const override;
std::array<uint16_t, 2> getFramebufferSize() const override;
- void initialize(mbgl::Map*) override;
+ // mbgl::Backend implementation
void activate() override;
void deactivate() override;
void invalidate() override;
+ // Window callbacks
static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods);
static void onScroll(GLFWwindow *window, double xoffset, double yoffset);
static void onWindowResize(GLFWwindow *window, int width, int height);
@@ -32,21 +49,12 @@ public:
static void onMouseClick(GLFWwindow *window, int button, int action, int modifiers);
static void onMouseMove(GLFWwindow *window, double x, double y);
- // Callback called when the user presses the key mapped to style change.
- // The expected action is to set a new style, different to the current one.
- void setChangeStyleCallback(std::function<void()> callback);
-
- void setShouldClose();
-
- void setWindowTitle(const std::string&);
-
- void run();
+ // Internal
void report(float duration);
void setMapChangeCallback(std::function<void(mbgl::MapChange)> callback);
void notifyMapChange(mbgl::MapChange change) override;
-private:
mbgl::Color makeRandomColor() const;
mbgl::Point<double> makeRandomPoint() const;
static std::shared_ptr<const mbgl::SpriteImage>