Documentation

This commit is contained in:
Pcornat 2026-01-10 16:13:38 +01:00
commit 7ce7fe4889
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD
4 changed files with 36 additions and 0 deletions

View file

@ -5,6 +5,9 @@
#include <string_view> #include <string_view>
namespace data { namespace data {
/*!
* \brief This interface is used by the window::Window class in its callbacks.
*/
class BasicData { class BasicData {
public: public:
virtual ~BasicData() noexcept = default; virtual ~BasicData() noexcept = default;

View file

@ -4,6 +4,9 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
namespace window { namespace window {
/*!
* \brief This class is a RAII object for GLFW library.
*/
class ContextWindow final { class ContextWindow final {
private: private:
bool init{ false }; bool init{ false };
@ -11,6 +14,10 @@ namespace window {
public: public:
ContextWindow() noexcept = delete; ContextWindow() noexcept = delete;
/*!
* \brief Constructor to initialize GLFW library
* \param error_clbk GLFW error callback. Can be null
*/
explicit ContextWindow(const GLFWerrorfun error_clbk) noexcept; explicit ContextWindow(const GLFWerrorfun error_clbk) noexcept;
~ContextWindow() noexcept; ~ContextWindow() noexcept;

View file

@ -10,6 +10,11 @@ namespace gui {
} }
namespace opengl { namespace opengl {
/*!
* \brief It takes a window object to get OpenGL context in current thread.
* \param win Window to use to init the GLEW context
* \return True: glew init, false: failed
*/
[[nodiscard]] bool init_glew(const gui::Window &win) noexcept; [[nodiscard]] bool init_glew(const gui::Window &win) noexcept;
} }

View file

@ -30,8 +30,10 @@ namespace gui {
static void window_pos_callback(GLFWwindow *window, int xpos, int ypos); static void window_pos_callback(GLFWwindow *window, int xpos, int ypos);
//! RAII window.
std::unique_ptr<GLFWwindow, decltype(&glfwDestroyWindow)> wwindow{ nullptr, glfwDestroyWindow }; std::unique_ptr<GLFWwindow, decltype(&glfwDestroyWindow)> wwindow{ nullptr, glfwDestroyWindow };
//! Modules used in callbacks.
modulesType modules; modulesType modules;
explicit Window(const bool debugOpengl, explicit Window(const bool debugOpengl,
@ -46,6 +48,14 @@ namespace gui {
Window(Window &&window) noexcept; 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<Window> create_window( [[nodiscard]] static std::optional<Window> create_window(
GLFWframebuffersizefun framebufferCallback, GLFWframebuffersizefun framebufferCallback,
const bool debugOpengl, const bool debugOpengl,
@ -74,10 +84,21 @@ namespace gui {
Window &operator=(Window other) noexcept; 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; 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; [[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; void opengl_debug() noexcept;
} }