1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#ifndef MBGL_COMMON_GLFW_VIEW
#define MBGL_COMMON_GLFW_VIEW
#include <mbgl/mbgl.hpp>
#ifdef NVIDIA
#define GLFW_INCLUDE_ES2
#endif
#include <GLFW/glfw3.h>
class GLFWView : public mbgl::View {
public:
GLFWView(bool fullscreen = false);
~GLFWView();
void initialize(mbgl::Map *map) override;
void activate() override;
void deactivate() override;
void notify() override;
void invalidate(std::function<void()> render) override;
static void onKey(GLFWwindow *window, int key, int scancode, int action, int mods);
static void onScroll(GLFWwindow *window, double xoffset, double yoffset);
static void onResize(GLFWwindow *window, int width, int height);
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 run();
void fps();
GLFWwindow *window = nullptr;
private:
bool fullscreen = false;
double lastX = 0, lastY = 0;
bool tracking = false;
bool rotating = false;
double lastClick = -1;
std::function<void()> changeStyleCallback;
};
#endif
|