Fireworks Engine  v2.0
Lightweight Sandbox Game Engine using OpenGL for additional Customisation and Quick Prototyping
fireworks::graphics::Window Class Reference

The class responsible for Window Creation. More...

#include <Window.h>

Public Member Functions

 Window (const char *title, int width, int height)
 Creates a Window by initializing GLFW. More...
 
 ~Window ()
 
void clear () const
 Clears the window screen blank. More...
 
void update () const
 Updates the window. More...
 
bool closed () const
 Indicates the current state of the Window. More...
 
int getWidth () const
 Gets the current width of the window. More...
 
int getHeight () const
 Gets the current height of the window. More...
 
GLFWwindow * getGLFWwindow () const
 Gets the current window's pointer to it's native object. More...
 
bool isKeyPressed (unsigned int keycode)
 Tells if a particular key on the keyboard was pressed or not. More...
 
bool isKeyReleased (unsigned int keycode)
 Tells if a particular key on the keyboard was released or not. More...
 
bool isKeyHeld (unsigned int keycode) const
 Tells if a particular key on the keyboard is being held or not. More...
 
bool isMouseButtonPressed (unsigned int button)
 Tells if a particular key on the Mouse button was pressed or not. More...
 
bool isMouseButtonReleased (unsigned int button)
 
bool isMouseButtonHeld (unsigned int button) const
 Tells if a particular key on the Mouse button is being held or not. More...
 
void getMousePosition (double &x, double &y) const
 Gets the current position of the mouse in Screen Space Coordinates. More...
 

Public Attributes

glm::vec4 backgroundColor
 The background color of the Window. More...
 
float deltaMouseX
 
float deltaMouseY
 

Friends

void key_callback (GLFWwindow *window, int key, int scancode, int action, int mods)
 A callback function called when the windows registers a key press from the Keyboard. More...
 
void window_resize_callback (GLFWwindow *window, int width, int height)
 A callback function called when the windows resizes. More...
 
void mouse_button_callback (GLFWwindow *window, int button, int action, int mods)
 A callback function called when the windows registers a button press from the Mouse. More...
 
void mouse_position_callback (GLFWwindow *window, double xpos, double ypos)
 A callback function called when the windows registers a change in the mouse position. More...
 

Detailed Description

The class responsible for Window Creation.

Use this to create a new winnow of type GLFWwindow and manage input from the user and set various properties of the window

Constructor & Destructor Documentation

◆ Window()

fireworks::graphics::Window::Window ( const char *  title,
int  width,
int  height 
)

Creates a Window by initializing GLFW.

Parameters
titleThe title of the window
widthThe width of the window
heightThe height of the window

◆ ~Window()

fireworks::graphics::Window::~Window ( )

Member Function Documentation

◆ clear()

void fireworks::graphics::Window::clear ( ) const

Clears the window screen blank.

Uses the data from the color, depth and stencil buffer bits to clear the window according the clearing rules

◆ closed()

bool fireworks::graphics::Window::closed ( ) const

Indicates the current state of the Window.

Returns
A bool indicating whether the window is closed or not

◆ getGLFWwindow()

GLFWwindow* fireworks::graphics::Window::getGLFWwindow ( ) const
inline

Gets the current window's pointer to it's native object.

Returns
A a pointer variable to the windows GLFWwindow object

◆ getHeight()

int fireworks::graphics::Window::getHeight ( ) const
inline

Gets the current height of the window.

Returns
An int denoting the current height of the graphics::Window

◆ getMousePosition()

void fireworks::graphics::Window::getMousePosition ( double &  x,
double &  y 
) const

Gets the current position of the mouse in Screen Space Coordinates.

Parameters
xA variable to the store the X coordinate of the mouse position
yA variable to the store the Y coordinate of the mouse position

◆ getWidth()

int fireworks::graphics::Window::getWidth ( ) const
inline

Gets the current width of the window.

Returns
An int denoting the current width of the graphics::Window

◆ isKeyHeld()

bool fireworks::graphics::Window::isKeyHeld ( unsigned int  keycode) const

Tells if a particular key on the keyboard is being held or not.

Note
returns true for the entire duration of the key press
Parameters
keycodeThe GLFW enum key code of the key to check it's status
Returns
A bool indicating whether the key was being held or not

◆ isKeyPressed()

bool fireworks::graphics::Window::isKeyPressed ( unsigned int  keycode)

Tells if a particular key on the keyboard was pressed or not.

Parameters
keycodeThe GLFW enum key code of the key to check it's status
Returns
A bool indicating whether the key was pressed or not

◆ isKeyReleased()

bool fireworks::graphics::Window::isKeyReleased ( unsigned int  keycode)

Tells if a particular key on the keyboard was released or not.

Parameters
keycodeThe GLFW enum key code of the key to check it's status
Returns
A bool indicating whether the key was released after being pressed or not

◆ isMouseButtonHeld()

bool fireworks::graphics::Window::isMouseButtonHeld ( unsigned int  button) const

Tells if a particular key on the Mouse button is being held or not.

Note
returns true for the entire duration of the button press
Parameters
keycodeThe GLFW enum button code of the key to check it's status
Returns
A bool indicating whether the button was being held or not

◆ isMouseButtonPressed()

bool fireworks::graphics::Window::isMouseButtonPressed ( unsigned int  button)

Tells if a particular key on the Mouse button was pressed or not.

Parameters
keycodeThe GLFW enum button code of the key to check it's status
Returns
A bool indicating whether the button was pressed or not

◆ isMouseButtonReleased()

bool fireworks::graphics::Window::isMouseButtonReleased ( unsigned int  button)

◆ update()

void fireworks::graphics::Window::update ( ) const

Updates the window.

Checks for OpenGL errors and swaps the buffers after poling for input events

Friends And Related Function Documentation

◆ key_callback

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

A callback function called when the windows registers a key press from the Keyboard.

Parameters
windowThe window that received the event
keyThe keyboard key that was pressed or released
scancodeThe system-specific scancode of the key
actionGLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT
modsBit field describing which modifier keys were held down

◆ mouse_button_callback

void mouse_button_callback ( GLFWwindow *  window,
int  button,
int  action,
int  mods 
)
friend

A callback function called when the windows registers a button press from the Mouse.

Parameters
windowThe window that received the event
buttonThe mouse button that was pressed or released
actionGLFW_PRESS, GLFW_RELEASE or GLFW_REPEAT
modsBit field describing which modifier keys were held down

◆ mouse_position_callback

void mouse_position_callback ( GLFWwindow *  window,
double  xpos,
double  ypos 
)
friend

A callback function called when the windows registers a change in the mouse position.

Parameters
windowThe window that received the event
xposThe new cursor x-coordinate, relative to the left edge of the content area
yposThe new cursor y-coordinate, relative to the top edge of the content area

◆ window_resize_callback

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

A callback function called when the windows resizes.

Parameters
windowThe window that received the event
widthThe new width of the window
heightThe new height of the window

Member Data Documentation

◆ backgroundColor

glm::vec4 fireworks::graphics::Window::backgroundColor

The background color of the Window.

Note
This sets the color in the GL_COLOR_BUFFER_BIT

◆ deltaMouseX

float fireworks::graphics::Window::deltaMouseX

◆ deltaMouseY

float fireworks::graphics::Window::deltaMouseY

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