#ifndef POC2DMODULAR_WINDOW_HPP #define POC2DMODULAR_WINDOW_HPP #include #include #include #include #include namespace data { class BasicData; } namespace gui { class Window final { public: using modulesType = std::unordered_map; using windowPtr = GLFWwindow *; static constexpr int default_width{ 1280 }; static constexpr int default_height{ 720 }; 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); //! RAII window. std::unique_ptr wwindow{ nullptr, glfwDestroyWindow }; //! Modules used in callbacks. modulesType modules; explicit Window(const bool debugOpengl, const GLFWframebuffersizefun framebufferCallback, GLFWwindow *shared, std::initializer_list initializer); public: Window() noexcept = delete; Window(const Window &) = delete; Window(Window &&window) noexcept; /*! * \brief * \param [in] framebufferCallback Self-explicit * \param [in] debugOpengl Boolean to choose if it activates OpenGL's debug mode * \param [in] shared Another window pointer that shares the OpenGL's context * \param [in] initializer To initialize Window::modules * \return Optional containing a Window object if it was successful. */ [[nodiscard]] static std::optional create_window( GLFWframebuffersizefun framebufferCallback, const bool debugOpengl, GLFWwindow *shared, std::initializer_list initializer) noexcept; ~Window() noexcept = default; [[nodiscard]] const std::unique_ptr &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=(const Window &) = delete; Window &operator=(Window other) noexcept; }; /*! * \brief It has to be used **before** creating a Window to put color channels on 10 bits resolution. */ void color_10_bits() noexcept; /*! * \brief It is used to check the color depth for OpenGL's context. * \param color_depth The color depth to check. Most of the time, 10 or 8 bits. * \return True: color depth is the input one, else it is not. */ [[nodiscard]] bool check_color_depth(int color_depth) noexcept; /*! * \brief It can be used to activate OpenGL's debug mode before creating a window. */ void opengl_debug() noexcept; } #endif //POC2DMODULAR_WINDOW_HPP