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.
|
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...
|
|
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.
|
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
-
wndSize | The size of the window. |
desktopSize | The size of the desktop area the window will be placed in. |
hpos | The desired horizontal position of the window, relative to the desktop. |
vpos | The desired vertical position of the window, relative to the desktop. |
- Returns
- The position of the top-left coordinate of the window.