aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-01-18 22:56:18 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-01-18 22:56:18 +0100
commit7c0d53684c638af98bece65edc7e744cae80806c (patch)
tree5736e296cbc15832b565f0143e059fa21bf79f7b /include
parent25125b2e23c02199bdefb3a638584465229fd833 (diff)
Event logic & handle resize & close for xcb windows
Diffstat (limited to 'include')
-rw-r--r--include/vk-renderer.hpp6
-rw-r--r--include/window.hpp37
2 files changed, 24 insertions, 19 deletions
diff --git a/include/vk-renderer.hpp b/include/vk-renderer.hpp
index a8c5d2b..aa51383 100644
--- a/include/vk-renderer.hpp
+++ b/include/vk-renderer.hpp
@@ -18,6 +18,8 @@ class vkrenderer {
void recreate_swapchain();
+ struct input_data* mapped_data;
+
private:
void create_instance();
@@ -43,7 +45,7 @@ class vkrenderer {
void create_input_buffer(const input_data& inputs);
- void destroy_swapchain();
+ void destroy_swapchain_images();
void select_physical_device();
@@ -88,8 +90,6 @@ class vkrenderer {
std::vector<VkImageView> swapchain_images_views;
uint32_t current_image_index;
- struct input_data* mapped_data;
-
window& wnd;
};
diff --git a/include/window.hpp b/include/window.hpp
index 3298d36..dae4f00 100644
--- a/include/window.hpp
+++ b/include/window.hpp
@@ -2,6 +2,7 @@
#define __WINDOW_HPP_
#include <cstdint>
+#include <vector>
#include "defines.hpp"
@@ -9,23 +10,20 @@ class vkrenderer;
#if defined(LINUX)
#include <xcb/xcb.h>
+#elif defined(WINDOWS)
+#include <Windows.h>
+#endif
-class window {
- public:
- window(uint32_t width, uint32_t height);
-
- void poll_events();
-
- xcb_connection_t* connection;
- xcb_window_t win;
-
- uint32_t width;
- uint32_t height;
+enum EVENT_TYPES: int32_t {
+ QUIT,
+ RESIZE,
+};
- bool isOpen;
+struct event {
+ uint32_t width;
+ uint32_t height;
+ EVENT_TYPES type;
};
-#elif defined(WINDOWS)
-#include <Windows.h>
class window {
public:
@@ -33,18 +31,25 @@ class window {
void poll_events();
+
+#if defined(WINDOWS)
LRESULT message_handler(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam);
static LRESULT CALLBACK window_procedure(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam);
HWND win_handle;
- vkrenderer* renderer = nullptr;
+#elif defined(LINUX)
+ xcb_connection_t* connection;
+ xcb_window_t win;
+ xcb_atom_t win_delete_atom;
+#endif
+
+ std::vector<event> events;
uint32_t width;
uint32_t height;
bool isOpen;
};
-#endif
#endif // !__WINDOW_HPP_