3 #include "RenderContext.hpp"
5 #include "../config/BaseProxy.hpp"
6 #include "../input/InputEvent.hpp"
7 #include "../input/WindowEvent.hpp"
8 #include "../util/VectorCore.hpp"
23 enum class CursorMode : uint8_t {
42 Window(std::string title =
"Lumina Application",
138 GLFWwindow* m_window;
140 std::pair<std::int16_t, std::int16_t> m_version;
142 std::unique_ptr<RenderContext> m_renderContext;
143 std::vector<InputEvent> m_eventQueue;
144 std::vector<EventCallback> m_eventCallbacks;
145 std::vector<WindowEvent> m_windowEventQueue;
146 std::vector<WindowCallback> m_windowCallbacks;
147 float m_lastMouseX, m_lastMouseY;
149 CursorMode m_cursorMode;
155 static std::map<GLFWwindow*, Window*> s_eventReceiver;
157 static void resizeCallback(GLFWwindow* win,
int width,
int height);
158 static void keyCallback(GLFWwindow* win,
163 static void charCallback(GLFWwindow* win,
unsigned int key);
164 static void mouseButtonCallback(GLFWwindow* win,
168 static void mousePosCallback(GLFWwindow* w,
double xpos,
double ypos);
169 static void mouseScrollCallback(GLFWwindow* w,
double x,
double y);
170 static void windowCloseCallback(GLFWwindow* w);
175 #include "Window.tpp"
void open()
Opens the window.
Definition: Window.cpp:32
void close()
Closes window and free resources.
Definition: Window.cpp:108
WindowCallbackIndex addWindowCallback(WindowCallback &&callback)
Add a callback to process WindowEvents.
Definition: Window.tpp:28
void update()
check for events and window status.
Definition: Window.cpp:146
void pollEvents()
Check for new events.
Definition: Window.cpp:162
EventCallbackIndex addEventCallback(EventCallback &&callback)
Add a callback to process InputEvents.
Definition: Window.tpp:17
void setTitle(std::string title)
Changes the title of the window.
Definition: Window.cpp:126
Vec2i getSize()
Returns the current size of the window.
Definition: Window.cpp:140
Definition: SingleBase.hpp:19
void setVersionHint(int major, int minor=0)
Sets a hint which OpenGL version to use to create the context.
Definition: Window.tpp:13
void setVSync(bool enable)
Disables or enables VSync If VSync is enabled RenderContext::swapBuffers will be synchronized with th...
Definition: Window.cpp:91
bool isValid()
Returns if the window is valid.
Definition: Window.cpp:196
std::vector< WindowCallback >::size_type WindowCallbackIndex
Type for accessing a specific WindowCallback.
Definition: Window.hpp:56
Definition: RenderContext.hpp:19
Window(std::string title="Lumina Application", Vec2i size=Vec2i(600, 400))
Creates a new Window but does not open it.
Definition: Window.tpp:3
void removeWindowCallback(WindowCallbackIndex index)
Removes an WindowEvent callback with the index previously returned by addWindowCallback.
Definition: Window.tpp:34
void setCursorMode(CursorMode mode)
Sets the mode of the mouse cursor.
Definition: Window.cpp:95
void removeEventCallback(EventCallbackIndex index)
Removes an InputEvent callback with the index previously returned by addEventCallback.
Definition: Window.tpp:23
void resize(Vec2i size)
Resizes the window.
Definition: Window.cpp:133
A Window from which a RenderContext can be obtained.
Definition: Window.hpp:36
Definition: WindowEvent.hpp:16
std::vector< EventCallback >::size_type EventCallbackIndex
Type for accessing a specific EventCallback.
Definition: Window.hpp:50
RenderContext & getRenderContext()
Returns the OpenGL context for this window.
Definition: Window.cpp:25
std::function< EventResult(WindowEvent)> WindowCallback
Functor type for handling WindowEvents.
Definition: Window.hpp:53
std::function< EventResult(InputEvent)> EventCallback
Functor type for handling InputEvents.
Definition: Window.hpp:47