![]() |
Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
|
#include <Window.hpp>
Public Member Functions | |
mat4 const & | getProjection () const |
vec2 const & | getCursor () const |
vec2 const & | getCursorDelta () const |
vec2 const & | getSize () const |
bool | isCursorInWindow () const |
vec2 | getClippedCursor () const |
Window (Application *app) | |
~Window () | |
void | swapBuffers () |
bool | doEvents () |
bool | keyDown (int key) |
bool | mouseDown (int key) |
void | update (double time, double timeDelta) |
void | close () |
bool const | hasProjChanged () const |
void | updatePointerPosition (vec2 pos) |
Protected Member Functions | |
void | onWindowSizeChanged (bool initialization=false) |
void | onKeyStateChanged (int key, bool pressed) |
Protected Attributes | |
Application * | m_app |
GLFWwindow * | m_window |
vec2 | m_size |
vec2 | m_cursor |
vec2 | m_cursorDelta |
mat4 | m_projection |
bool | m_cursorInit |
vector< bool > | m_hasProjChanged |
Friends | |
void | glfwOnWindowSizeChanged (GLFWwindow *window, int width, int height) |
void | glfwOnCursorMove (GLFWwindow *window, double x, double y) |
void | glfwOnKeyStateChanged (GLFWwindow *window, int key, int scancode, int action, int mods) |
The application window-object. Should only be instanced once. Provides simple access to input-events/-states. Hosts the projection-matrix.
Definition at line 13 of file Window.hpp.
Window | ( | Application * | app | ) |
Constructs a window-object. Size/resolution, window-title and wheter or not to run in fullscreen is read from the config-file. Uses GLFW to open a window. Initializes OpenGL (version 3.3 core).
If compiled in debug, a debug-context is created and - if available - the debug-callbacks are used.
app | The global Application |
Definition at line 84 of file Window.cpp.
~Window | ( | ) |
Destructs the window-object
Definition at line 161 of file Window.cpp.
void close | ( | ) |
Tells the window to close the next iteration of the main-loop.
Definition at line 252 of file Window.cpp.
bool doEvents | ( | ) |
Polls and handles all GLFW-events. Updates the cursor position in visual space.
Definition at line 213 of file Window.cpp.
|
inline |
Returns the cursor position after it was clipped to the window
Definition at line 55 of file Window.hpp.
|
inline |
An accessor for the cursor position of the window
Definition at line 35 of file Window.hpp.
|
inline |
An accessor for the cursor position delta of the window
Definition at line 40 of file Window.hpp.
|
inline |
An accessor for the projection matrix of the window
Definition at line 30 of file Window.hpp.
|
inline |
An accessor for the window-size of the window
Definition at line 45 of file Window.hpp.
|
inline |
Returns a bool indicating wheter the projection-matrix has changed or not.
Definition at line 152 of file Window.hpp.
|
inline |
A bool indicating wheter or not the cursor is in the window
Definition at line 50 of file Window.hpp.
bool keyDown | ( | int | key | ) |
Returns a bool that indicates wheter the passed key is down or not.
key | The requested key (GLFW-enum) |
Definition at line 243 of file Window.cpp.
bool mouseDown | ( | int | key | ) |
Returns a bool that indicates wheter the passed mouse-button is down or not.
key | The requested mouse-button (GLFW-enum) |
Definition at line 247 of file Window.cpp.
|
protected |
Callback if a key-state has changed
key | the key |
pressed | true if the key was pressed, else false |
Definition at line 197 of file Window.cpp.
|
protected |
Callback if the window-size has hanged
initialization | if the window is still in construction this paramter is true |
Definition at line 175 of file Window.cpp.
void swapBuffers | ( | ) |
Swaps front- and backbuffer
Definition at line 209 of file Window.cpp.
void update | ( | double | time, |
double | timeDelta | ||
) |
Updates the window. Actually does nothing else but to provide information about wheter the projection matrix has changed or not.
time | The absolute frame time - ignored |
timeDelta | The time since the last frame - ignored |
Definition at line 258 of file Window.cpp.
void updatePointerPosition | ( | vec2 | pos | ) |
Sets the cursor to the specified position (in visual space)
Definition at line 264 of file Window.cpp.
|
friend |
GLFW-callback for cursor-moves
window | the window |
x | the new cursor x-coordinate |
y | the new cursor y-coordinate |
Definition at line 202 of file Window.cpp.
|
friend |
GLFW-callback for key-state-changes
window | the window |
key | the key |
scancode | scancodes |
action | GLFW_PRESS if it was pressed, GLFW_RELEASE if it was released |
mods | modifiers |
Definition at line 192 of file Window.cpp.
|
friend |
GLFW-callback for window-size-changes
window | the window |
width | the new window-widht |
height | the new window-height |
Definition at line 169 of file Window.cpp.
|
protected |
The global application
Definition at line 16 of file Window.hpp.
|
protected |
The current cursor-position
Definition at line 19 of file Window.hpp.
|
protected |
The cursor-position-delta since the last frame in motor space
Definition at line 20 of file Window.hpp.
|
protected |
A bool indicating wheter the cursor-position was initialized or not
Definition at line 22 of file Window.hpp.
|
protected |
A queue storing the state of the projection-matrix (has it changed?) for the last 2 frames
Definition at line 23 of file Window.hpp.
|
protected |
The projection-matrix
Definition at line 21 of file Window.hpp.
|
protected |
The window-size
Definition at line 18 of file Window.hpp.
|
protected |
The GLFW-window-object
Definition at line 17 of file Window.hpp.