diff options
Diffstat (limited to 'include/mbgl/platform/default')
-rw-r--r-- | include/mbgl/platform/default/glfw_view.hpp | 48 | ||||
-rw-r--r-- | include/mbgl/platform/default/glx.h | 2 | ||||
-rw-r--r-- | include/mbgl/platform/default/headless_display.hpp | 25 | ||||
-rw-r--r-- | include/mbgl/platform/default/headless_view.hpp | 65 | ||||
-rw-r--r-- | include/mbgl/platform/default/log_stderr.hpp | 21 | ||||
-rw-r--r-- | include/mbgl/platform/default/settings_json.hpp | 24 |
6 files changed, 185 insertions, 0 deletions
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp new file mode 100644 index 0000000000..6e91c1125e --- /dev/null +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -0,0 +1,48 @@ +#ifndef MBGL_COMMON_GLFW_VIEW +#define MBGL_COMMON_GLFW_VIEW + +#include <mbgl/mbgl.hpp> +#include <mbgl/util/time.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); + void swap(); + void make_active(); + void make_inactive(); + void notify(); + void notify_map_change(mbgl::MapChange change, mbgl::timestamp delay = 0); + + 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; +}; + +#endif diff --git a/include/mbgl/platform/default/glx.h b/include/mbgl/platform/default/glx.h new file mode 100644 index 0000000000..6b7d9a3df9 --- /dev/null +++ b/include/mbgl/platform/default/glx.h @@ -0,0 +1,2 @@ +#include <GL/glx.h> +#undef None diff --git a/include/mbgl/platform/default/headless_display.hpp b/include/mbgl/platform/default/headless_display.hpp new file mode 100644 index 0000000000..5b33fd6990 --- /dev/null +++ b/include/mbgl/platform/default/headless_display.hpp @@ -0,0 +1,25 @@ +#ifndef MBGL_COMMON_HEADLESS_DISPLAY +#define MBGL_COMMON_HEADLESS_DISPLAY + +#include "headless_view.hpp" + +namespace mbgl { + +class HeadlessDisplay { +public: + HeadlessDisplay(); + ~HeadlessDisplay(); + +#if MBGL_USE_CGL + CGLPixelFormatObj pixelFormat; +#endif + +#if MBGL_USE_GLX + Display *x_display = nullptr; + GLXFBConfig *fb_configs = nullptr; +#endif +}; + +} + +#endif diff --git a/include/mbgl/platform/default/headless_view.hpp b/include/mbgl/platform/default/headless_view.hpp new file mode 100644 index 0000000000..c0baddb884 --- /dev/null +++ b/include/mbgl/platform/default/headless_view.hpp @@ -0,0 +1,65 @@ +#ifndef MBGL_COMMON_HEADLESS_VIEW +#define MBGL_COMMON_HEADLESS_VIEW + +#ifdef __APPLE__ +#define MBGL_USE_CGL 1 +#else +#define GL_GLEXT_PROTOTYPES +#include <GL/glx.h> +#define MBGL_USE_GLX 1 +#endif + +#include <mbgl/map/view.hpp> +#include <mbgl/platform/gl.hpp> + +#include <memory> + +namespace mbgl { + +class HeadlessDisplay; + +class HeadlessView : public View { +public: + HeadlessView(); + HeadlessView(std::shared_ptr<HeadlessDisplay> display); + ~HeadlessView(); + + void createContext(); + + void resize(uint16_t width, uint16_t height, float pixelRatio); + const std::unique_ptr<uint32_t[]> readPixels(); + + void notify(); + void notify_map_change(MapChange change, timestamp delay = 0); + void make_active(); + void make_inactive(); + void swap(); + +private: + void clear_buffers(); + +private: + std::shared_ptr<HeadlessDisplay> display_; + uint16_t width_; + uint16_t height_; + float pixelRatio_; + +#if MBGL_USE_CGL + CGLContextObj gl_context; +#endif + +#if MBGL_USE_GLX + Display *x_display = nullptr; + GLXFBConfig *fb_configs = nullptr; + GLXContext gl_context = 0; + GLXPbuffer glx_pbuffer = 0; +#endif + + GLuint fbo = 0; + GLuint fbo_depth_stencil = 0; + GLuint fbo_color = 0; +}; + +} + +#endif diff --git a/include/mbgl/platform/default/log_stderr.hpp b/include/mbgl/platform/default/log_stderr.hpp new file mode 100644 index 0000000000..45f76f0d1a --- /dev/null +++ b/include/mbgl/platform/default/log_stderr.hpp @@ -0,0 +1,21 @@ +#ifndef MBGL_COMMON_STDERR_LOG +#define MBGL_COMMON_STDERR_LOG + +#include <mbgl/platform/log.hpp> + +namespace mbgl { + +class StderrLogBackend : public LogBackend { +public: + inline ~StderrLogBackend() = default; + + void record(EventSeverity severity, Event event, const std::string &msg); + void record(EventSeverity severity, Event event, const char* format, ...); + void record(EventSeverity severity, Event event, int64_t code); + void record(EventSeverity severity, Event event, int64_t code, const std::string &msg); +}; + + +} + +#endif diff --git a/include/mbgl/platform/default/settings_json.hpp b/include/mbgl/platform/default/settings_json.hpp new file mode 100644 index 0000000000..25c2179ba0 --- /dev/null +++ b/include/mbgl/platform/default/settings_json.hpp @@ -0,0 +1,24 @@ +#ifndef MBGL_JSON_SETTINGS +#define MBGL_JSON_SETTINGS + +namespace mbgl { + +class Settings_JSON { +public: + Settings_JSON(); + void load(); + void save(); + void clear(); + +public: + double longitude = 0; + double latitude = 0; + double zoom = 0; + double bearing = 0; + + bool debug = false; +}; + +} + +#endif |