aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mglpp/graphics/Texture.hpp11
-rw-r--r--include/mglpp/mglpp.hpp12
-rw-r--r--include/mglpp/system/vec.hpp4
-rw-r--r--include/mglpp/window/Event.hpp12
-rw-r--r--include/mglpp/window/Keyboard.hpp30
-rw-r--r--include/mglpp/window/Window.hpp13
6 files changed, 72 insertions, 10 deletions
diff --git a/include/mglpp/graphics/Texture.hpp b/include/mglpp/graphics/Texture.hpp
index 1ea040e..6ab1fb4 100644
--- a/include/mglpp/graphics/Texture.hpp
+++ b/include/mglpp/graphics/Texture.hpp
@@ -14,24 +14,25 @@ namespace mgl {
struct LoadOptions {
bool compressed = false;
bool pixel_coordinates = false;
- bool mipmap = false; /* available since opengl 3.0 */
+ mgl_texture_scale_type scale_type = MGL_TEXTURE_SCALE_LINEAR;
};
struct ReferenceOptions {
bool pixel_coordinates = false;
+ mgl_texture_scale_type scale_type = MGL_TEXTURE_SCALE_LINEAR;
};
Texture();
- Texture(unsigned int gl_texture_id, mgl_texture_format format, const ReferenceOptions reference_options = {false});
+ Texture(unsigned int gl_texture_id, mgl_texture_format format, const ReferenceOptions reference_options = {false, MGL_TEXTURE_SCALE_LINEAR});
Texture(Texture &&other);
Texture& operator=(Texture &&other);
~Texture();
static Texture reference(mgl_texture ref);
- bool load_from_file(const char *filepath, const LoadOptions load_options = {false, false, false});
- bool load_from_image(Image &image, const LoadOptions load_options = {false, false, false});
- bool load_from_memory(const unsigned char *data, int width, int height, mgl_image_format format, LoadOptions load_options = {false, false, false});
+ bool load_from_file(const char *filepath, const LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
+ bool load_from_image(Image &image, const LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
+ bool load_from_memory(const unsigned char *data, int width, int height, mgl_image_format format, LoadOptions load_options = {false, false, MGL_TEXTURE_SCALE_LINEAR});
void clear();
vec2i get_size() const;
bool is_valid() const;
diff --git a/include/mglpp/mglpp.hpp b/include/mglpp/mglpp.hpp
index 2e49da5..730ddf5 100644
--- a/include/mglpp/mglpp.hpp
+++ b/include/mglpp/mglpp.hpp
@@ -1,9 +1,15 @@
#ifndef MGLPP_MGLPP_HPP
#define MGLPP_MGLPP_HPP
-#include <stdexcept>
+#include <exception>
namespace mgl {
+ enum class WindowSystem {
+ NATIVE, // Use X11 on X11 and Wayland on Wayland
+ X11, // Use X11 on X11 and XWayland on Wayland
+ WAYLAND, // Use Wayland. If user runs on X11 then it fails to connect
+ };
+
class InitException : public std::exception {
public:
const char* what() const noexcept override {
@@ -13,8 +19,8 @@ namespace mgl {
class Init {
public:
- // Throws InitException on failure
- Init();
+ // Throws InitException on failure.
+ Init(WindowSystem window_system = WindowSystem::X11);
~Init();
bool is_connected_to_display_server();
diff --git a/include/mglpp/system/vec.hpp b/include/mglpp/system/vec.hpp
index 23ef935..d424f42 100644
--- a/include/mglpp/system/vec.hpp
+++ b/include/mglpp/system/vec.hpp
@@ -61,6 +61,10 @@ namespace mgl {
return { static_cast<float>(x), static_cast<float>(y) };
}
+ vec2<int> to_vec2i() const {
+ return { static_cast<int>(x), static_cast<int>(y) };
+ }
+
vec2<T> floor() const {
return { static_cast<T>(static_cast<int>(x)), static_cast<T>(static_cast<int>(y)) };
}
diff --git a/include/mglpp/window/Event.hpp b/include/mglpp/window/Event.hpp
index bcd1e91..35b83a4 100644
--- a/include/mglpp/window/Event.hpp
+++ b/include/mglpp/window/Event.hpp
@@ -63,6 +63,16 @@ namespace mgl {
int id;
};
+ enum class MappingChangedType : int {
+ MODIFIER,
+ KEYBOARD,
+ POINTER
+ };
+
+ struct MappingChangedEvent {
+ MappingChangedType type;
+ };
+
enum Type : int {
Unknown,
Closed, /* Window closed */
@@ -79,6 +89,7 @@ namespace mgl {
MonitorConnected,
MonitorDisconnected,
MonitorPropertyChanged,
+ MappingChanged
};
Type type;
@@ -93,6 +104,7 @@ namespace mgl {
MonitorConnectedEvent monitor_connected;
MonitorDisconnectedEvent monitor_disconnected;
MonitorPropertyChangedEvent monitor_property_changed;
+ MappingChangedEvent mapping_changed;
};
};
}
diff --git a/include/mglpp/window/Keyboard.hpp b/include/mglpp/window/Keyboard.hpp
index 17c4d7c..2cb6c0a 100644
--- a/include/mglpp/window/Keyboard.hpp
+++ b/include/mglpp/window/Keyboard.hpp
@@ -1,6 +1,8 @@
#ifndef MGLPP_KEYBOARD_HPP
#define MGLPP_KEYBOARD_HPP
+#include <stdint.h>
+
namespace mgl {
class Keyboard {
public:
@@ -108,10 +110,38 @@ namespace mgl {
F14,
F15,
Pause,
+ Printscreen,
+ NumpadEnter,
+ AudioLowerVolume,
+ AudioRaiseVolume,
+ AudioPlay,
+ AudioStop,
+ AudioPause,
+ AudioMute,
+ AudioPrev,
+ AudioNext,
+ AudioRewind,
+ AudioForward,
+ DeadAcute,
+ Apostrophe,
+ F16,
+ F17,
+ F18,
+ F19,
+ F20,
+ F21,
+ F22,
+ F23,
+ F24,
/* This should always be the last key */
__NumKeys__
};
+
+ /* Returns nullptr if unknown key */
+ static const char* key_to_string(Key key);
+ static bool key_is_modifier(Key key);
+ static uint64_t key_to_x11_keysym(Key key);
};
}
diff --git a/include/mglpp/window/Window.hpp b/include/mglpp/window/Window.hpp
index 2c179a8..8458d71 100644
--- a/include/mglpp/window/Window.hpp
+++ b/include/mglpp/window/Window.hpp
@@ -27,6 +27,11 @@ namespace mgl {
vec2i size;
};
+ struct Scissor {
+ vec2i position;
+ vec2i size;
+ };
+
/*
Return true to continue. |get_clipboard| returns false if this returns false.
Note: |size| is the size of the current data, not the total data (if the callback only contains a part of the data).
@@ -46,11 +51,11 @@ namespace mgl {
bool override_redirect = false;
bool support_alpha = false; /* support alpha for the window */
bool hide_decorations = false; /* this is a hint, it may be ignored by the window manager */
- Color background_color = {0, 0, 0, 0};
+ Color background_color = {0, 0, 0, 255};
const char *class_name = nullptr;
mgl_window_type window_type = MGL_WINDOW_TYPE_NORMAL;
WindowHandle transient_for_window = 0; /* 0 = none */
- mgl_render_api render_api = MGL_RENDER_API_GLX;
+ mgl_graphics_api graphics_api = MGL_GRAPHICS_API_EGL;
};
Window();
@@ -103,6 +108,9 @@ namespace mgl {
void set_view(const View &new_view);
View get_view();
+ void set_scissor(const Scissor &scissor);
+ Scissor get_scissor();
+
bool is_key_pressed(Keyboard::Key key) const;
bool is_mouse_button_pressed(Mouse::Button button) const;
@@ -115,6 +123,7 @@ namespace mgl {
mgl_window* internal_window();
private:
mgl_window window;
+ bool window_created = false;
};
}