summaryrefslogtreecommitdiff
path: root/common/glfw_view.hpp
blob: 5dbb64efb286ef6249f9f8395fee773b46fd751c (plain)
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
#ifndef LLMR_COMMON_GLFW_VIEW
#define LLMR_COMMON_GLFW_VIEW

#include <llmr/llmr.hpp>
#include <GLFW/glfw3.h>
#include <uv.h>

class MapView {
public:
    MapView(llmr::Settings &settings, bool fullscreen = false);
    ~MapView();

    void init();

    static void key(GLFWwindow *window, int key, int scancode, int action, int mods);
    static void scroll(GLFWwindow *window, double xoffset, double yoffset);
    static void resize(GLFWwindow *window, int, int);
    static void mouseclick(GLFWwindow *window, int button, int action, int modifiers);
    static void mousemove(GLFWwindow *window, double x, double y);

    static void eventloop(void *arg);

    int run();
    void fps();

public:
    bool fullscreen = false;

    double last_x = 0, last_y = 0;
    bool tracking = false;

    bool rotating = false;

    double last_click = -1;

    GLFWwindow *window = nullptr;
    llmr::Settings &settings;
    llmr::Map map;

    uv_loop_t *loop = nullptr;
};

#endif