Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Window.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Util.hpp"
4 
5 class Application;
6 
13 class Window
14 {
15  protected:
17  GLFWwindow* m_window;
18  vec2 m_size;
19  vec2 m_cursor;
21  mat4 m_projection;
22  bool m_cursorInit;
23  vector<bool>m_hasProjChanged;
25  public:
30  mat4 const & getProjection() const { return m_projection; }
35  vec2 const & getCursor() const { return m_cursor; }
40  vec2 const & getCursorDelta() const { return m_cursorDelta; }
45  vec2 const & getSize() const { return m_size; }
50  bool isCursorInWindow() const { return m_cursor.x >= 0 && m_cursor.y >= 0 && m_cursor.x < m_size.x && m_cursor.y < m_size.y; }
55  vec2 getClippedCursor() const { return vec2(glm::clamp(m_cursor.x, 0.0f, m_size.x), glm::clamp(m_cursor.y, 0.0f, m_size.y)); }
56 
57  protected:
64  friend void glfwOnWindowSizeChanged(GLFWwindow * window, int width, int height);
71  friend void glfwOnCursorMove(GLFWwindow * window, double x, double y);
80  friend void glfwOnKeyStateChanged(GLFWwindow * window, int key, int scancode, int action, int mods);
81 
86  void onWindowSizeChanged(bool initialization = false);
92  void onKeyStateChanged(int key, bool pressed);
93 
94  public:
105  Window(Application* app);
109  ~Window();
110 
114  void swapBuffers();
115 
121  bool doEvents();
122 
128  bool keyDown(int key);
134  bool mouseDown(int key);
135 
141  void update(double time, double timeDelta);
142 
146  void close();
147 
152  bool const hasProjChanged() const { return m_hasProjChanged[0]; }
153 
157  void updatePointerPosition(vec2 pos);
158 };
void close()
Definition: Window.cpp:252
Application * m_app
Definition: Window.hpp:16
vector< bool > m_hasProjChanged
Definition: Window.hpp:23
GLFWwindow * m_window
Definition: Window.hpp:17
bool keyDown(int key)
Definition: Window.cpp:243
vec2 m_cursor
Definition: Window.hpp:19
void onWindowSizeChanged(bool initialization=false)
Definition: Window.cpp:175
bool isCursorInWindow() const
Definition: Window.hpp:50
Window(Application *app)
Definition: Window.cpp:84
friend void glfwOnKeyStateChanged(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: Window.cpp:192
mat4 const & getProjection() const
Definition: Window.hpp:30
vec2 const & getCursorDelta() const
Definition: Window.hpp:40
void swapBuffers()
Definition: Window.cpp:209
vec2 getClippedCursor() const
Definition: Window.hpp:55
bool doEvents()
Definition: Window.cpp:213
void updatePointerPosition(vec2 pos)
Definition: Window.cpp:264
void update(double time, double timeDelta)
Definition: Window.cpp:258
vec2 m_cursorDelta
Definition: Window.hpp:20
bool mouseDown(int key)
Definition: Window.cpp:247
vec2 const & getCursor() const
Definition: Window.hpp:35
bool m_cursorInit
Definition: Window.hpp:22
void onKeyStateChanged(int key, bool pressed)
Definition: Window.cpp:197
bool const hasProjChanged() const
Definition: Window.hpp:152
vec2 const & getSize() const
Definition: Window.hpp:45
mat4 m_projection
Definition: Window.hpp:21
friend void glfwOnWindowSizeChanged(GLFWwindow *window, int width, int height)
Definition: Window.cpp:169
~Window()
Definition: Window.cpp:161
friend void glfwOnCursorMove(GLFWwindow *window, double x, double y)
Definition: Window.cpp:202
vec2 m_size
Definition: Window.hpp:18