GLW
Computer Graphics Structures library
glw::Window Class Reference

Implements GLFW functions in object style programming. More...

Inheritance diagram for glw::Window:
[legend]

Data Structures

struct  InitParameters
 Parameters used to initialize Window. More...
 

Public Member Functions

 Window (const InitParameters &params)
 
void ObserverRegister (WindowEventObserver *object, const uint8_t priority=glw::Window::max_observer_priority)
 
void ObserverRemove (WindowEventObserver *object)
 Unregisters observer for window callback events.
 
bool IsVisible () const
 
bool IsMaximized () const
 
bool IsIconified () const
 
bool IsFullscreen ()
 
bool IsInitialized ()
 
bool ShouldClose ()
 
void SetShouldClose ()
 
bool IsContextShared ()
 
GLFWwindow * GetWindowPtr ()
 Returns pointer to raw GLFW window.
 
glm::vec2 GetMousePosition () const
 Returns position of mouse, relative to the window position.
 
glm::ivec2 GetPosition () const
 Returns screen position of window client area.
 
glm::uvec2 GetResolution () const
 Returns resolution of window rendering buffer.
 
uint32_t GetWidth () const
 Returns width of window rendering buffer.
 
uint32_t GetHeight () const
 Returns height of window rendering buffer.
 
glm::vec2 GetContentScaling () const
 The content scale is the ratio between the current DPI and the platform's default DPI. More...
 
glm::uvec2 GetUnscaledResolution () const
 Window resolution modulated by a content scaling factor.
 
void SetWindowedMode (int width, int height, int posx=0, int posy=0)
 
void SetFullscreenMode ()
 
void PollEvents ()
 
void SwapBuffers ()
 
void SetContextConditional ()
 
void UnsetContextConditional ()
 

Static Public Attributes

static constexpr uint8_t max_observer_priority = 15u
 

Protected Member Functions

bool Initialize (const InitParameters &init)
 
- Protected Member Functions inherited from glw::WindowEventObserver
virtual void OnMouseMove (double xpos, double ypos)
 
virtual void OnMouseDown (int button, int mods)
 
virtual void OnMouseUp (int button, int mods)
 
virtual void OnMouseWheel (double xoffset, double yoffset)
 
virtual void OnCharacter (char codepoint)
 
virtual void OnKeyDown (int key, int mods, bool is_repeat)
 
virtual void OnKeyUp (int key, int mods)
 
virtual void OnTouch (unsigned int num_of_contacts, unsigned int *id, double *xpos, double *ypos, double *cwidth, double *cheight)
 
virtual void OnTouchGestBegin ()
 
virtual void OnTouchGestEnd ()
 
virtual void OnTouchGestZoom (double distance, double xpos, double ypos)
 
virtual void OnTouchGestPan (double distance, double xpos, double ypos)
 
virtual void OnWindowMove (int xpos, int ypos)
 
virtual void OnWindowRefresh ()
 
virtual void OnWindowResize (int width, int height)
 
virtual void OnContentScale (float xscale, float yscale)
 
virtual void OnFramebufferResize (int width, int height)
 
virtual void OnWindowIconify (int is_iconified)
 
virtual void OnWindowFocus (int is_focused)
 
virtual void OnWindowClose ()
 
virtual void OnFilesDropped (const std::vector< std::string > &files)
 

Detailed Description

Implements GLFW functions in object style programming.

Member Function Documentation

◆ GetContentScaling()

glm::vec2 glw::Window::GetContentScaling ( ) const

The content scale is the ratio between the current DPI and the platform's default DPI.

The content scale may depend on both the monitor resolution and pixel density and on user settings. It may be very different from the raw DPI calculated from the physical size and current resolution.

On systems where each monitors can have its own content scale, the window content scale will depend on which monitor the system considers the window to be on.

◆ Initialize()

bool glw::Window::Initialize ( const InitParameters &  init)
protected

Window initialization procedure. When creating derived class, this method needs to be called at some point in window creation!

◆ ObserverRegister()

void glw::Window::ObserverRegister ( WindowEventObserver *  object,
const uint8_t  priority = glw::Window::max_observer_priority 
)

Registers observer for window callback events. Priority parameter sets ordering update - the lower number = the sooner notified