|
1 | 1 | #pragma once |
2 | 2 |
|
| 3 | +#include "inexor/vulkan-renderer/input/keyboard_mouse_data.hpp" |
3 | 4 | #include "inexor/vulkan-renderer/renderer.hpp" |
4 | 5 |
|
5 | 6 | #include <GLFW/glfw3.h> |
|
10 | 11 | #include <string> |
11 | 12 | #include <vector> |
12 | 13 |
|
| 14 | +// forward declarations |
| 15 | +namespace inexor::vulkan_renderer::input { |
| 16 | +class KeyboardMouseInputData; |
| 17 | +} |
| 18 | + |
13 | 19 | namespace inexor::vulkan_renderer { |
14 | 20 |
|
15 | 21 | class Application : public VulkanRenderer { |
16 | 22 | std::string m_application_name; |
17 | 23 | std::string m_engine_name; |
18 | 24 |
|
19 | | - std::uint32_t m_application_version{}; |
20 | | - std::uint32_t m_engine_version{}; |
| 25 | + std::uint32_t m_application_version; |
| 26 | + std::uint32_t m_engine_version; |
21 | 27 |
|
22 | 28 | std::vector<std::string> m_vertex_shader_files; |
23 | 29 | std::vector<std::string> m_fragment_shader_files; |
24 | 30 | std::vector<std::string> m_texture_files; |
25 | 31 | std::vector<std::string> m_shader_files; |
26 | 32 | std::vector<std::string> m_gltf_model_files; |
27 | 33 |
|
| 34 | + std::unique_ptr<input::KeyboardMouseInputData> m_input_data; |
| 35 | + |
28 | 36 | /// @brief Load the configuration of the renderer from a TOML configuration file. |
29 | 37 | /// @brief file_name The TOML configuration file. |
30 | 38 | /// @note It was collectively decided not to use JSON for configuration files. |
31 | 39 | void load_toml_configuration_file(const std::string &file_name); |
32 | 40 | void load_textures(); |
33 | 41 | void load_shaders(); |
34 | 42 | void load_octree_geometry(); |
| 43 | + void setup_window_and_input_callbacks(); |
35 | 44 | void update_imgui_overlay(); |
36 | 45 | void check_application_specific_features(); |
37 | 46 | void update_uniform_buffers(); |
38 | | - void update_mouse_input(); |
39 | | - |
40 | | - // TODO: Refactor! |
41 | | - double m_cursor_x, m_cursor_y; |
| 47 | + void process_mouse_input(); |
| 48 | + // TODO: Implement a method for processing keyboard input. |
42 | 49 |
|
43 | 50 | public: |
44 | 51 | Application(int argc, char **argv); |
45 | 52 |
|
| 53 | + /// @brief Call glfwSetFramebufferSizeCallback. |
| 54 | + /// @param window The window whose framebuffer was resized. |
| 55 | + /// @param width The new width, in pixels, of the framebuffer. |
| 56 | + /// @param height The new height, in pixels, of the framebuffer. |
| 57 | + void frame_buffer_resize_callback(GLFWwindow *window, int width, int height); |
| 58 | + |
| 59 | + /// @brief Call glfwSetKeyCallback. |
| 60 | + /// @param window The window that received the event. |
| 61 | + /// @param key The keyboard key that was pressed or released. |
| 62 | + /// @param scancode The system-specific scancode of the key. |
| 63 | + /// @param action GLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT. |
| 64 | + /// @param mods Bit field describing which modifier keys were held down. |
| 65 | + void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods); |
| 66 | + |
| 67 | + /// @brief Call glfwSetCursorPosCallback. |
| 68 | + /// @param window The window that received the event. |
| 69 | + /// @param xpos The new x-coordinate, in screen coordinates, of the cursor. |
| 70 | + /// @param ypos The new y-coordinate, in screen coordinates, of the cursor. |
| 71 | + void cursor_position_callback(GLFWwindow *window, double xpos, double ypos); |
| 72 | + |
| 73 | + /// @brief Call glfwSetMouseButtonCallback. |
| 74 | + /// @param window The window that received the event. |
| 75 | + /// @param button The mouse button that was pressed or released. |
| 76 | + /// @param action One of GLFW_PRESS or GLFW_RELEASE. |
| 77 | + /// @param mods Bit field describing which modifier keys were held down. |
| 78 | + void mouse_button_callback(GLFWwindow *window, int button, int action, int mods); |
| 79 | + |
46 | 80 | void run(); |
47 | 81 | }; |
48 | 82 |
|
|
0 commit comments