11 #include <unordered_map> 14 #include <glm/glm.hpp> 16 #include <GLW/WindowEventObserver.h> 28 static constexpr uint8_t max_observer_priority = 15u;
34 glm::uvec2 resolution = glm::uvec2(640, 480);
36 glm::uvec2 min_resolution = glm::uvec2(0);
38 glm::uvec2 max_resolution = glm::uvec2(0);
40 bool maximized =
false;
42 std::string caption =
"GLW Window";
44 int8_t aa_samples = 8;
48 bool try_share_contexts =
true;
50 bool resizable =
true;
52 glm::ivec2 position = glm::ivec2(100);
54 bool fullscreen =
false;
56 bool hidden_cursor =
false;
66 void ObserverRegister(
WindowEventObserver *
object,
const uint8_t priority = glw::Window::max_observer_priority);
70 [[nodiscard]]
bool IsVisible()
const;
71 [[nodiscard]]
bool IsMaximized()
const;
72 [[nodiscard]]
bool IsIconified()
const;
73 [[nodiscard]]
bool IsFullscreen();
75 [[nodiscard]]
bool IsInitialized();
76 [[nodiscard]]
bool ShouldClose();
77 void SetShouldClose();
79 [[nodiscard]]
bool IsContextShared();
82 [[nodiscard]] GLFWwindow *GetWindowPtr();
85 [[nodiscard]] glm::vec2 GetMousePosition()
const;
87 [[nodiscard]] glm::ivec2 GetPosition()
const;
89 [[nodiscard]] glm::uvec2 GetResolution()
const;
91 [[nodiscard]] uint32_t GetWidth()
const;
93 [[nodiscard]] uint32_t GetHeight()
const;
106 [[nodiscard]] glm::vec2 GetContentScaling()
const;
109 [[nodiscard]] glm::uvec2 GetUnscaledResolution()
const;
111 void SetWindowedMode(
int width,
int height,
int posx = 0,
int posy = 0);
112 void SetFullscreenMode();
117 void SetContextConditional();
118 void UnsetContextConditional();
128 std::array < std::set<WindowEventObserver *>, glw::Window::max_observer_priority + 1 > obs_priority_lists_;
129 std::unordered_map<WindowEventObserver *, std::set<WindowEventObserver *>*> obs_iterator_for_ptr_;
131 GLFWwindow *window_ =
nullptr;
132 GLFWwindow *shared_window_ =
nullptr;
134 glm::uvec2 resolution_;
135 glm::ivec2 position_;
136 glm::vec2 mouse_position_;
138 bool is_initialized_ =
false;
140 bool is_fullscreen_ =
false;
143 void RegisterCallbacks();
145 static void CursorPosCallback(GLFWwindow *window,
double xpos,
double ypos);
146 static void MouseButtonCallback(GLFWwindow *window,
int button,
int action,
int mods);
147 static void ScrollCallback(GLFWwindow *window,
double xoffset,
double yoffset);
148 static void CharCallback(GLFWwindow *window,
unsigned int codepoint);
149 static void KeyCallback(GLFWwindow *window,
int key,
int scancode,
int action,
int mods);
150 static void TouchCallback(GLFWwindow *window,
unsigned int num_of_contacts,
unsigned int *
id,
double *xpos,
double *ypos,
double *cwidth,
double *cheight);
151 static void TouchGestBeginCallback(GLFWwindow *window);
152 static void TouchGestEndCallback(GLFWwindow *window);
153 static void TouchGestZoomCallback(GLFWwindow *window,
double distance,
double xpos,
double ypos);
154 static void TouchGestPanCallback(GLFWwindow *window,
double distance,
double xpos,
double ypos);
155 static void FramebufferResizeCallback(GLFWwindow *window,
int xpos,
int ypos);
156 static void WindowMoveCallback(GLFWwindow *window,
int xpos,
int ypos);
157 static void WindowRefreshCallback(GLFWwindow *window);
158 static void WindowResizeCallback(GLFWwindow *window,
int xpos,
int ypos);
159 static void WindowFocusCallback(GLFWwindow *window,
int is_focused);
160 static void WindowCloseCallback(GLFWwindow *window);
161 static void WindowIconifyCallback(GLFWwindow *window,
int is_iconified);
162 static void FilesDropCallback(GLFWwindow *window, int32_t file_count,
const char **files);
163 static void WindowContentScaleCallback(GLFWwindow *window,
float xscale,
float yscale);
172 std::unique_ptr<Window> window_;
OpenGL wrapper library namespace. Provides simplified interface for using OpenGL features.
Definition: API.h:17
Any class derived from WindowEventObserver can receive Window events.
Definition: WindowEventObserver.h:14
Parameters used to initialize Window.
Definition: Window.h:31
Implements GLFW functions in object style programming.
Definition: Window.h:24