Add size limits and aspect ratio functions

Fixes #555.
This commit is contained in:
Camilla Berglund
2014-02-13 02:57:59 +01:00
parent 8e062afdd8
commit d84772d620
13 changed files with 399 additions and 13 deletions

View File

@@ -4,6 +4,11 @@
@section news_32 New features in 3.2
@subsection news_32_sizelimits Window size limit support
GLFW now supports setting both absolute and relative window size limits with
@ref glfwSetWindowSizeLimits and @ref glfwSetWindowAspectRatio.
@section news_31 New features in 3.1

View File

@@ -485,6 +485,45 @@ The size of a framebuffer may change independently of the size of a window, for
example if the window is dragged between a regular monitor and a high-DPI one.
@subsection window_sizelimits Window size limits
The minimum and maximum size of the client area of a windowed mode window can be
set with @ref glfwSetWindowSizeLimits. The user may resize the window to any
size and aspect ratio within the specified limits, unless the aspect ratio is
also set.
@code
glfwSetWindowSizeLimits(window, 200, 200, 400, 400);
@endcode
To disable size limits for a window, set them to `GLFW_DONT_CARE`.
@code
glfwSetWindowSizeLimits(window, GLFW_DONT_CARE, GLFW_DONT_CARE, GLFW_DONT_CARE, GLFW_DONT_CARE);
@endcode
The aspect ratio of the client area of a windowed mode window can be set with
@ref glfwSetWindowAspectRatio. The user may resize the window freely unless
size limits are also set, but the size will be constrained to maintain the
aspect ratio.
The aspect ratio is specified as a numerator and denominator, corresponding to
the width and height, respectively.
@code
glfwSetWindowAspectRatio(window, 16, 9);
@endcode
To disable aspect ratio for a window, set it to `GLFW_DONT_CARE`.
@code
glfwSetWindowAspectRatio(window, GLFW_DONT_CARE, GLFW_DONT_CARE);
@endcode
You can have both size limits and aspect ratio set for a window, but the results
are undefined if they conflict.
@subsection window_pos Window position
The position of a windowed-mode window can be changed with @ref