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
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Window Class Reference

#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

Applicationm_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)
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
appThe global Application

Definition at line 84 of file Window.cpp.

~Window ( )

Destructs the window-object

Definition at line 161 of file Window.cpp.

Member Function Documentation

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.

Returns
If this function returns false, the application was signaled to terminate.

Definition at line 213 of file Window.cpp.

vec2 getClippedCursor ( ) const
inline

Returns the cursor position after it was clipped to the window

Returns
the cursor position after it was clipped to the window

Definition at line 55 of file Window.hpp.

vec2 const& getCursor ( ) const
inline

An accessor for the cursor position of the window

Returns
A onst reference to the cursor position of the window

Definition at line 35 of file Window.hpp.

vec2 const& getCursorDelta ( ) const
inline

An accessor for the cursor position delta of the window

Returns
A onst reference to the cursor position delta of the window

Definition at line 40 of file Window.hpp.

mat4 const& getProjection ( ) const
inline

An accessor for the projection matrix of the window

Returns
A const reference to the projection matrix of the window

Definition at line 30 of file Window.hpp.

vec2 const& getSize ( ) const
inline

An accessor for the window-size of the window

Returns
A onst reference to the window-size of the window

Definition at line 45 of file Window.hpp.

bool const hasProjChanged ( ) const
inline

Returns a bool indicating wheter the projection-matrix has changed or not.

Returns
a bool indicating wheter the projection-matrix has changed or not.

Definition at line 152 of file Window.hpp.

bool isCursorInWindow ( ) const
inline

A bool indicating wheter or not the cursor is in the window

Returns
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.

Parameters
keyThe requested key (GLFW-enum)
Returns
a bool that indicates wheter the passed key is down or not

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.

Parameters
keyThe requested mouse-button (GLFW-enum)
Returns
a bool that indicates wheter the passed mouse-button is down or not

Definition at line 247 of file Window.cpp.

void onKeyStateChanged ( int  key,
bool  pressed 
)
protected

Callback if a key-state has changed

Parameters
keythe key
pressedtrue if the key was pressed, else false

Definition at line 197 of file Window.cpp.

void onWindowSizeChanged ( bool  initialization = false)
protected

Callback if the window-size has hanged

Parameters
initializationif 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.

Parameters
timeThe absolute frame time - ignored
timeDeltaThe 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.

Friends And Related Function Documentation

void glfwOnCursorMove ( GLFWwindow *  window,
double  x,
double  y 
)
friend

GLFW-callback for cursor-moves

Parameters
windowthe window
xthe new cursor x-coordinate
ythe new cursor y-coordinate

Definition at line 202 of file Window.cpp.

void glfwOnKeyStateChanged ( GLFWwindow *  window,
int  key,
int  scancode,
int  action,
int  mods 
)
friend

GLFW-callback for key-state-changes

Parameters
windowthe window
keythe key
scancodescancodes
actionGLFW_PRESS if it was pressed, GLFW_RELEASE if it was released
modsmodifiers

Definition at line 192 of file Window.cpp.

void glfwOnWindowSizeChanged ( GLFWwindow *  window,
int  width,
int  height 
)
friend

GLFW-callback for window-size-changes

Parameters
windowthe window
widththe new window-widht
heightthe new window-height

Definition at line 169 of file Window.cpp.

Member Data Documentation

Application* m_app
protected

The global application

Definition at line 16 of file Window.hpp.

vec2 m_cursor
protected

The current cursor-position

Definition at line 19 of file Window.hpp.

vec2 m_cursorDelta
protected

The cursor-position-delta since the last frame in motor space

Definition at line 20 of file Window.hpp.

bool m_cursorInit
protected

A bool indicating wheter the cursor-position was initialized or not

Definition at line 22 of file Window.hpp.

vector<bool> m_hasProjChanged
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.

mat4 m_projection
protected

The projection-matrix

Definition at line 21 of file Window.hpp.

vec2 m_size
protected

The window-size

Definition at line 18 of file Window.hpp.

GLFWwindow* m_window
protected

The GLFW-window-object

Definition at line 17 of file Window.hpp.


The documentation for this class was generated from the following files: