Unofficial OpenGL Software Development Kit  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Enumerations | Functions
Window Positioning

Helper function for positioning a window, based on the desktop size and the window's size.

Note
GLFW lacks the ability to get the window's actual size. The size you get back is always the size of the client area, not the whole window. As such, if you use this function to anchor the window to the right or bottom of the desktop, the window will be partially off-screen.

Enumerations

enum  glutil::HorizWindowPos { glutil::WH_CENTER, glutil::WH_LEFT, glutil::WH_RIGHT }
 Horizontal window positions. More...
 
enum  glutil::VertWindowPos { glutil::WV_CENTER, glutil::WV_TOP, glutil::WV_BOTTOM }
 Vertical window positions. More...
 

Functions

glm::ivec2 glutil::CalcWindowPosition (const glm::ivec2 &wndSize, const glm::ivec2 &desktopSize, HorizWindowPos hpos=WH_CENTER, VertWindowPos vpos=WV_CENTER)
 Compute the position of the window relative to the desktop area. More...
 

Enumeration Type Documentation

Horizontal window positions.

Enumerator
WH_CENTER 

Horizontally position the window in the center of the screen.

WH_LEFT 

Horizontally position the window on the left edge of the screen.

WH_RIGHT 

Horizontally position the window on the right edge of the screen.

Vertical window positions.

Enumerator
WV_CENTER 

Vertically position the window in the center of the screen.

WV_TOP 

Vertically position the window on the top edge of the screen.

WV_BOTTOM 

Vertically position the window on the bottom edge of the screen.

Function Documentation

glm::ivec2 glutil::CalcWindowPosition ( const glm::ivec2 &  wndSize,
const glm::ivec2 &  desktopSize,
HorizWindowPos  hpos = WH_CENTER,
VertWindowPos  vpos = WV_CENTER 
)

Compute the position of the window relative to the desktop area.

This function can be used to center a window or place it along the edges of the desktop.

Parameters
wndSizeThe size of the window.
desktopSizeThe size of the desktop area the window will be placed in.
hposThe desired horizontal position of the window, relative to the desktop.
vposThe desired vertical position of the window, relative to the desktop.
Returns
The position of the top-left coordinate of the window.