Separate files between include and src
This commit is contained in:
parent
9fd87798e2
commit
ac620fb3b7
4 changed files with 3 additions and 3 deletions
89
include/window.hpp
Normal file
89
include/window.hpp
Normal file
|
@ -0,0 +1,89 @@
|
|||
#ifndef POC2DMODULAR_WINDOW_HPP
|
||||
#define POC2DMODULAR_WINDOW_HPP
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace data {
|
||||
class BasicData;
|
||||
}
|
||||
|
||||
namespace gui {
|
||||
class Window final {
|
||||
public:
|
||||
using modulesType = std::unordered_map<std::string, data::BasicData *>;
|
||||
using windowPtr = GLFWwindow *;
|
||||
|
||||
private:
|
||||
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods);
|
||||
|
||||
static void cursor_position_callback(GLFWwindow *window, double xpos, double ypos);
|
||||
|
||||
static void scroll_callback(GLFWwindow *window, double xoffset, double yoffset);
|
||||
|
||||
static void window_size_callback(GLFWwindow *window, int width, int height);
|
||||
|
||||
static void window_pos_callback(GLFWwindow *window, int xpos, int ypos);
|
||||
|
||||
static void delete_glfw_window(GLFWwindow *glfWwindow) {
|
||||
glfwDestroyWindow(glfWwindow);
|
||||
glfwTerminate();
|
||||
}
|
||||
|
||||
static std::uint_fast8_t count_instance;
|
||||
|
||||
std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> wwindow{ nullptr, delete_glfw_window };
|
||||
|
||||
modulesType modules;
|
||||
|
||||
explicit Window(const bool debugOpengl,
|
||||
const GLFWframebuffersizefun framebufferCallback,
|
||||
GLFWwindow *shared,
|
||||
std::initializer_list<modulesType::value_type> initializer);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static bool init_glfw(GLFWerrorfun errorCallback) noexcept;
|
||||
|
||||
Window() noexcept = delete;
|
||||
|
||||
Window(Window &&window) noexcept = default;
|
||||
|
||||
[[nodiscard]] friend std::optional<Window> create_window(
|
||||
const GLFWerrorfun errorCallback,
|
||||
GLFWframebuffersizefun framebufferCallback,
|
||||
const bool debugOpengl,
|
||||
GLFWwindow *shared,
|
||||
std::initializer_list<Window::modulesType::value_type> initializer) noexcept;
|
||||
|
||||
~Window() noexcept;
|
||||
|
||||
[[nodiscard]] const std::unique_ptr<GLFWwindow, decltype(&delete_glfw_window)> &get_window() const noexcept;
|
||||
|
||||
[[nodiscard]] bool should_close() const noexcept;
|
||||
|
||||
void swap_buffers() const noexcept;
|
||||
|
||||
void add_module(data::BasicData &module);
|
||||
|
||||
void delete_module(const std::string &module);
|
||||
|
||||
/**
|
||||
* \brief Make window's OpenGL context current
|
||||
*/
|
||||
void get_context() const noexcept;
|
||||
|
||||
Window &operator=(Window &&other) noexcept = default;
|
||||
};
|
||||
|
||||
void color_10_bits() noexcept;
|
||||
|
||||
bool check_color_depth(int color_depth) noexcept;
|
||||
|
||||
void opengl_debug() noexcept;
|
||||
}
|
||||
|
||||
|
||||
#endif //POC2DMODULAR_WINDOW_HPP
|
Loading…
Add table
Add a link
Reference in a new issue