mirror of
https://github.com/glfw/glfw.git
synced 2025-10-05 06:06:36 +00:00
Merge branch 'master' of https://github.com/glfw/glfw
This commit is contained in:
commit
ae04c86c42
13
.travis.yml
13
.travis.yml
@ -50,12 +50,17 @@ matrix:
|
|||||||
- os: osx
|
- os: osx
|
||||||
env: BUILD_SHARED_LIBS=OFF
|
env: BUILD_SHARED_LIBS=OFF
|
||||||
script:
|
script:
|
||||||
|
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- if test -n "${USE_WAYLAND}"; then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb; fi
|
- if test -n "${USE_WAYLAND}";
|
||||||
- if test -n "${USE_WAYLAND}"; then sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb; fi
|
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
||||||
- if test -n "${USE_WAYLAND}"; then git clone git://anongit.freedesktop.org/wayland/wayland-protocols; fi
|
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
|
||||||
- if test -n "${USE_WAYLAND}"; then pushd wayland-protocols; ./autogen.sh --prefix=/usr; make -j; sudo make install; popd; fi
|
git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
|
||||||
|
pushd wayland-protocols;
|
||||||
|
git checkout 1.6 && ./autogen.sh --prefix=/usr && make && sudo make install;
|
||||||
|
popd;
|
||||||
|
fi
|
||||||
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} ..
|
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} -DGLFW_USE_WAYLAND=${USE_WAYLAND} ..
|
||||||
- cmake --build .
|
- cmake --build .
|
||||||
notifications:
|
notifications:
|
||||||
|
@ -278,7 +278,7 @@ if (_GLFW_WAYLAND)
|
|||||||
|
|
||||||
find_package(Wayland REQUIRED Client Cursor Egl)
|
find_package(Wayland REQUIRED Client Cursor Egl)
|
||||||
find_package(WaylandScanner REQUIRED)
|
find_package(WaylandScanner REQUIRED)
|
||||||
find_package(WaylandProtocols 1.1 REQUIRED)
|
find_package(WaylandProtocols 1.6 REQUIRED)
|
||||||
|
|
||||||
list(APPEND glfw_PKG_DEPS "wayland-egl")
|
list(APPEND glfw_PKG_DEPS "wayland-egl")
|
||||||
|
|
||||||
|
27
README.md
27
README.md
@ -136,8 +136,9 @@ information on what to include when reporting a bug.
|
|||||||
gamepad mapping (#900)
|
gamepad mapping (#900)
|
||||||
- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate`
|
- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate`
|
||||||
for retrieving gamepad input state (#900)
|
for retrieving gamepad input state (#900)
|
||||||
- Added `glfwGetWindowContentScale` and `glfwGetMonitorContentScale` for
|
- Added `glfwGetWindowContentScale`, `glfwGetMonitorContentScale` and
|
||||||
DPI-aware rendering (#235,#439,#677,#845,#898)
|
`glfwSetWindowContentScaleCallback` for DPI-aware rendering
|
||||||
|
(#235,#439,#677,#845,#898)
|
||||||
- Added `glfwRequestWindowAttention` function for requesting attention from the
|
- Added `glfwRequestWindowAttention` function for requesting attention from the
|
||||||
user (#732,#988)
|
user (#732,#988)
|
||||||
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent
|
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent
|
||||||
@ -147,30 +148,38 @@ information on what to include when reporting a bug.
|
|||||||
- Added `glfwSetWindowAttrib` function for changing window attributes (#537)
|
- Added `glfwSetWindowAttrib` function for changing window attributes (#537)
|
||||||
- Added `glfwGetJoystickHats` function for querying joystick hats
|
- Added `glfwGetJoystickHats` function for querying joystick hats
|
||||||
(#889,#906,#934)
|
(#889,#906,#934)
|
||||||
- Added `glfwInitHint` and `glfwInitHintString` for setting initialization hints
|
- Added `glfwInitHint` for setting initialization hints
|
||||||
|
- Added `glfwWindowHintString` for setting string type window hints (#893,#1139)
|
||||||
- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole
|
- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole
|
||||||
window transparency (#1089)
|
window transparency (#1089)
|
||||||
|
- Added `glfwSetMonitorUserPointer` and `glfwGetMonitorUserPointer` for
|
||||||
|
per-monitor user pointers
|
||||||
|
- Added `glfwSetJoystickUserPointer` and `glfwGetJoystickUserPointer` for
|
||||||
|
per-joystick user pointers
|
||||||
- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString`
|
- Added `glfwGetX11SelectionString` and `glfwSetX11SelectionString`
|
||||||
functions for accessing X11 primary selection (#894,#1056)
|
functions for accessing X11 primary selection (#894,#1056)
|
||||||
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
|
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
|
||||||
- Added definition of `GLAPIENTRY` to public header
|
- Added definition of `GLAPIENTRY` to public header
|
||||||
- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling
|
- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling
|
||||||
per-pixel framebuffer transparency (#197,#663,#715,#723,#1078)
|
per-pixel framebuffer transparency (#197,#663,#715,#723,#1078)
|
||||||
|
- Added `GLFW_HOVERED` window attribute for polling cursor hover state (#1166)
|
||||||
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
- Added `GLFW_CENTER_CURSOR` window hint for controlling cursor centering
|
||||||
(#749,#842)
|
(#749,#842)
|
||||||
- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889)
|
- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889)
|
||||||
|
- Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946)
|
||||||
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
|
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
|
||||||
- Added macOS specific `GLFW_COCOA_FRAME_AUTOSAVE` window hint (#195)
|
- Added macOS specific `GLFW_COCOA_FRAME_NAME` window hint (#195)
|
||||||
- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935)
|
- Added macOS specific `GLFW_COCOA_GRAPHICS_SWITCHING` window hint (#377,#935)
|
||||||
- Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
|
- Added macOS specific `GLFW_COCOA_CHDIR_RESOURCES` init hint
|
||||||
- Added macOS specific `GLFW_COCOA_MENUBAR` init hint
|
- Added macOS specific `GLFW_COCOA_MENUBAR` init hint
|
||||||
- Added X11 specific `GLFW_X11_WM_CLASS_NAME` and `GLFW_X11_WM_CLASS_CLASS` init
|
- Added X11 specific `GLFW_X11_CLASS_NAME` and `GLFW_X11_INSTANCE_NAME` window
|
||||||
hints (#893)
|
hints (#893,#1139)
|
||||||
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
|
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
|
||||||
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
|
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
|
||||||
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
|
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
|
||||||
- Added `GenerateMappings.cmake` script for updating gamepad mappings
|
- Added `GenerateMappings.cmake` script for updating gamepad mappings
|
||||||
- Deprecated window parameter of clipboard string functions
|
- Deprecated window parameter of clipboard string functions
|
||||||
|
- Deprecated charmods callback
|
||||||
- Removed `GLFW_USE_RETINA` compile-time option
|
- Removed `GLFW_USE_RETINA` compile-time option
|
||||||
- Removed `GLFW_USE_CHDIR` compile-time option
|
- Removed `GLFW_USE_CHDIR` compile-time option
|
||||||
- Removed `GLFW_USE_MENUBAR` compile-time option
|
- Removed `GLFW_USE_MENUBAR` compile-time option
|
||||||
@ -205,6 +214,9 @@ information on what to include when reporting a bug.
|
|||||||
- [Win32] Bugfix: Returned key names did not match other platforms (#943)
|
- [Win32] Bugfix: Returned key names did not match other platforms (#943)
|
||||||
- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899)
|
- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899)
|
||||||
- [Win32] Bugfix: Window was resized twice when entering full screen (#1085)
|
- [Win32] Bugfix: Window was resized twice when entering full screen (#1085)
|
||||||
|
- [Win32] Bugfix: The HID device notification was not unregistered (#1170)
|
||||||
|
- [Win32] Bugfix: `glfwCreateWindow` activated window even with `GLFW_FOCUSED`
|
||||||
|
hint set to false (#1179,#1180)
|
||||||
- [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125)
|
- [X11] Moved to XI2 `XI_RawMotion` for disable cursor mode motion input (#125)
|
||||||
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
|
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
|
||||||
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
|
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
|
||||||
@ -323,6 +335,8 @@ skills.
|
|||||||
- Mário Freitas
|
- Mário Freitas
|
||||||
- GeO4d
|
- GeO4d
|
||||||
- Marcus Geelnard
|
- Marcus Geelnard
|
||||||
|
- Stephen Gowen
|
||||||
|
- Kovid Goyal
|
||||||
- Eloi Marín Gratacós
|
- Eloi Marín Gratacós
|
||||||
- Stefan Gustavson
|
- Stefan Gustavson
|
||||||
- Jonathan Hale
|
- Jonathan Hale
|
||||||
@ -388,6 +402,7 @@ skills.
|
|||||||
- Keith Pitt
|
- Keith Pitt
|
||||||
- Stanislav Podgorskiy
|
- Stanislav Podgorskiy
|
||||||
- Alexandre Pretyman
|
- Alexandre Pretyman
|
||||||
|
- przemekmirek
|
||||||
- Philip Rideout
|
- Philip Rideout
|
||||||
- Eddie Ringle
|
- Eddie Ringle
|
||||||
- Jorge Rodriguez
|
- Jorge Rodriguez
|
||||||
|
555
deps/nuklear.h
vendored
555
deps/nuklear.h
vendored
File diff suppressed because it is too large
Load Diff
17
deps/nuklear_glfw_gl2.h
vendored
17
deps/nuklear_glfw_gl2.h
vendored
@ -75,6 +75,8 @@ static struct nk_glfw {
|
|||||||
int text_len;
|
int text_len;
|
||||||
struct nk_vec2 scroll;
|
struct nk_vec2 scroll;
|
||||||
double last_button_click;
|
double last_button_click;
|
||||||
|
int is_double_click_down;
|
||||||
|
struct nk_vec2 double_click_pos;
|
||||||
} glfw;
|
} glfw;
|
||||||
|
|
||||||
NK_INTERN void
|
NK_INTERN void
|
||||||
@ -219,10 +221,12 @@ nk_glfw3_mouse_button_callback(GLFWwindow* window, int button, int action, int m
|
|||||||
glfwGetCursorPos(window, &x, &y);
|
glfwGetCursorPos(window, &x, &y);
|
||||||
if (action == GLFW_PRESS) {
|
if (action == GLFW_PRESS) {
|
||||||
double dt = glfwGetTime() - glfw.last_button_click;
|
double dt = glfwGetTime() - glfw.last_button_click;
|
||||||
if (dt > NK_GLFW_DOUBLE_CLICK_LO && dt < NK_GLFW_DOUBLE_CLICK_HI)
|
if (dt > NK_GLFW_DOUBLE_CLICK_LO && dt < NK_GLFW_DOUBLE_CLICK_HI) {
|
||||||
nk_input_button(&glfw.ctx, NK_BUTTON_DOUBLE, (int)x, (int)y, nk_true);
|
glfw.is_double_click_down = nk_true;
|
||||||
|
glfw.double_click_pos = nk_vec2((float)x, (float)y);
|
||||||
|
}
|
||||||
glfw.last_button_click = glfwGetTime();
|
glfw.last_button_click = glfwGetTime();
|
||||||
} else nk_input_button(&glfw.ctx, NK_BUTTON_DOUBLE, (int)x, (int)y, nk_false);
|
} else glfw.is_double_click_down = nk_false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NK_INTERN void
|
NK_INTERN void
|
||||||
@ -261,6 +265,10 @@ nk_glfw3_init(GLFWwindow *win, enum nk_glfw_init_state init_state)
|
|||||||
glfw.ctx.clip.paste = nk_glfw3_clipbard_paste;
|
glfw.ctx.clip.paste = nk_glfw3_clipbard_paste;
|
||||||
glfw.ctx.clip.userdata = nk_handle_ptr(0);
|
glfw.ctx.clip.userdata = nk_handle_ptr(0);
|
||||||
nk_buffer_init_default(&glfw.ogl.cmds);
|
nk_buffer_init_default(&glfw.ogl.cmds);
|
||||||
|
|
||||||
|
glfw.is_double_click_down = nk_false;
|
||||||
|
glfw.double_click_pos = nk_vec2(0, 0);
|
||||||
|
|
||||||
return &glfw.ctx;
|
return &glfw.ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +352,7 @@ nk_glfw3_new_frame(void)
|
|||||||
glfwGetCursorPos(win, &x, &y);
|
glfwGetCursorPos(win, &x, &y);
|
||||||
nk_input_motion(ctx, (int)x, (int)y);
|
nk_input_motion(ctx, (int)x, (int)y);
|
||||||
if (ctx->input.mouse.grabbed) {
|
if (ctx->input.mouse.grabbed) {
|
||||||
glfwSetCursorPos(glfw.win, ctx->input.mouse.prev.x, ctx->input.mouse.prev.y);
|
glfwSetCursorPos(glfw.win, (double)ctx->input.mouse.prev.x, (double)ctx->input.mouse.prev.y);
|
||||||
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
ctx->input.mouse.pos.x = ctx->input.mouse.prev.x;
|
||||||
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
ctx->input.mouse.pos.y = ctx->input.mouse.prev.y;
|
||||||
}
|
}
|
||||||
@ -352,6 +360,7 @@ nk_glfw3_new_frame(void)
|
|||||||
nk_input_button(ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);
|
nk_input_button(ctx, NK_BUTTON_LEFT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS);
|
||||||
nk_input_button(ctx, NK_BUTTON_MIDDLE, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS);
|
nk_input_button(ctx, NK_BUTTON_MIDDLE, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS);
|
||||||
nk_input_button(ctx, NK_BUTTON_RIGHT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS);
|
nk_input_button(ctx, NK_BUTTON_RIGHT, (int)x, (int)y, glfwGetMouseButton(win, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS);
|
||||||
|
nk_input_button(ctx, NK_BUTTON_DOUBLE, (int)glfw.double_click_pos.x, (int)glfw.double_click_pos.y, glfw.is_double_click_down);
|
||||||
nk_input_scroll(ctx, glfw.scroll);
|
nk_input_scroll(ctx, glfw.scroll);
|
||||||
nk_input_end(&glfw.ctx);
|
nk_input_end(&glfw.ctx);
|
||||||
glfw.text_len = 0;
|
glfw.text_len = 0;
|
||||||
|
@ -170,6 +170,19 @@ When sticky keys mode is enabled, the pollable state of a key will remain
|
|||||||
it has been polled, if a key release event had been processed in the meantime,
|
it has been polled, if a key release event had been processed in the meantime,
|
||||||
the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.
|
the state will reset to `GLFW_RELEASE`, otherwise it will remain `GLFW_PRESS`.
|
||||||
|
|
||||||
|
@anchor GLFW_LOCK_KEY_MODS
|
||||||
|
If you wish to know what the state of the Caps Lock and Num Lock keys was when
|
||||||
|
input events were generated, set the `GLFW_LOCK_KEY_MODS` input mode.
|
||||||
|
|
||||||
|
@code
|
||||||
|
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, 1);
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
When this input mode is enabled, any callback that receives
|
||||||
|
[modifier bits](@ref mods) will have the @ref GLFW_MOD_CAPS_LOCK bit set if Caps
|
||||||
|
Lock was on when the event occurred and the @ref GLFW_MOD_NUM_LOCK bit set if
|
||||||
|
Num Lock was on.
|
||||||
|
|
||||||
The `GLFW_KEY_LAST` constant holds the highest value of any
|
The `GLFW_KEY_LAST` constant holds the highest value of any
|
||||||
[named key](@ref keys).
|
[named key](@ref keys).
|
||||||
|
|
||||||
@ -186,8 +199,7 @@ encode the code points into UTF-8 or any other encoding you prefer.
|
|||||||
Because an `unsigned int` is 32 bits long on all platforms supported by GLFW,
|
Because an `unsigned int` is 32 bits long on all platforms supported by GLFW,
|
||||||
you can treat the code point argument as native endian UTF-32.
|
you can treat the code point argument as native endian UTF-32.
|
||||||
|
|
||||||
There are two callbacks for receiving Unicode code points. If you wish to
|
If you wish to offer regular text input, set a character callback.
|
||||||
offer regular text input, set a character callback.
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
glfwSetCharCallback(window, character_callback);
|
glfwSetCharCallback(window, character_callback);
|
||||||
@ -203,23 +215,6 @@ void character_callback(GLFWwindow* window, unsigned int codepoint)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
If you also wish to receive those Unicode code points generated with modifier
|
|
||||||
key combinations that a plain text field would ignore, or want to know exactly
|
|
||||||
what modifier keys were used, set a character with modifiers callback.
|
|
||||||
|
|
||||||
@code
|
|
||||||
glfwSetCharModsCallback(window, charmods_callback);
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
The callback function receives Unicode code points and
|
|
||||||
[modifier bits](@ref mods).
|
|
||||||
|
|
||||||
@code
|
|
||||||
void charmods_callback(GLFWwindow* window, unsigned int codepoint, int mods)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@endcode
|
|
||||||
|
|
||||||
|
|
||||||
@subsection input_key_name Key names
|
@subsection input_key_name Key names
|
||||||
|
|
||||||
@ -424,6 +419,16 @@ void cursor_enter_callback(GLFWwindow* window, int entered)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
You can query whether the cursor is currently inside the client area of the
|
||||||
|
window with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute.
|
||||||
|
|
||||||
|
@code
|
||||||
|
if (glfwGetWindowAttrib(window, GLFW_HOVERED))
|
||||||
|
{
|
||||||
|
highlight_interface();
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection input_mouse_button Mouse button input
|
@subsection input_mouse_button Mouse button input
|
||||||
|
|
||||||
@ -516,6 +521,9 @@ present with @ref glfwJoystickPresent.
|
|||||||
int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
int present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
Each joystick has zero or more axes, zero or more buttons, zero or more hats,
|
||||||
|
a human-readable name, a user pointer and an SDL compatible GUID.
|
||||||
|
|
||||||
When GLFW is initialized, detected joysticks are added to to the beginning of
|
When GLFW is initialized, detected joysticks are added to to the beginning of
|
||||||
the array. Once a joystick is detected, it keeps its assigned ID until it is
|
the array. Once a joystick is detected, it keeps its assigned ID until it is
|
||||||
disconnected or the library is terminated, so as joysticks are connected and
|
disconnected or the library is terminated, so as joysticks are connected and
|
||||||
@ -618,6 +626,17 @@ and make may have the same name. Only the [joystick token](@ref joysticks) is
|
|||||||
guaranteed to be unique, and only until that joystick is disconnected.
|
guaranteed to be unique, and only until that joystick is disconnected.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection joystick_userptr Joystick user pointer
|
||||||
|
|
||||||
|
Each joystick has a user pointer that can be set with @ref
|
||||||
|
glfwSetJoystickUserPointer and queried with @ref glfwGetJoystickUserPointer.
|
||||||
|
This can be used for any purpose you need and will not be modified by GLFW. The
|
||||||
|
value will be kept until the joystick is disconnected or until the library is
|
||||||
|
terminated.
|
||||||
|
|
||||||
|
The initial value of the pointer is `NULL`.
|
||||||
|
|
||||||
|
|
||||||
@subsection joystick_event Joystick configuration changes
|
@subsection joystick_event Joystick configuration changes
|
||||||
|
|
||||||
If you wish to be notified when a joystick is connected or disconnected, set
|
If you wish to be notified when a joystick is connected or disconnected, set
|
||||||
@ -650,6 +669,10 @@ functions. Joystick disconnection may also be detected and the callback
|
|||||||
called by joystick functions. The function will then return whatever it
|
called by joystick functions. The function will then return whatever it
|
||||||
returns for a disconnected joystick.
|
returns for a disconnected joystick.
|
||||||
|
|
||||||
|
Only @ref glfwGetJoystickName and @ref glfwGetJoystickUserPointer will return
|
||||||
|
useful values for a disconnected joystick and only before the monitor callback
|
||||||
|
returns.
|
||||||
|
|
||||||
|
|
||||||
@subsection gamepad Gamepad input
|
@subsection gamepad Gamepad input
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ successfully initialized, and only from the main thread.
|
|||||||
- @ref glfwGetError
|
- @ref glfwGetError
|
||||||
- @ref glfwSetErrorCallback
|
- @ref glfwSetErrorCallback
|
||||||
- @ref glfwInitHint
|
- @ref glfwInitHint
|
||||||
- @ref glfwInitHintString
|
|
||||||
- @ref glfwInit
|
- @ref glfwInit
|
||||||
- @ref glfwTerminate
|
- @ref glfwTerminate
|
||||||
|
|
||||||
@ -67,8 +66,7 @@ settings and these might not be restored without termination.
|
|||||||
@subsection init_hints Initialization hints
|
@subsection init_hints Initialization hints
|
||||||
|
|
||||||
Initialization hints are set before @ref glfwInit and affect how the library
|
Initialization hints are set before @ref glfwInit and affect how the library
|
||||||
behaves until termination. Integer type hints are set with @ref glfwInitHint
|
behaves until termination. Hints are set with @ref glfwInitHint.
|
||||||
and string type hints with @ref glfwInitHintString.
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
|
glfwInitHint(GLFW_JOYSTICK_HAT_BUTTONS, GLFW_FALSE);
|
||||||
@ -104,15 +102,6 @@ a nib or manually, when the first window is created, which is when AppKit is
|
|||||||
initialized. Set this with @ref glfwInitHint.
|
initialized. Set this with @ref glfwInitHint.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection init_hints_x11 X11 specific init hints
|
|
||||||
|
|
||||||
@anchor GLFW_X11_WM_CLASS_NAME
|
|
||||||
@anchor GLFW_X11_WM_CLASS_CLASS
|
|
||||||
__GLFW_X11_WM_CLASS_NAME__ and __GLFW_X11_WM_CLASS_CLASS__ specifies the desired
|
|
||||||
ASCII encoded name and class parts of the ICCCM `WM_CLASS` hint for all windows.
|
|
||||||
Set this with @ref glfwInitHintString.
|
|
||||||
|
|
||||||
|
|
||||||
@subsubsection init_hints_values Supported and default values
|
@subsubsection init_hints_values Supported and default values
|
||||||
|
|
||||||
Initialization hint | Default value | Supported values
|
Initialization hint | Default value | Supported values
|
||||||
@ -120,8 +109,6 @@ Initialization hint | Default value | Supported values
|
|||||||
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_JOYSTICK_HAT_BUTTONS | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_CHDIR_RESOURCES | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
@ref GLFW_COCOA_MENUBAR | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
@ref GLFW_X11_WM_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` name
|
|
||||||
@ref GLFW_X11_WM_CLASS_CLASS | `""` | An ASCII encoded `WM_CLASS` class
|
|
||||||
|
|
||||||
|
|
||||||
@subsection intro_init_terminate Terminating GLFW
|
@subsection intro_init_terminate Terminating GLFW
|
||||||
|
@ -86,14 +86,16 @@ void monitor_callback(GLFWmonitor* monitor, int event)
|
|||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
If a monitor is disconnected, all windows that are full screen on it will be
|
If a monitor is disconnected, all windows that are full screen on it will be
|
||||||
switched to windowed mode.
|
switched to windowed mode before the callback is called. Only @ref
|
||||||
|
glfwGetMonitorName and @ref glfwGetMonitorUserPointer will return useful values
|
||||||
|
for a disconnected monitor and only before the monitor callback returns.
|
||||||
|
|
||||||
|
|
||||||
@section monitor_properties Monitor properties
|
@section monitor_properties Monitor properties
|
||||||
|
|
||||||
Each monitor has a current video mode, a list of supported video modes,
|
Each monitor has a current video mode, a list of supported video modes,
|
||||||
a virtual position, a human-readable name, an estimated physical size and
|
a virtual position, a human-readable name, a user pointer, an estimated physical
|
||||||
a gamma ramp.
|
size and a gamma ramp.
|
||||||
|
|
||||||
|
|
||||||
@subsection monitor_modes Video modes
|
@subsection monitor_modes Video modes
|
||||||
@ -187,6 +189,17 @@ and make may have the same name. Only the monitor handle is guaranteed to be
|
|||||||
unique, and only until that monitor is disconnected.
|
unique, and only until that monitor is disconnected.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection monitor_userptr User pointer
|
||||||
|
|
||||||
|
Each monitor has a user pointer that can be set with @ref
|
||||||
|
glfwSetMonitorUserPointer and queried with @ref glfwGetMonitorUserPointer. This
|
||||||
|
can be used for any purpose you need and will not be modified by GLFW. The
|
||||||
|
value will be kept until the monitor is disconnected or until the library is
|
||||||
|
terminated.
|
||||||
|
|
||||||
|
The initial value of the pointer is `NULL`.
|
||||||
|
|
||||||
|
|
||||||
@subsection monitor_gamma Gamma ramp
|
@subsection monitor_gamma Gamma ramp
|
||||||
|
|
||||||
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
|
The gamma ramp of a monitor can be set with @ref glfwSetGammaRamp, which accepts
|
||||||
|
@ -64,14 +64,16 @@ GLFW now supports querying the window and monitor content scale, i.e. the ratio
|
|||||||
between the current DPI and the platform's default DPI, with @ref
|
between the current DPI and the platform's default DPI, with @ref
|
||||||
glfwGetWindowContentScale and @ref glfwGetMonitorContentScale.
|
glfwGetWindowContentScale and @ref glfwGetMonitorContentScale.
|
||||||
|
|
||||||
|
Changes of the content scale of a window can be received with the window content
|
||||||
|
scale callback, set with @ref glfwSetWindowCloseCallback.
|
||||||
|
|
||||||
@see @ref window_scale
|
@see @ref window_scale
|
||||||
|
|
||||||
|
|
||||||
@subsection news_33_inithint Support for initialization hints
|
@subsection news_33_inithint Support for initialization hints
|
||||||
|
|
||||||
GLFW now supports setting library initialization hints with @ref glfwInitHint
|
GLFW now supports setting library initialization hints with @ref glfwInitHint.
|
||||||
or @ref glfwInitHintString. These must be set before initialization to take
|
These must be set before initialization to take effect.
|
||||||
effect.
|
|
||||||
|
|
||||||
@see @ref init_hints
|
@see @ref init_hints
|
||||||
|
|
||||||
@ -140,6 +142,13 @@ creation API, intended for automated testing. This backend does not provide
|
|||||||
input.
|
input.
|
||||||
|
|
||||||
|
|
||||||
|
@subsection news_33_userptr Monitor and joystick user pointers
|
||||||
|
|
||||||
|
GLFW now supports setting and querying user pointers for connected monitors and
|
||||||
|
joysticks with @ref glfwSetMonitorUserPointer, @ref glfwGetMonitorUserPointer,
|
||||||
|
@ref glfwSetJoystickUserPointer and @ref glfwGetJoystickUserPointer.
|
||||||
|
|
||||||
|
|
||||||
@subsection news_33_primary X11 primary selection access
|
@subsection news_33_primary X11 primary selection access
|
||||||
|
|
||||||
GLFW now supports querying and setting the X11 primary selection via the native
|
GLFW now supports querying and setting the X11 primary selection via the native
|
||||||
|
@ -146,16 +146,18 @@ is restored, but the gamma ramp is left untouched.
|
|||||||
There are a number of hints that can be set before the creation of a window and
|
There are a number of hints that can be set before the creation of a window and
|
||||||
context. Some affect the window itself, others affect the framebuffer or
|
context. Some affect the window itself, others affect the framebuffer or
|
||||||
context. These hints are set to their default values each time the library is
|
context. These hints are set to their default values each time the library is
|
||||||
initialized with @ref glfwInit, can be set individually with @ref glfwWindowHint
|
initialized with @ref glfwInit. Integer value hints can be set individually
|
||||||
and reset all at once to their defaults with @ref glfwDefaultWindowHints.
|
with @ref glfwWindowHint and string value hints with @ref glfwWindowHintString.
|
||||||
|
You can reset all at once to their defaults with @ref glfwDefaultWindowHints.
|
||||||
|
|
||||||
Some hints are platform specific. These are always valid to set on any
|
Some hints are platform specific. These are always valid to set on any
|
||||||
platform but they will only affect their specific platform. Other platforms
|
platform but they will only affect their specific platform. Other platforms
|
||||||
will ignore them. Setting these hints requires no platform specific headers or
|
will ignore them. Setting these hints requires no platform specific headers or
|
||||||
calls.
|
calls.
|
||||||
|
|
||||||
Note that hints need to be set _before_ the creation of the window and context
|
@note Window hints need to be set before the creation of the window and context
|
||||||
you wish to have the specified attributes.
|
you wish to have the specified attributes. They function as additional
|
||||||
|
arguments to @ref glfwCreateWindow.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_hard Hard and soft constraints
|
@subsubsection window_hints_hard Hard and soft constraints
|
||||||
@ -441,10 +443,10 @@ __GLFW_COCOA_RETINA_FRAMEBUFFER__ specifies whether to use full resolution
|
|||||||
framebuffers on Retina displays. Possible values are `GLFW_TRUE` and
|
framebuffers on Retina displays. Possible values are `GLFW_TRUE` and
|
||||||
`GLFW_FALSE`. This is ignored on other platforms.
|
`GLFW_FALSE`. This is ignored on other platforms.
|
||||||
|
|
||||||
@anchor GLFW_COCOA_FRAME_AUTOSAVE_hint
|
@anchor GLFW_COCOA_FRAME_NAME_hint
|
||||||
__GLFW_COCOA_FRAME_AUTOSAVE__ specifies whether to activate frame autosaving
|
__GLFW_COCOA_FRAME_NAME__ specifies the UTF-8 encoded name to use for autosaving
|
||||||
using the window title specified at window creation. Possible values are
|
the window frame, or if empty disables frame autosaving for the window. This is
|
||||||
`GLFW_TRUE` and `GLFW_FALSE`. This is ignored on other platforms.
|
ignored on other platforms. This is set with @ref glfwWindowHintString.
|
||||||
|
|
||||||
@anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint
|
@anchor GLFW_COCOA_GRAPHICS_SWITCHING_hint
|
||||||
__GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics
|
__GLFW_COCOA_GRAPHICS_SWITCHING__ specifies whether to in Automatic Graphics
|
||||||
@ -465,6 +467,15 @@ should also declare this in its `Info.plist` by setting the
|
|||||||
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
`NSSupportsAutomaticGraphicsSwitching` key to `true`.
|
||||||
|
|
||||||
|
|
||||||
|
@subsubsection window_hints_x11 X11 specific window hints
|
||||||
|
|
||||||
|
@anchor GLFW_X11_CLASS_NAME
|
||||||
|
@anchor GLFW_X11_INSTANCE_NAME
|
||||||
|
__GLFW_X11_CLASS_NAME__ and __GLFW_X11_INSTANCE_NAME__ specifies the desired
|
||||||
|
ASCII encoded class and instance parts of the ICCCM `WM_CLASS` window property.
|
||||||
|
These are set with @ref glfwWindowHintString.
|
||||||
|
|
||||||
|
|
||||||
@subsubsection window_hints_values Supported and default values
|
@subsubsection window_hints_values Supported and default values
|
||||||
|
|
||||||
Window hint | Default value | Supported values
|
Window hint | Default value | Supported values
|
||||||
@ -504,8 +515,10 @@ GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GL
|
|||||||
GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_OPENGL_DEBUG_CONTEXT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
GLFW_OPENGL_PROFILE | `GLFW_OPENGL_ANY_PROFILE` | `GLFW_OPENGL_ANY_PROFILE`, `GLFW_OPENGL_COMPAT_PROFILE` or `GLFW_OPENGL_CORE_PROFILE`
|
||||||
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_RETINA_FRAMEBUFFER | `GLFW_TRUE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
GLFW_COCOA_FRAME_AUTOSAVE | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_FRAME_NAME | `""` | A UTF-8 encoded frame autosave name
|
||||||
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
GLFW_COCOA_GRAPHICS_SWITCHING | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
|
||||||
|
GLFW_X11_CLASS_NAME | `""` | An ASCII encoded `WM_CLASS` class name
|
||||||
|
GLFW_X11_INSTANCE_NAME | `""` | An ASCII encoded `WM_CLASS` instance name
|
||||||
|
|
||||||
|
|
||||||
@section window_events Window event processing
|
@section window_events Window event processing
|
||||||
@ -518,7 +531,7 @@ See @ref events.
|
|||||||
@subsection window_userptr User pointer
|
@subsection window_userptr User pointer
|
||||||
|
|
||||||
Each window has a user pointer that can be set with @ref
|
Each window has a user pointer that can be set with @ref
|
||||||
glfwSetWindowUserPointer and fetched with @ref glfwGetWindowUserPointer. This
|
glfwSetWindowUserPointer and queried with @ref glfwGetWindowUserPointer. This
|
||||||
can be used for any purpose you need and will not be modified by GLFW throughout
|
can be used for any purpose you need and will not be modified by GLFW throughout
|
||||||
the life-time of the window.
|
the life-time of the window.
|
||||||
|
|
||||||
@ -682,6 +695,23 @@ 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
|
content scale will depend on which monitor the system considers the window to be
|
||||||
on.
|
on.
|
||||||
|
|
||||||
|
If you wish to be notified when the content scale of a window changes, whether
|
||||||
|
because of a system setting change or because it was moved to a monitor with
|
||||||
|
a different scale, set a content scale callback.
|
||||||
|
|
||||||
|
@code
|
||||||
|
glfwSetWindowContentScaleCallback(window, window_content_scale_callback);
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
The callback function receives the new content scale of the window.
|
||||||
|
|
||||||
|
@code
|
||||||
|
void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
|
||||||
|
{
|
||||||
|
set_interface_scale(xscale, yscale);
|
||||||
|
}
|
||||||
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@subsection window_sizelimits Window size limits
|
@subsection window_sizelimits Window size limits
|
||||||
|
|
||||||
@ -1190,6 +1220,11 @@ See @ref window_iconify for details.
|
|||||||
__GLFW_MAXIMIZED__ indicates whether the specified window is maximized. See
|
__GLFW_MAXIMIZED__ indicates whether the specified window is maximized. See
|
||||||
@ref window_maximize for details.
|
@ref window_maximize for details.
|
||||||
|
|
||||||
|
@anchor GLFW_HOVERED_attrib
|
||||||
|
__GLFW_HOVERED__ indicates whether the cursor is currently directly over the
|
||||||
|
client area of the window, with no other windows between. See @ref cursor_enter
|
||||||
|
for details.
|
||||||
|
|
||||||
@anchor GLFW_VISIBLE_attrib
|
@anchor GLFW_VISIBLE_attrib
|
||||||
__GLFW_VISIBLE__ indicates whether the specified window is visible. See @ref
|
__GLFW_VISIBLE__ indicates whether the specified window is visible. See @ref
|
||||||
window_hide for details.
|
window_hide for details.
|
||||||
|
@ -493,17 +493,37 @@ extern "C" {
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
/*! @brief If this bit is set one or more Shift keys were held down.
|
/*! @brief If this bit is set one or more Shift keys were held down.
|
||||||
|
*
|
||||||
|
* If this bit is set one or more Shift keys were held down.
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_SHIFT 0x0001
|
#define GLFW_MOD_SHIFT 0x0001
|
||||||
/*! @brief If this bit is set one or more Control keys were held down.
|
/*! @brief If this bit is set one or more Control keys were held down.
|
||||||
|
*
|
||||||
|
* If this bit is set one or more Control keys were held down.
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_CONTROL 0x0002
|
#define GLFW_MOD_CONTROL 0x0002
|
||||||
/*! @brief If this bit is set one or more Alt keys were held down.
|
/*! @brief If this bit is set one or more Alt keys were held down.
|
||||||
|
*
|
||||||
|
* If this bit is set one or more Alt keys were held down.
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_ALT 0x0004
|
#define GLFW_MOD_ALT 0x0004
|
||||||
/*! @brief If this bit is set one or more Super keys were held down.
|
/*! @brief If this bit is set one or more Super keys were held down.
|
||||||
|
*
|
||||||
|
* If this bit is set one or more Super keys were held down.
|
||||||
*/
|
*/
|
||||||
#define GLFW_MOD_SUPER 0x0008
|
#define GLFW_MOD_SUPER 0x0008
|
||||||
|
/*! @brief If this bit is set the Caps Lock key is enabled.
|
||||||
|
*
|
||||||
|
* If this bit is set the Caps Lock key is enabled and the @ref
|
||||||
|
* GLFW_LOCK_KEY_MODS input mode is set.
|
||||||
|
*/
|
||||||
|
#define GLFW_MOD_CAPS_LOCK 0x0010
|
||||||
|
/*! @brief If this bit is set the Num Lock key is enabled.
|
||||||
|
*
|
||||||
|
* If this bit is set the Num Lock key is enabled and the @ref
|
||||||
|
* GLFW_LOCK_KEY_MODS input mode is set.
|
||||||
|
*/
|
||||||
|
#define GLFW_MOD_NUM_LOCK 0x0020
|
||||||
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
@ -794,6 +814,7 @@ extern "C" {
|
|||||||
* [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
|
* [window attribute](@ref GLFW_TRANSPARENT_FRAMEBUFFER_attrib).
|
||||||
*/
|
*/
|
||||||
#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
|
#define GLFW_TRANSPARENT_FRAMEBUFFER 0x0002000A
|
||||||
|
#define GLFW_HOVERED 0x0002000B
|
||||||
|
|
||||||
/*! @brief Framebuffer bit depth hint.
|
/*! @brief Framebuffer bit depth hint.
|
||||||
*
|
*
|
||||||
@ -944,8 +965,11 @@ extern "C" {
|
|||||||
#define GLFW_CONTEXT_CREATION_API 0x0002200B
|
#define GLFW_CONTEXT_CREATION_API 0x0002200B
|
||||||
|
|
||||||
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
#define GLFW_COCOA_RETINA_FRAMEBUFFER 0x00023001
|
||||||
#define GLFW_COCOA_FRAME_AUTOSAVE 0x00023002
|
#define GLFW_COCOA_FRAME_NAME 0x00023002
|
||||||
#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
|
#define GLFW_COCOA_GRAPHICS_SWITCHING 0x00023003
|
||||||
|
|
||||||
|
#define GLFW_X11_CLASS_NAME 0x00024001
|
||||||
|
#define GLFW_X11_INSTANCE_NAME 0x00024002
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_NO_API 0
|
#define GLFW_NO_API 0
|
||||||
@ -963,6 +987,7 @@ extern "C" {
|
|||||||
#define GLFW_CURSOR 0x00033001
|
#define GLFW_CURSOR 0x00033001
|
||||||
#define GLFW_STICKY_KEYS 0x00033002
|
#define GLFW_STICKY_KEYS 0x00033002
|
||||||
#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
|
#define GLFW_STICKY_MOUSE_BUTTONS 0x00033003
|
||||||
|
#define GLFW_LOCK_KEY_MODS 0x00033004
|
||||||
|
|
||||||
#define GLFW_CURSOR_NORMAL 0x00034001
|
#define GLFW_CURSOR_NORMAL 0x00034001
|
||||||
#define GLFW_CURSOR_HIDDEN 0x00034002
|
#define GLFW_CURSOR_HIDDEN 0x00034002
|
||||||
@ -1025,9 +1050,6 @@ extern "C" {
|
|||||||
|
|
||||||
#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
|
#define GLFW_COCOA_CHDIR_RESOURCES 0x00051001
|
||||||
#define GLFW_COCOA_MENUBAR 0x00051002
|
#define GLFW_COCOA_MENUBAR 0x00051002
|
||||||
|
|
||||||
#define GLFW_X11_WM_CLASS_NAME 0x00052001
|
|
||||||
#define GLFW_X11_WM_CLASS_CLASS 0x00052002
|
|
||||||
/*! @} */
|
/*! @} */
|
||||||
|
|
||||||
#define GLFW_DONT_CARE -1
|
#define GLFW_DONT_CARE -1
|
||||||
@ -1046,7 +1068,7 @@ extern "C" {
|
|||||||
* @sa @ref glfwGetProcAddress
|
* @sa @ref glfwGetProcAddress
|
||||||
*
|
*
|
||||||
* @since Added in version 3.0.
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
* @ingroup context
|
* @ingroup context
|
||||||
*/
|
*/
|
||||||
typedef void (*GLFWglproc)(void);
|
typedef void (*GLFWglproc)(void);
|
||||||
@ -1257,6 +1279,24 @@ typedef void (* GLFWwindowmaximizefun)(GLFWwindow*,int);
|
|||||||
*/
|
*/
|
||||||
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
typedef void (* GLFWframebuffersizefun)(GLFWwindow*,int,int);
|
||||||
|
|
||||||
|
/*! @brief The function signature for window content scale callbacks.
|
||||||
|
*
|
||||||
|
* This is the function signature for window content scale callback
|
||||||
|
* functions.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose content scale changed.
|
||||||
|
* @param[in] xscale The new x-axis content scale of the window.
|
||||||
|
* @param[in] yscale The new y-axis content scale of the window.
|
||||||
|
*
|
||||||
|
* @sa @ref window_scale
|
||||||
|
* @sa @ref glfwSetWindowContentScaleCallback
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
typedef void (* GLFWwindowcontentscalefun)(GLFWwindow*,float,float);
|
||||||
|
|
||||||
/*! @brief The function signature for mouse button callbacks.
|
/*! @brief The function signature for mouse button callbacks.
|
||||||
*
|
*
|
||||||
* This is the function signature for mouse button callback functions.
|
* This is the function signature for mouse button callback functions.
|
||||||
@ -1642,8 +1682,7 @@ GLFWAPI void glfwTerminate(void);
|
|||||||
|
|
||||||
/*! @brief Sets the specified init hint to the desired value.
|
/*! @brief Sets the specified init hint to the desired value.
|
||||||
*
|
*
|
||||||
* This function sets hints for the next initialization of GLFW. Only integer
|
* This function sets hints for the next initialization of GLFW.
|
||||||
* type hints can be set with this function.
|
|
||||||
*
|
*
|
||||||
* The values you set hints to are never reset by GLFW, but they only take
|
* The values you set hints to are never reset by GLFW, but they only take
|
||||||
* effect during initialization. Once GLFW has been initialized, any values
|
* effect during initialization. Once GLFW has been initialized, any values
|
||||||
@ -1666,7 +1705,6 @@ GLFWAPI void glfwTerminate(void);
|
|||||||
*
|
*
|
||||||
* @sa init_hints
|
* @sa init_hints
|
||||||
* @sa glfwInit
|
* @sa glfwInit
|
||||||
* @sa glfwInitHintString
|
|
||||||
*
|
*
|
||||||
* @since Added in version 3.3.
|
* @since Added in version 3.3.
|
||||||
*
|
*
|
||||||
@ -1674,40 +1712,6 @@ GLFWAPI void glfwTerminate(void);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwInitHint(int hint, int value);
|
GLFWAPI void glfwInitHint(int hint, int value);
|
||||||
|
|
||||||
/*! @brief Sets the specified init hint to the desired value.
|
|
||||||
*
|
|
||||||
* This function sets hints for the next initialization of GLFW. Only string
|
|
||||||
* type hints can be set with this function.
|
|
||||||
*
|
|
||||||
* The values you set hints to are never reset by GLFW, but they only take
|
|
||||||
* effect during initialization. Once GLFW has been initialized, any values
|
|
||||||
* you set will be ignored until the library is terminated and initialized
|
|
||||||
* again.
|
|
||||||
*
|
|
||||||
* Some hints are platform specific. These may be set on any platform but they
|
|
||||||
* will only affect their specific platform. Other platforms will ignore them.
|
|
||||||
* Setting these hints requires no platform specific headers or functions.
|
|
||||||
*
|
|
||||||
* @param[in] hint The [init hint](@ref init_hints) to set.
|
|
||||||
* @param[in] value The new value of the init hint.
|
|
||||||
*
|
|
||||||
* @errors Possible errors include @ref GLFW_INVALID_ENUM and @ref
|
|
||||||
* GLFW_INVALID_VALUE.
|
|
||||||
*
|
|
||||||
* @remarks This function may be called before @ref glfwInit.
|
|
||||||
*
|
|
||||||
* @thread_safety This function must only be called from the main thread.
|
|
||||||
*
|
|
||||||
* @sa init_hints
|
|
||||||
* @sa glfwInit
|
|
||||||
* @sa glfwInitHint
|
|
||||||
*
|
|
||||||
* @since Added in version 3.3.
|
|
||||||
*
|
|
||||||
* @ingroup init
|
|
||||||
*/
|
|
||||||
GLFWAPI void glfwInitHintString(int hint, const char* value);
|
|
||||||
|
|
||||||
/*! @brief Retrieves the version of the GLFW library.
|
/*! @brief Retrieves the version of the GLFW library.
|
||||||
*
|
*
|
||||||
* This function retrieves the major, minor and revision numbers of the GLFW
|
* This function retrieves the major, minor and revision numbers of the GLFW
|
||||||
@ -2004,6 +2008,56 @@ GLFWAPI void glfwGetMonitorContentScale(GLFWmonitor* monitor, float* xscale, flo
|
|||||||
*/
|
*/
|
||||||
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
|
GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Sets the user pointer of the specified monitor.
|
||||||
|
*
|
||||||
|
* This function sets the user-defined pointer of the specified monitor. The
|
||||||
|
* current value is retained until the monitor is disconnected. The initial
|
||||||
|
* value is `NULL`.
|
||||||
|
*
|
||||||
|
* This function may be called from the monitor callback, even for a monitor
|
||||||
|
* that is being disconnected.
|
||||||
|
*
|
||||||
|
* @param[in] monitor The monitor whose pointer to set.
|
||||||
|
* @param[in] pointer The new value.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_userptr
|
||||||
|
* @sa @ref glfwGetMonitorUserPointer
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* monitor, void* pointer);
|
||||||
|
|
||||||
|
/*! @brief Returns the user pointer of the specified monitor.
|
||||||
|
*
|
||||||
|
* This function returns the current value of the user-defined pointer of the
|
||||||
|
* specified monitor. The initial value is `NULL`.
|
||||||
|
*
|
||||||
|
* This function may be called from the monitor callback, even for a monitor
|
||||||
|
* that is being disconnected.
|
||||||
|
*
|
||||||
|
* @param[in] monitor The monitor whose pointer to return.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @sa @ref monitor_userptr
|
||||||
|
* @sa @ref glfwSetMonitorUserPointer
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup monitor
|
||||||
|
*/
|
||||||
|
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* monitor);
|
||||||
|
|
||||||
/*! @brief Sets the monitor configuration callback.
|
/*! @brief Sets the monitor configuration callback.
|
||||||
*
|
*
|
||||||
* This function sets the monitor configuration callback, or removes the
|
* This function sets the monitor configuration callback, or removes the
|
||||||
@ -2203,6 +2257,7 @@ GLFWAPI void glfwSetGammaRamp(GLFWmonitor* monitor, const GLFWgammaramp* ramp);
|
|||||||
*
|
*
|
||||||
* @sa @ref window_hints
|
* @sa @ref window_hints
|
||||||
* @sa @ref glfwWindowHint
|
* @sa @ref glfwWindowHint
|
||||||
|
* @sa @ref glfwWindowHintString
|
||||||
*
|
*
|
||||||
* @since Added in version 3.0.
|
* @since Added in version 3.0.
|
||||||
*
|
*
|
||||||
@ -2213,14 +2268,20 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
/*! @brief Sets the specified window hint to the desired value.
|
/*! @brief Sets the specified window hint to the desired value.
|
||||||
*
|
*
|
||||||
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
||||||
* hints, once set, retain their values until changed by a call to @ref
|
* hints, once set, retain their values until changed by a call to this
|
||||||
* glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
|
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
||||||
* terminated.
|
*
|
||||||
|
* Only integer value hints can be set with this function. String value hints
|
||||||
|
* are set with @ref glfwWindowHintString.
|
||||||
*
|
*
|
||||||
* This function does not check whether the specified hint values are valid.
|
* This function does not check whether the specified hint values are valid.
|
||||||
* If you set hints to invalid values this will instead be reported by the next
|
* If you set hints to invalid values this will instead be reported by the next
|
||||||
* call to @ref glfwCreateWindow.
|
* call to @ref glfwCreateWindow.
|
||||||
*
|
*
|
||||||
|
* Some hints are platform specific. These may be set on any platform but they
|
||||||
|
* will only affect their specific platform. Other platforms will ignore them.
|
||||||
|
* Setting these hints requires no platform specific headers or functions.
|
||||||
|
*
|
||||||
* @param[in] hint The [window hint](@ref window_hints) to set.
|
* @param[in] hint The [window hint](@ref window_hints) to set.
|
||||||
* @param[in] value The new value of the window hint.
|
* @param[in] value The new value of the window hint.
|
||||||
*
|
*
|
||||||
@ -2230,6 +2291,7 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_hints
|
* @sa @ref window_hints
|
||||||
|
* @sa @ref glfwWindowHintString
|
||||||
* @sa @ref glfwDefaultWindowHints
|
* @sa @ref glfwDefaultWindowHints
|
||||||
*
|
*
|
||||||
* @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
|
* @since Added in version 3.0. Replaces `glfwOpenWindowHint`.
|
||||||
@ -2238,6 +2300,44 @@ GLFWAPI void glfwDefaultWindowHints(void);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI void glfwWindowHint(int hint, int value);
|
GLFWAPI void glfwWindowHint(int hint, int value);
|
||||||
|
|
||||||
|
/*! @brief Sets the specified window hint to the desired value.
|
||||||
|
*
|
||||||
|
* This function sets hints for the next call to @ref glfwCreateWindow. The
|
||||||
|
* hints, once set, retain their values until changed by a call to this
|
||||||
|
* function or @ref glfwDefaultWindowHints, or until the library is terminated.
|
||||||
|
*
|
||||||
|
* Only string type hints can be set with this function. Integer value hints
|
||||||
|
* are set with @ref glfwWindowHint.
|
||||||
|
*
|
||||||
|
* This function does not check whether the specified hint values are valid.
|
||||||
|
* If you set hints to invalid values this will instead be reported by the next
|
||||||
|
* call to @ref glfwCreateWindow.
|
||||||
|
*
|
||||||
|
* Some hints are platform specific. These may be set on any platform but they
|
||||||
|
* will only affect their specific platform. Other platforms will ignore them.
|
||||||
|
* Setting these hints requires no platform specific headers or functions.
|
||||||
|
*
|
||||||
|
* @param[in] hint The [window hint](@ref window_hints) to set.
|
||||||
|
* @param[in] value The new value of the window hint.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
|
* GLFW_INVALID_ENUM.
|
||||||
|
*
|
||||||
|
* @pointer_lifetime The specified string is copied before this function
|
||||||
|
* returns.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref window_hints
|
||||||
|
* @sa @ref glfwWindowHint
|
||||||
|
* @sa @ref glfwDefaultWindowHints
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwWindowHintString(int hint, const char* value);
|
||||||
|
|
||||||
/*! @brief Creates a window and its associated context.
|
/*! @brief Creates a window and its associated context.
|
||||||
*
|
*
|
||||||
* This function creates a window and its associated OpenGL or OpenGL ES
|
* This function creates a window and its associated OpenGL or OpenGL ES
|
||||||
@ -2348,9 +2448,8 @@ GLFWAPI void glfwWindowHint(int hint, int value);
|
|||||||
* `CMake/MacOSXBundleInfo.plist.in` in the source tree.
|
* `CMake/MacOSXBundleInfo.plist.in` in the source tree.
|
||||||
*
|
*
|
||||||
* @remark @macos When activating frame autosaving with
|
* @remark @macos When activating frame autosaving with
|
||||||
* [GLFW_COCOA_FRAME_AUTOSAVE](@ref GLFW_COCOA_FRAME_AUTOSAVE_hint), the
|
* [GLFW_COCOA_FRAME_NAME](@ref GLFW_COCOA_FRAME_NAME_hint), the specified
|
||||||
* specified window size may be overriden by a previously saved size and
|
* window size and position may be overriden by previously saved values.
|
||||||
* position.
|
|
||||||
*
|
*
|
||||||
* @remark @x11 Some window managers will not respect the placement of
|
* @remark @x11 Some window managers will not respect the placement of
|
||||||
* initially hidden windows.
|
* initially hidden windows.
|
||||||
@ -2360,10 +2459,12 @@ GLFWAPI void glfwWindowHint(int hint, int value);
|
|||||||
* query the final size, position or other attributes directly after window
|
* query the final size, position or other attributes directly after window
|
||||||
* creation.
|
* creation.
|
||||||
*
|
*
|
||||||
* @remark @x11 The name and class of the `WM_CLASS` window property will by
|
* @remark @x11 The class part of the `WM_CLASS` window property will by
|
||||||
* default be set to the window title passed to this function. Set the @ref
|
* default be set to the window title passed to this function. The instance
|
||||||
* GLFW_X11_WM_CLASS_NAME and @ref GLFW_X11_WM_CLASS_CLASS init hints before
|
* part will use the contents of the `RESOURCE_NAME` environment variable, if
|
||||||
* initialization to override this.
|
* present and not empty, or fall back to the window title. Set the @ref
|
||||||
|
* GLFW_X11_CLASS_NAME and @ref GLFW_X11_INSTANCE_NAME window hints to override
|
||||||
|
* this.
|
||||||
*
|
*
|
||||||
* @remark @wayland The window frame is currently unimplemented, as if
|
* @remark @wayland The window frame is currently unimplemented, as if
|
||||||
* [GLFW_DECORATED](@ref GLFW_DECORATED_hint) was always set to `GLFW_FALSE`.
|
* [GLFW_DECORATED](@ref GLFW_DECORATED_hint) was always set to `GLFW_FALSE`.
|
||||||
@ -2850,6 +2951,7 @@ GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* window, int* left, int* top, int
|
|||||||
* @thread_safety This function must only be called from the main thread.
|
* @thread_safety This function must only be called from the main thread.
|
||||||
*
|
*
|
||||||
* @sa @ref window_scale
|
* @sa @ref window_scale
|
||||||
|
* @sa @ref glfwSetWindowContentScaleCallback
|
||||||
* @sa @ref glfwGetMonitorContentScale
|
* @sa @ref glfwGetMonitorContentScale
|
||||||
*
|
*
|
||||||
* @since Added in version 3.3.
|
* @since Added in version 3.3.
|
||||||
@ -3512,6 +3614,30 @@ GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* window,
|
|||||||
*/
|
*/
|
||||||
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
|
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* window, GLFWframebuffersizefun cbfun);
|
||||||
|
|
||||||
|
/*! @brief Sets the window content scale callback for the specified window.
|
||||||
|
*
|
||||||
|
* This function sets the window content scale callback of the specified window,
|
||||||
|
* which is called when the content scale of the specified window changes.
|
||||||
|
*
|
||||||
|
* @param[in] window The window whose callback to set.
|
||||||
|
* @param[in] cbfun The new callback, or `NULL` to remove the currently set
|
||||||
|
* callback.
|
||||||
|
* @return The previously set callback, or `NULL` if no callback was set or the
|
||||||
|
* library had not been [initialized](@ref intro_init).
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function must only be called from the main thread.
|
||||||
|
*
|
||||||
|
* @sa @ref window_scale
|
||||||
|
* @sa @ref glfwGetWindowContentScale
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup window
|
||||||
|
*/
|
||||||
|
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* window, GLFWwindowcontentscalefun cbfun);
|
||||||
|
|
||||||
/*! @brief Processes all pending events.
|
/*! @brief Processes all pending events.
|
||||||
*
|
*
|
||||||
* This function processes only those events that are already in the event
|
* This function processes only those events that are already in the event
|
||||||
@ -3676,12 +3802,12 @@ GLFWAPI void glfwPostEmptyEvent(void);
|
|||||||
/*! @brief Returns the value of an input option for the specified window.
|
/*! @brief Returns the value of an input option for the specified window.
|
||||||
*
|
*
|
||||||
* This function returns the value of an input option for the specified window.
|
* This function returns the value of an input option for the specified window.
|
||||||
* The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS or
|
* The mode must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
|
||||||
* @ref GLFW_STICKY_MOUSE_BUTTONS.
|
* @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
|
||||||
*
|
*
|
||||||
* @param[in] window The window to query.
|
* @param[in] window The window to query.
|
||||||
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
|
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
|
||||||
* `GLFW_STICKY_MOUSE_BUTTONS`.
|
* `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
|
||||||
* GLFW_INVALID_ENUM.
|
* GLFW_INVALID_ENUM.
|
||||||
@ -3699,8 +3825,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
|||||||
/*! @brief Sets an input option for the specified window.
|
/*! @brief Sets an input option for the specified window.
|
||||||
*
|
*
|
||||||
* This function sets an input mode option for the specified window. The mode
|
* This function sets an input mode option for the specified window. The mode
|
||||||
* must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS or
|
* must be one of @ref GLFW_CURSOR, @ref GLFW_STICKY_KEYS,
|
||||||
* @ref GLFW_STICKY_MOUSE_BUTTONS.
|
* @ref GLFW_STICKY_MOUSE_BUTTONS or @ref GLFW_LOCK_KEY_MODS.
|
||||||
*
|
*
|
||||||
* If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
|
* If the mode is `GLFW_CURSOR`, the value must be one of the following cursor
|
||||||
* modes:
|
* modes:
|
||||||
@ -3726,9 +3852,15 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* window, int mode);
|
|||||||
* you are only interested in whether mouse buttons have been pressed but not
|
* you are only interested in whether mouse buttons have been pressed but not
|
||||||
* when or in which order.
|
* when or in which order.
|
||||||
*
|
*
|
||||||
|
* If the mode is `GLFW_LOCK_KEY_MODS`, the value must be either `GLFW_TRUE` to
|
||||||
|
* enable lock key modifier bits, or `GLFW_FALSE` to disable them. If enabled,
|
||||||
|
* callbacks that receive modifier bits will also have the @ref
|
||||||
|
* GLFW_MOD_CAPS_LOCK bit set when the event was generated with Caps Lock on,
|
||||||
|
* and the @ref GLFW_MOD_NUM_LOCK bit when Num Lock was on.
|
||||||
|
*
|
||||||
* @param[in] window The window whose input mode to set.
|
* @param[in] window The window whose input mode to set.
|
||||||
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS` or
|
* @param[in] mode One of `GLFW_CURSOR`, `GLFW_STICKY_KEYS`,
|
||||||
* `GLFW_STICKY_MOUSE_BUTTONS`.
|
* `GLFW_STICKY_MOUSE_BUTTONS` or `GLFW_LOCK_KEY_MODS`.
|
||||||
* @param[in] value The new value of the specified input mode.
|
* @param[in] value The new value of the specified input mode.
|
||||||
*
|
*
|
||||||
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
|
||||||
@ -4621,6 +4753,56 @@ GLFWAPI const char* glfwGetJoystickName(int jid);
|
|||||||
*/
|
*/
|
||||||
GLFWAPI const char* glfwGetJoystickGUID(int jid);
|
GLFWAPI const char* glfwGetJoystickGUID(int jid);
|
||||||
|
|
||||||
|
/*! @brief Sets the user pointer of the specified joystick.
|
||||||
|
*
|
||||||
|
* This function sets the user-defined pointer of the specified joystick. The
|
||||||
|
* current value is retained until the joystick is disconnected. The initial
|
||||||
|
* value is `NULL`.
|
||||||
|
*
|
||||||
|
* This function may be called from the joystick callback, even for a joystick
|
||||||
|
* that is being disconnected.
|
||||||
|
*
|
||||||
|
* @param[in] joystick The joystick whose pointer to set.
|
||||||
|
* @param[in] pointer The new value.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_userptr
|
||||||
|
* @sa @ref glfwGetJoystickUserPointer
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer);
|
||||||
|
|
||||||
|
/*! @brief Returns the user pointer of the specified joystick.
|
||||||
|
*
|
||||||
|
* This function returns the current value of the user-defined pointer of the
|
||||||
|
* specified joystick. The initial value is `NULL`.
|
||||||
|
*
|
||||||
|
* This function may be called from the joystick callback, even for a joystick
|
||||||
|
* that is being disconnected.
|
||||||
|
*
|
||||||
|
* @param[in] joystick The joystick whose pointer to return.
|
||||||
|
*
|
||||||
|
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @sa @ref joystick_userptr
|
||||||
|
* @sa @ref glfwSetJoystickUserPointer
|
||||||
|
*
|
||||||
|
* @since Added in version 3.3.
|
||||||
|
*
|
||||||
|
* @ingroup input
|
||||||
|
*/
|
||||||
|
GLFWAPI void* glfwGetJoystickUserPointer(int jid);
|
||||||
|
|
||||||
/*! @brief Returns whether the specified joystick has a gamepad mapping.
|
/*! @brief Returns whether the specified joystick has a gamepad mapping.
|
||||||
*
|
*
|
||||||
* This function returns whether the specified joystick is both present and has
|
* This function returns whether the specified joystick is both present and has
|
||||||
|
@ -49,7 +49,7 @@ elseif (_GLFW_WAYLAND)
|
|||||||
BASENAME pointer-constraints-unstable-v1)
|
BASENAME pointer-constraints-unstable-v1)
|
||||||
ecm_add_wayland_client_protocol(glfw_SOURCES
|
ecm_add_wayland_client_protocol(glfw_SOURCES
|
||||||
PROTOCOL
|
PROTOCOL
|
||||||
${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml
|
"${WAYLAND_PROTOCOLS_PKGDATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml"
|
||||||
BASENAME idle-inhibit-unstable-v1)
|
BASENAME idle-inhibit-unstable-v1)
|
||||||
elseif (_GLFW_MIR)
|
elseif (_GLFW_MIR)
|
||||||
set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h
|
set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h
|
||||||
|
@ -88,9 +88,10 @@ typedef struct _GLFWwindowNS
|
|||||||
|
|
||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
|
|
||||||
// Cached window and framebuffer sizes used to filter out duplicate events
|
// Cached window properties to filter out duplicate events
|
||||||
int width, height;
|
int width, height;
|
||||||
int fbWidth, fbHeight;
|
int fbWidth, fbHeight;
|
||||||
|
float xscale, yscale;
|
||||||
|
|
||||||
// The total sum of the distances the cursor has been warped
|
// The total sum of the distances the cursor has been warped
|
||||||
// since the last cursor motion event was processed
|
// since the last cursor motion event was processed
|
||||||
|
@ -43,6 +43,7 @@
|
|||||||
#define NSEventModifierFlagControl NSControlKeyMask
|
#define NSEventModifierFlagControl NSControlKeyMask
|
||||||
#define NSEventModifierFlagOption NSAlternateKeyMask
|
#define NSEventModifierFlagOption NSAlternateKeyMask
|
||||||
#define NSEventModifierFlagShift NSShiftKeyMask
|
#define NSEventModifierFlagShift NSShiftKeyMask
|
||||||
|
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
|
||||||
#define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
|
#define NSEventModifierFlagDeviceIndependentFlagsMask NSDeviceIndependentModifierFlagsMask
|
||||||
#define NSEventMaskAny NSAnyEventMask
|
#define NSEventMaskAny NSAnyEventMask
|
||||||
#define NSEventTypeApplicationDefined NSApplicationDefined
|
#define NSEventTypeApplicationDefined NSApplicationDefined
|
||||||
@ -177,6 +178,8 @@ static int translateFlags(NSUInteger flags)
|
|||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if (flags & NSEventModifierFlagCommand)
|
if (flags & NSEventModifierFlagCommand)
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
|
if (flags & NSEventModifierFlagCapsLock)
|
||||||
|
mods |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
@ -571,6 +574,16 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
window->ns.fbHeight = fbRect.size.height;
|
window->ns.fbHeight = fbRect.size.height;
|
||||||
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
_glfwInputFramebufferSize(window, fbRect.size.width, fbRect.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const float xscale = fbRect.size.width / contentRect.size.width;
|
||||||
|
const float yscale = fbRect.size.height / contentRect.size.height;
|
||||||
|
|
||||||
|
if (xscale != window->ns.xscale || yscale != window->ns.yscale)
|
||||||
|
{
|
||||||
|
window->ns.xscale = xscale;
|
||||||
|
window->ns.yscale = yscale;
|
||||||
|
_glfwInputWindowContentScale(window, xscale, yscale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)drawRect:(NSRect)rect
|
- (void)drawRect:(NSRect)rect
|
||||||
@ -1093,8 +1106,8 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
[window->ns.object zoom:nil];
|
[window->ns.object zoom:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->ns.frame)
|
if (strlen(wndconfig->ns.frameName))
|
||||||
[window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->title]];
|
[window->ns.object setFrameAutosaveName:[NSString stringWithUTF8String:wndconfig->ns.frameName]];
|
||||||
|
|
||||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||||
|
|
||||||
@ -1475,6 +1488,20 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return [window->ns.object isZoomed];
|
return [window->ns.object isZoomed];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
const NSPoint point = [NSEvent mouseLocation];
|
||||||
|
|
||||||
|
if ([NSWindow windowNumberAtPoint:point belowWindowWithWindowNumber:0] !=
|
||||||
|
[window->ns.object windowNumber])
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NSPointInRect(point,
|
||||||
|
[window->ns.object convertRectToScreen:[window->ns.view bounds]]);
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
return ![window->ns.object isOpaque] && ![window->ns.view isOpaque];
|
||||||
|
@ -321,10 +321,11 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||||
|
const _GLFWctxconfig* ctxconfig)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* previous;
|
||||||
const char* version;
|
const char* version;
|
||||||
const char* prefixes[] =
|
const char* prefixes[] =
|
||||||
{
|
{
|
||||||
@ -334,11 +335,12 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
|
||||||
|
|
||||||
window->context.source = ctxconfig->source;
|
window->context.source = ctxconfig->source;
|
||||||
window->context.client = GLFW_OPENGL_API;
|
window->context.client = GLFW_OPENGL_API;
|
||||||
|
|
||||||
|
previous = _glfwPlatformGetTls(&_glfw.contextSlot);;
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) window);
|
||||||
|
|
||||||
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
|
window->context.GetIntegerv = (PFNGLGETINTEGERVPROC)
|
||||||
window->context.getProcAddress("glGetIntegerv");
|
window->context.getProcAddress("glGetIntegerv");
|
||||||
window->context.GetString = (PFNGLGETSTRINGPROC)
|
window->context.GetString = (PFNGLGETSTRINGPROC)
|
||||||
@ -346,6 +348,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
if (!window->context.GetIntegerv || !window->context.GetString)
|
if (!window->context.GetIntegerv || !window->context.GetString)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
|
_glfwInputError(GLFW_PLATFORM_ERROR, "Entry point retrieval is broken");
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +366,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
"OpenGL ES version string retrieval is broken");
|
"OpenGL ES version string retrieval is broken");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,6 +398,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
"No version found in OpenGL ES version string");
|
"No version found in OpenGL ES version string");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,6 +428,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
window->context.major, window->context.minor);
|
window->context.major, window->context.minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,6 +444,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"Entry point retrieval is broken");
|
"Entry point retrieval is broken");
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -544,6 +551,7 @@ GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig)
|
|||||||
window->context.swapBuffers(window);
|
window->context.swapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
src/init.c
26
src/init.c
@ -53,10 +53,6 @@ static _GLFWinitconfig _glfwInitHints =
|
|||||||
{
|
{
|
||||||
GLFW_TRUE, // macOS menu bar
|
GLFW_TRUE, // macOS menu bar
|
||||||
GLFW_TRUE // macOS bundle chdir
|
GLFW_TRUE // macOS bundle chdir
|
||||||
},
|
|
||||||
{
|
|
||||||
"", // X11 WM_CLASS name
|
|
||||||
"" // X11 WM_CLASS class
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -260,27 +256,7 @@ GLFWAPI void glfwInitHint(int hint, int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
_glfwInputError(GLFW_INVALID_ENUM,
|
||||||
"Invalid integer type init hint 0x%08X", hint);
|
"Invalid init hint 0x%08X", hint);
|
||||||
}
|
|
||||||
|
|
||||||
GLFWAPI void glfwInitHintString(int hint, const char* value)
|
|
||||||
{
|
|
||||||
assert(value != NULL);
|
|
||||||
|
|
||||||
switch (hint)
|
|
||||||
{
|
|
||||||
case GLFW_X11_WM_CLASS_NAME:
|
|
||||||
strncpy(_glfwInitHints.x11.className, value,
|
|
||||||
sizeof(_glfwInitHints.x11.className) - 1);
|
|
||||||
return;
|
|
||||||
case GLFW_X11_WM_CLASS_CLASS:
|
|
||||||
strncpy(_glfwInitHints.x11.classClass, value,
|
|
||||||
sizeof(_glfwInitHints.x11.classClass) - 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM,
|
|
||||||
"Invalid string type init hint 0x%08X", hint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev)
|
||||||
|
109
src/input.c
109
src/input.c
@ -57,6 +57,58 @@ static _GLFWmapping* findMapping(const char* guid)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks whether a gamepad mapping element is present in the hardware
|
||||||
|
//
|
||||||
|
static GLFWbool isValidElementForJoystick(const _GLFWmapelement* e,
|
||||||
|
const _GLFWjoystick* js)
|
||||||
|
{
|
||||||
|
if (e->type == _GLFW_JOYSTICK_HATBIT && (e->value >> 4) >= js->hatCount)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
else if (e->type == _GLFW_JOYSTICK_BUTTON && e->value >= js->buttonCount)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
else if (e->type == _GLFW_JOYSTICK_AXIS && e->value >= js->axisCount)
|
||||||
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finds a mapping based on joystick GUID and verifies element indices
|
||||||
|
//
|
||||||
|
static _GLFWmapping* findValidMapping(const _GLFWjoystick* js)
|
||||||
|
{
|
||||||
|
_GLFWmapping* mapping = findMapping(js->guid);
|
||||||
|
if (mapping)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i <= GLFW_GAMEPAD_BUTTON_LAST; i++)
|
||||||
|
{
|
||||||
|
if (!isValidElementForJoystick(mapping->buttons + i, js))
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
"Invalid button in gamepad mapping %s (%s)",
|
||||||
|
mapping->guid,
|
||||||
|
mapping->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i <= GLFW_GAMEPAD_AXIS_LAST; i++)
|
||||||
|
{
|
||||||
|
if (!isValidElementForJoystick(mapping->axes + i, js))
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_INVALID_VALUE,
|
||||||
|
"Invalid axis in gamepad mapping %s (%s)",
|
||||||
|
mapping->guid,
|
||||||
|
mapping->name);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mapping;
|
||||||
|
}
|
||||||
|
|
||||||
// Parses an SDL_GameControllerDB line and adds it to the mapping list
|
// Parses an SDL_GameControllerDB line and adds it to the mapping list
|
||||||
//
|
//
|
||||||
static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
static GLFWbool parseMapping(_GLFWmapping* mapping, const char* string)
|
||||||
@ -193,6 +245,9 @@ void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int m
|
|||||||
action = GLFW_REPEAT;
|
action = GLFW_REPEAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!window->lockKeyMods)
|
||||||
|
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||||
|
|
||||||
if (window->callbacks.key)
|
if (window->callbacks.key)
|
||||||
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
||||||
}
|
}
|
||||||
@ -202,6 +257,9 @@ void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWb
|
|||||||
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
if (codepoint < 32 || (codepoint > 126 && codepoint < 160))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!window->lockKeyMods)
|
||||||
|
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||||
|
|
||||||
if (window->callbacks.charmods)
|
if (window->callbacks.charmods)
|
||||||
window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
|
window->callbacks.charmods((GLFWwindow*) window, codepoint, mods);
|
||||||
|
|
||||||
@ -223,6 +281,9 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
|
|||||||
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!window->lockKeyMods)
|
||||||
|
mods &= ~(GLFW_MOD_CAPS_LOCK | GLFW_MOD_NUM_LOCK);
|
||||||
|
|
||||||
if (action == GLFW_RELEASE && window->stickyMouseButtons)
|
if (action == GLFW_RELEASE && window->stickyMouseButtons)
|
||||||
window->mouseButtons[button] = _GLFW_STICK;
|
window->mouseButtons[button] = _GLFW_STICK;
|
||||||
else
|
else
|
||||||
@ -328,9 +389,9 @@ _GLFWjoystick* _glfwAllocJoystick(const char* name,
|
|||||||
js->axisCount = axisCount;
|
js->axisCount = axisCount;
|
||||||
js->buttonCount = buttonCount;
|
js->buttonCount = buttonCount;
|
||||||
js->hatCount = hatCount;
|
js->hatCount = hatCount;
|
||||||
js->mapping = findMapping(guid);
|
|
||||||
|
|
||||||
strcpy(js->guid, guid);
|
strcpy(js->guid, guid);
|
||||||
|
js->mapping = findValidMapping(js);
|
||||||
|
|
||||||
return js;
|
return js;
|
||||||
}
|
}
|
||||||
@ -364,6 +425,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode)
|
|||||||
return window->stickyKeys;
|
return window->stickyKeys;
|
||||||
case GLFW_STICKY_MOUSE_BUTTONS:
|
case GLFW_STICKY_MOUSE_BUTTONS:
|
||||||
return window->stickyMouseButtons;
|
return window->stickyMouseButtons;
|
||||||
|
case GLFW_LOCK_KEY_MODS:
|
||||||
|
return window->lockKeyMods;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||||
@ -419,7 +482,7 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->stickyKeys = value ? GLFW_TRUE : GLFW_FALSE;
|
window->stickyKeys = value;
|
||||||
}
|
}
|
||||||
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
|
else if (mode == GLFW_STICKY_MOUSE_BUTTONS)
|
||||||
{
|
{
|
||||||
@ -439,8 +502,10 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window->stickyMouseButtons = value ? GLFW_TRUE : GLFW_FALSE;
|
window->stickyMouseButtons = value;
|
||||||
}
|
}
|
||||||
|
else if (mode == GLFW_LOCK_KEY_MODS)
|
||||||
|
window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
else
|
else
|
||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode);
|
||||||
}
|
}
|
||||||
@ -948,6 +1013,38 @@ GLFWAPI const char* glfwGetJoystickGUID(int jid)
|
|||||||
return js->guid;
|
return js->guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwSetJoystickUserPointer(int jid, void* pointer)
|
||||||
|
{
|
||||||
|
_GLFWjoystick* js;
|
||||||
|
|
||||||
|
assert(jid >= GLFW_JOYSTICK_1);
|
||||||
|
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
js = _glfw.joysticks + jid;
|
||||||
|
if (!js->present)
|
||||||
|
return;
|
||||||
|
|
||||||
|
js->userPointer = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void* glfwGetJoystickUserPointer(int jid)
|
||||||
|
{
|
||||||
|
_GLFWjoystick* js;
|
||||||
|
|
||||||
|
assert(jid >= GLFW_JOYSTICK_1);
|
||||||
|
assert(jid <= GLFW_JOYSTICK_LAST);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
|
||||||
|
js = _glfw.joysticks + jid;
|
||||||
|
if (!js->present)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return js->userPointer;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
@ -1007,7 +1104,7 @@ GLFWAPI int glfwUpdateGamepadMappings(const char* string)
|
|||||||
{
|
{
|
||||||
_GLFWjoystick* js = _glfw.joysticks + jid;
|
_GLFWjoystick* js = _glfw.joysticks + jid;
|
||||||
if (js->present)
|
if (js->present)
|
||||||
js->mapping = findMapping(js->guid);
|
js->mapping = findValidMapping(js);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -1119,8 +1216,8 @@ GLFWAPI int glfwGetGamepadState(int jid, GLFWgamepadstate* state)
|
|||||||
state->axes[i] = js->axes[js->mapping->axes[i].value];
|
state->axes[i] = js->axes[js->mapping->axes[i].value];
|
||||||
else if (js->mapping->buttons[i].type == _GLFW_JOYSTICK_HATBIT)
|
else if (js->mapping->buttons[i].type == _GLFW_JOYSTICK_HATBIT)
|
||||||
{
|
{
|
||||||
const unsigned int hat = js->mapping->buttons[i].value >> 4;
|
const unsigned int hat = js->mapping->axes[i].value >> 4;
|
||||||
const unsigned int bit = js->mapping->buttons[i].value & 0xf;
|
const unsigned int bit = js->mapping->axes[i].value & 0xf;
|
||||||
if (js->hats[hat] & bit)
|
if (js->hats[hat] & bit)
|
||||||
state->axes[i] = 1.f;
|
state->axes[i] = 1.f;
|
||||||
}
|
}
|
||||||
|
@ -281,10 +281,6 @@ struct _GLFWinitconfig
|
|||||||
GLFWbool menubar;
|
GLFWbool menubar;
|
||||||
GLFWbool chdir;
|
GLFWbool chdir;
|
||||||
} ns;
|
} ns;
|
||||||
struct {
|
|
||||||
char className[256];
|
|
||||||
char classClass[256];
|
|
||||||
} x11;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! @brief Window configuration.
|
/*! @brief Window configuration.
|
||||||
@ -308,8 +304,12 @@ struct _GLFWwndconfig
|
|||||||
GLFWbool centerCursor;
|
GLFWbool centerCursor;
|
||||||
struct {
|
struct {
|
||||||
GLFWbool retina;
|
GLFWbool retina;
|
||||||
GLFWbool frame;
|
char frameName[256];
|
||||||
} ns;
|
} ns;
|
||||||
|
struct {
|
||||||
|
char className[256];
|
||||||
|
char instanceName[256];
|
||||||
|
} x11;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! @brief Context configuration.
|
/*! @brief Context configuration.
|
||||||
@ -419,9 +419,13 @@ struct _GLFWwindow
|
|||||||
|
|
||||||
GLFWbool stickyKeys;
|
GLFWbool stickyKeys;
|
||||||
GLFWbool stickyMouseButtons;
|
GLFWbool stickyMouseButtons;
|
||||||
|
|
||||||
double penPressure;
|
double penPressure;
|
||||||
int penXposition;
|
int penXposition;
|
||||||
int penYposition;
|
int penYposition;
|
||||||
|
|
||||||
|
GLFWbool lockKeyMods;
|
||||||
|
|
||||||
int cursorMode;
|
int cursorMode;
|
||||||
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||||
char keys[GLFW_KEY_LAST + 1];
|
char keys[GLFW_KEY_LAST + 1];
|
||||||
@ -439,6 +443,7 @@ struct _GLFWwindow
|
|||||||
GLFWwindowiconifyfun iconify;
|
GLFWwindowiconifyfun iconify;
|
||||||
GLFWwindowmaximizefun maximize;
|
GLFWwindowmaximizefun maximize;
|
||||||
GLFWframebuffersizefun fbsize;
|
GLFWframebuffersizefun fbsize;
|
||||||
|
GLFWwindowcontentscalefun scale;
|
||||||
GLFWmousebuttonfun mouseButton;
|
GLFWmousebuttonfun mouseButton;
|
||||||
GLFWpenpressurefun penPressure;
|
GLFWpenpressurefun penPressure;
|
||||||
GLFWcursorposfun cursorPos;
|
GLFWcursorposfun cursorPos;
|
||||||
@ -459,6 +464,7 @@ struct _GLFWwindow
|
|||||||
struct _GLFWmonitor
|
struct _GLFWmonitor
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
|
void* userPointer;
|
||||||
|
|
||||||
// Physical dimensions in millimeters.
|
// Physical dimensions in millimeters.
|
||||||
int widthMM, heightMM;
|
int widthMM, heightMM;
|
||||||
@ -517,6 +523,7 @@ struct _GLFWjoystick
|
|||||||
unsigned char* hats;
|
unsigned char* hats;
|
||||||
int hatCount;
|
int hatCount;
|
||||||
char* name;
|
char* name;
|
||||||
|
void* userPointer;
|
||||||
char guid[33];
|
char guid[33];
|
||||||
_GLFWmapping* mapping;
|
_GLFWmapping* mapping;
|
||||||
|
|
||||||
@ -690,6 +697,7 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window);
|
|||||||
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
int _glfwPlatformWindowIconified(_GLFWwindow* window);
|
||||||
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
int _glfwPlatformWindowVisible(_GLFWwindow* window);
|
||||||
int _glfwPlatformWindowMaximized(_GLFWwindow* window);
|
int _glfwPlatformWindowMaximized(_GLFWwindow* window);
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window);
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window);
|
||||||
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
|
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window);
|
||||||
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
|
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled);
|
||||||
@ -755,6 +763,14 @@ void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
|||||||
*/
|
*/
|
||||||
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
|
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
|
/*! @brief Notifies shared code that a window content scale has changed.
|
||||||
|
* @param[in] window The window that received the event.
|
||||||
|
* @param[in] xscale The new x-axis content scale of the window.
|
||||||
|
* @param[in] yscale The new y-axis content scale of the window.
|
||||||
|
* @ingroup event
|
||||||
|
*/
|
||||||
|
void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale);
|
||||||
|
|
||||||
/*! @brief Notifies shared code that a window has been iconified or restored.
|
/*! @brief Notifies shared code that a window has been iconified or restored.
|
||||||
* @param[in] window The window that received the event.
|
* @param[in] window The window that received the event.
|
||||||
* @param[in] iconified `GLFW_TRUE` if the window was iconified, or
|
* @param[in] iconified `GLFW_TRUE` if the window was iconified, or
|
||||||
@ -964,7 +980,8 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
|||||||
* unusable.
|
* unusable.
|
||||||
* @ingroup utility
|
* @ingroup utility
|
||||||
*/
|
*/
|
||||||
GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig);
|
GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
|
||||||
|
const _GLFWctxconfig* ctxconfig);
|
||||||
|
|
||||||
/*! @brief Checks whether the desired context attributes are valid.
|
/*! @brief Checks whether the desired context attributes are valid.
|
||||||
* @param[in] ctxconfig The context attributes to check.
|
* @param[in] ctxconfig The context attributes to check.
|
||||||
|
@ -117,12 +117,16 @@ static int mirModToGLFWMod(uint32_t mods)
|
|||||||
|
|
||||||
if (mods & mir_input_event_modifier_alt)
|
if (mods & mir_input_event_modifier_alt)
|
||||||
publicMods |= GLFW_MOD_ALT;
|
publicMods |= GLFW_MOD_ALT;
|
||||||
else if (mods & mir_input_event_modifier_shift)
|
if (mods & mir_input_event_modifier_shift)
|
||||||
publicMods |= GLFW_MOD_SHIFT;
|
publicMods |= GLFW_MOD_SHIFT;
|
||||||
else if (mods & mir_input_event_modifier_ctrl)
|
if (mods & mir_input_event_modifier_ctrl)
|
||||||
publicMods |= GLFW_MOD_CONTROL;
|
publicMods |= GLFW_MOD_CONTROL;
|
||||||
else if (mods & mir_input_event_modifier_meta)
|
if (mods & mir_input_event_modifier_meta)
|
||||||
publicMods |= GLFW_MOD_SUPER;
|
publicMods |= GLFW_MOD_SUPER;
|
||||||
|
if (mods & mir_input_event_modifier_caps_lock)
|
||||||
|
publicMods |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
if (mods & mir_input_event_modifier_num_lock)
|
||||||
|
publicMods |= GLFW_MOD_NUM_LOCK;
|
||||||
|
|
||||||
return publicMods;
|
return publicMods;
|
||||||
}
|
}
|
||||||
@ -623,6 +627,13 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return mir_window_get_state(window->mir.window) == mir_window_state_maximized;
|
return mir_window_get_state(window->mir.window) == mir_window_state_maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
"Mir: Unsupported function %s", __PRETTY_FUNCTION__);
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
|
@ -351,6 +351,24 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
|||||||
return monitor->name;
|
return monitor->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwSetMonitorUserPointer(GLFWmonitor* handle, void* pointer)
|
||||||
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
assert(monitor != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
monitor->userPointer = pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
GLFWAPI void* glfwGetMonitorUserPointer(GLFWmonitor* handle)
|
||||||
|
{
|
||||||
|
_GLFWmonitor* monitor = (_GLFWmonitor*) handle;
|
||||||
|
assert(monitor != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
return monitor->userPointer;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
@ -406,16 +424,16 @@ GLFWAPI void glfwSetGamma(GLFWmonitor* handle, float gamma)
|
|||||||
|
|
||||||
for (i = 0; i < 256; i++)
|
for (i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
double value;
|
float value;
|
||||||
|
|
||||||
// Calculate intensity
|
// Calculate intensity
|
||||||
value = i / 255.0;
|
value = i / 255.f;
|
||||||
// Apply gamma curve
|
// Apply gamma curve
|
||||||
value = pow(value, 1.0 / gamma) * 65535.0 + 0.5;
|
value = powf(value, 1.f / gamma) * 65535.f + 0.5f;
|
||||||
|
|
||||||
// Clamp to value range
|
// Clamp to value range
|
||||||
if (value > 65535.0)
|
if (value > 65535.f)
|
||||||
value = 65535.0;
|
value = 65535.f;
|
||||||
|
|
||||||
values[i] = (unsigned short) value;
|
values[i] = (unsigned short) value;
|
||||||
}
|
}
|
||||||
|
@ -165,6 +165,11 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
@ -329,21 +329,52 @@ static void destroyContextWGL(_GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize WGL-specific extensions
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
////// GLFW internal API //////
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Initialize WGL
|
||||||
//
|
//
|
||||||
static void loadWGLExtensions(void)
|
GLFWbool _glfwInitWGL(void)
|
||||||
{
|
{
|
||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
HGLRC rc;
|
HGLRC prc, rc;
|
||||||
HDC dc = GetDC(_glfw.win32.helperWindowHandle);;
|
HDC pdc, dc;
|
||||||
|
|
||||||
_glfw.wgl.extensionsLoaded = GLFW_TRUE;
|
if (_glfw.wgl.instance)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
|
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
||||||
|
if (!_glfw.wgl.instance)
|
||||||
|
{
|
||||||
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
|
"WGL: Failed to load opengl32.dll");
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
|
||||||
|
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
|
||||||
|
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
|
||||||
|
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
|
||||||
|
_glfw.wgl.GetCurrentContext = (PFN_wglGetCurrentContext)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentContext");
|
||||||
|
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
|
||||||
|
_glfw.wgl.ShareLists = (PFN_wglShareLists)
|
||||||
|
GetProcAddress(_glfw.wgl.instance, "wglShareLists");
|
||||||
|
|
||||||
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
// NOTE: A dummy context has to be created for opengl32.dll to load the
|
||||||
// OpenGL ICD, from which we can then query WGL extensions
|
// OpenGL ICD, from which we can then query WGL extensions
|
||||||
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
|
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
|
||||||
// creation failure occurs during manual pixel format enumeration
|
// creation failure occurs during manual pixel format enumeration
|
||||||
|
|
||||||
|
dc = GetDC(_glfw.win32.helperWindowHandle);;
|
||||||
|
|
||||||
ZeroMemory(&pfd, sizeof(pfd));
|
ZeroMemory(&pfd, sizeof(pfd));
|
||||||
pfd.nSize = sizeof(pfd);
|
pfd.nSize = sizeof(pfd);
|
||||||
pfd.nVersion = 1;
|
pfd.nVersion = 1;
|
||||||
@ -355,7 +386,7 @@ static void loadWGLExtensions(void)
|
|||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to set pixel format for dummy context");
|
"WGL: Failed to set pixel format for dummy context");
|
||||||
return;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = wglCreateContext(dc);
|
rc = wglCreateContext(dc);
|
||||||
@ -363,15 +394,19 @@ static void loadWGLExtensions(void)
|
|||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to create dummy context");
|
"WGL: Failed to create dummy context");
|
||||||
return;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdc = wglGetCurrentDC();
|
||||||
|
prc = wglGetCurrentContext();
|
||||||
|
|
||||||
if (!wglMakeCurrent(dc, rc))
|
if (!wglMakeCurrent(dc, rc))
|
||||||
{
|
{
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
||||||
"WGL: Failed to make dummy context current");
|
"WGL: Failed to make dummy context current");
|
||||||
|
wglMakeCurrent(pdc, prc);
|
||||||
wglDeleteContext(rc);
|
wglDeleteContext(rc);
|
||||||
return;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: Functions must be loaded first as they're needed to retrieve the
|
// NOTE: Functions must be loaded first as they're needed to retrieve the
|
||||||
@ -414,43 +449,8 @@ static void loadWGLExtensions(void)
|
|||||||
_glfw.wgl.ARB_context_flush_control =
|
_glfw.wgl.ARB_context_flush_control =
|
||||||
extensionSupportedWGL("WGL_ARB_context_flush_control");
|
extensionSupportedWGL("WGL_ARB_context_flush_control");
|
||||||
|
|
||||||
wglMakeCurrent(dc, NULL);
|
wglMakeCurrent(pdc, prc);
|
||||||
wglDeleteContext(rc);
|
wglDeleteContext(rc);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Initialize WGL
|
|
||||||
//
|
|
||||||
GLFWbool _glfwInitWGL(void)
|
|
||||||
{
|
|
||||||
if (_glfw.wgl.instance)
|
|
||||||
return GLFW_TRUE;
|
|
||||||
|
|
||||||
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
|
||||||
if (!_glfw.wgl.instance)
|
|
||||||
{
|
|
||||||
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
|
|
||||||
"WGL: Failed to load opengl32.dll");
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfw.wgl.CreateContext = (PFN_wglCreateContext)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglCreateContext");
|
|
||||||
_glfw.wgl.DeleteContext = (PFN_wglDeleteContext)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglDeleteContext");
|
|
||||||
_glfw.wgl.GetProcAddress = (PFN_wglGetProcAddress)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglGetProcAddress");
|
|
||||||
_glfw.wgl.GetCurrentDC = (PFN_wglGetCurrentDC)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglGetCurrentDC");
|
|
||||||
_glfw.wgl.MakeCurrent = (PFN_wglMakeCurrent)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglMakeCurrent");
|
|
||||||
_glfw.wgl.ShareLists = (PFN_wglShareLists)
|
|
||||||
GetProcAddress(_glfw.wgl.instance, "wglShareLists");
|
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,9 +480,6 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
|
|||||||
PIXELFORMATDESCRIPTOR pfd;
|
PIXELFORMATDESCRIPTOR pfd;
|
||||||
HGLRC share = NULL;
|
HGLRC share = NULL;
|
||||||
|
|
||||||
if (!_glfw.wgl.extensionsLoaded)
|
|
||||||
loadWGLExtensions();
|
|
||||||
|
|
||||||
if (ctxconfig->share)
|
if (ctxconfig->share)
|
||||||
share = ctxconfig->share->context.wgl.handle;
|
share = ctxconfig->share->context.wgl.handle;
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC);
|
|||||||
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
typedef BOOL (WINAPI * PFN_wglDeleteContext)(HGLRC);
|
||||||
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
typedef PROC (WINAPI * PFN_wglGetProcAddress)(LPCSTR);
|
||||||
typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
|
||||||
|
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(void);
|
||||||
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
typedef BOOL (WINAPI * PFN_wglMakeCurrent)(HDC,HGLRC);
|
||||||
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
||||||
|
|
||||||
@ -94,6 +95,7 @@ typedef BOOL (WINAPI * PFN_wglShareLists)(HGLRC,HGLRC);
|
|||||||
#define wglDeleteContext _glfw.wgl.DeleteContext
|
#define wglDeleteContext _glfw.wgl.DeleteContext
|
||||||
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
#define wglGetProcAddress _glfw.wgl.GetProcAddress
|
||||||
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
|
#define wglGetCurrentDC _glfw.wgl.GetCurrentDC
|
||||||
|
#define wglGetCurrentContext _glfw.wgl.GetCurrentContext
|
||||||
#define wglMakeCurrent _glfw.wgl.MakeCurrent
|
#define wglMakeCurrent _glfw.wgl.MakeCurrent
|
||||||
#define wglShareLists _glfw.wgl.ShareLists
|
#define wglShareLists _glfw.wgl.ShareLists
|
||||||
|
|
||||||
@ -124,11 +126,10 @@ typedef struct _GLFWlibraryWGL
|
|||||||
PFN_wglDeleteContext DeleteContext;
|
PFN_wglDeleteContext DeleteContext;
|
||||||
PFN_wglGetProcAddress GetProcAddress;
|
PFN_wglGetProcAddress GetProcAddress;
|
||||||
PFN_wglGetCurrentDC GetCurrentDC;
|
PFN_wglGetCurrentDC GetCurrentDC;
|
||||||
|
PFN_wglGetCurrentContext GetCurrentContext;
|
||||||
PFN_wglMakeCurrent MakeCurrent;
|
PFN_wglMakeCurrent MakeCurrent;
|
||||||
PFN_wglShareLists ShareLists;
|
PFN_wglShareLists ShareLists;
|
||||||
|
|
||||||
GLFWbool extensionsLoaded;
|
|
||||||
|
|
||||||
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
PFNWGLSWAPINTERVALEXTPROC SwapIntervalEXT;
|
||||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
PFNWGLGETPIXELFORMATATTRIBIVARBPROC GetPixelFormatAttribivARB;
|
||||||
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
|
||||||
|
@ -351,6 +351,7 @@ static HWND createHelperWindow(void)
|
|||||||
dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
dbi.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||||
dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
|
dbi.dbcc_classguid = GUID_DEVINTERFACE_HID;
|
||||||
|
|
||||||
|
_glfw.win32.deviceNotificationHandle =
|
||||||
RegisterDeviceNotificationW(window,
|
RegisterDeviceNotificationW(window,
|
||||||
(DEV_BROADCAST_HDR*) &dbi,
|
(DEV_BROADCAST_HDR*) &dbi,
|
||||||
DEVICE_NOTIFY_WINDOW_HANDLE);
|
DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||||
@ -543,6 +544,9 @@ int _glfwPlatformInit(void)
|
|||||||
|
|
||||||
void _glfwPlatformTerminate(void)
|
void _glfwPlatformTerminate(void)
|
||||||
{
|
{
|
||||||
|
if (_glfw.win32.deviceNotificationHandle)
|
||||||
|
UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle);
|
||||||
|
|
||||||
if (_glfw.win32.helperWindowHandle)
|
if (_glfw.win32.helperWindowHandle)
|
||||||
DestroyWindow(_glfw.win32.helperWindowHandle);
|
DestroyWindow(_glfw.win32.helperWindowHandle);
|
||||||
|
|
||||||
|
@ -188,12 +188,11 @@ WINUSERAPI BOOL WINAPI GetPointerInfo(UINT32,POINTER_INFO*);
|
|||||||
#endif /*Windows 8 and above*/
|
#endif /*Windows 8 and above*/
|
||||||
|
|
||||||
#if WINVER < 0x0601
|
#if WINVER < 0x0601
|
||||||
typedef struct tagCHANGEFILTERSTRUCT
|
typedef struct
|
||||||
{
|
{
|
||||||
DWORD cbSize;
|
DWORD cbSize;
|
||||||
DWORD ExtStatus;
|
DWORD ExtStatus;
|
||||||
|
} CHANGEFILTERSTRUCT;
|
||||||
} CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT;
|
|
||||||
#ifndef MSGFLT_ALLOW
|
#ifndef MSGFLT_ALLOW
|
||||||
#define MSGFLT_ALLOW 1
|
#define MSGFLT_ALLOW 1
|
||||||
#endif
|
#endif
|
||||||
@ -212,13 +211,13 @@ typedef struct
|
|||||||
#endif /*Windows Vista*/
|
#endif /*Windows Vista*/
|
||||||
|
|
||||||
#ifndef DPI_ENUMS_DECLARED
|
#ifndef DPI_ENUMS_DECLARED
|
||||||
typedef enum PROCESS_DPI_AWARENESS
|
typedef enum
|
||||||
{
|
{
|
||||||
PROCESS_DPI_UNAWARE = 0,
|
PROCESS_DPI_UNAWARE = 0,
|
||||||
PROCESS_SYSTEM_DPI_AWARE = 1,
|
PROCESS_SYSTEM_DPI_AWARE = 1,
|
||||||
PROCESS_PER_MONITOR_DPI_AWARE = 2
|
PROCESS_PER_MONITOR_DPI_AWARE = 2
|
||||||
} PROCESS_DPI_AWARENESS;
|
} PROCESS_DPI_AWARENESS;
|
||||||
typedef enum MONITOR_DPI_TYPE
|
typedef enum
|
||||||
{
|
{
|
||||||
MDT_EFFECTIVE_DPI = 0,
|
MDT_EFFECTIVE_DPI = 0,
|
||||||
MDT_ANGULAR_DPI = 1,
|
MDT_ANGULAR_DPI = 1,
|
||||||
@ -292,7 +291,7 @@ typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*
|
|||||||
|
|
||||||
// user32.dll function pointer typedefs
|
// user32.dll function pointer typedefs
|
||||||
typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
|
typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
|
||||||
typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,PCHANGEFILTERSTRUCT);
|
typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
|
||||||
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
|
||||||
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
|
||||||
|
|
||||||
@ -372,6 +371,7 @@ typedef struct _GLFWwindowWin32
|
|||||||
typedef struct _GLFWlibraryWin32
|
typedef struct _GLFWlibraryWin32
|
||||||
{
|
{
|
||||||
HWND helperWindowHandle;
|
HWND helperWindowHandle;
|
||||||
|
HDEVNOTIFY deviceNotificationHandle;
|
||||||
DWORD foregroundLockTimeout;
|
DWORD foregroundLockTimeout;
|
||||||
int acquiredMonitorCount;
|
int acquiredMonitorCount;
|
||||||
char* clipboardString;
|
char* clipboardString;
|
||||||
|
@ -386,14 +386,18 @@ static int getKeyMods(void)
|
|||||||
{
|
{
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
|
|
||||||
if (GetKeyState(VK_SHIFT) & (1 << 31))
|
if (GetKeyState(VK_SHIFT) & 0x8000)
|
||||||
mods |= GLFW_MOD_SHIFT;
|
mods |= GLFW_MOD_SHIFT;
|
||||||
if (GetKeyState(VK_CONTROL) & (1 << 31))
|
if (GetKeyState(VK_CONTROL) & 0x8000)
|
||||||
mods |= GLFW_MOD_CONTROL;
|
mods |= GLFW_MOD_CONTROL;
|
||||||
if (GetKeyState(VK_MENU) & (1 << 31))
|
if (GetKeyState(VK_MENU) & 0x8000)
|
||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & (1 << 31))
|
if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
|
if (GetKeyState(VK_CAPITAL) & 1)
|
||||||
|
mods |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
if (GetKeyState(VK_NUMLOCK) & 1)
|
||||||
|
mods |= GLFW_MOD_NUM_LOCK;
|
||||||
|
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
@ -404,14 +408,18 @@ static int getAsyncKeyMods(void)
|
|||||||
{
|
{
|
||||||
int mods = 0;
|
int mods = 0;
|
||||||
|
|
||||||
if (GetAsyncKeyState(VK_SHIFT) & (1 << 31))
|
if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
|
||||||
mods |= GLFW_MOD_SHIFT;
|
mods |= GLFW_MOD_SHIFT;
|
||||||
if (GetAsyncKeyState(VK_CONTROL) & (1 << 31))
|
if (GetAsyncKeyState(VK_CONTROL) & 0x8000)
|
||||||
mods |= GLFW_MOD_CONTROL;
|
mods |= GLFW_MOD_CONTROL;
|
||||||
if (GetAsyncKeyState(VK_MENU) & (1 << 31))
|
if (GetAsyncKeyState(VK_MENU) & 0x8000)
|
||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & (1 << 31))
|
if ((GetAsyncKeyState(VK_LWIN) | GetAsyncKeyState(VK_RWIN)) & 0x8000)
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
|
if (GetAsyncKeyState(VK_CAPITAL) & 1)
|
||||||
|
mods |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
if (GetAsyncKeyState(VK_NUMLOCK) & 1)
|
||||||
|
mods |= GLFW_MOD_NUM_LOCK;
|
||||||
|
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
@ -1051,6 +1059,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WM_DPICHANGED:
|
||||||
|
{
|
||||||
|
const float xscale = HIWORD(wParam) / 96.f;
|
||||||
|
const float yscale = LOWORD(wParam) / 96.f;
|
||||||
|
_glfwInputWindowContentScale(window, xscale, yscale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
{
|
{
|
||||||
if (LOWORD(lParam) == HTCLIENT)
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
@ -1506,7 +1522,7 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
|
|||||||
|
|
||||||
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
void _glfwPlatformShowWindow(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
ShowWindow(window->win32.handle, SW_SHOW);
|
ShowWindow(window->win32.handle, SW_SHOWNA);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
void _glfwPlatformHideWindow(_GLFWwindow* window)
|
||||||
@ -1625,6 +1641,11 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return IsZoomed(window->win32.handle);
|
return IsZoomed(window->win32.handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return cursorInClientArea(window);
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->win32.transparent && _glfwIsCompositionEnabledWin32();
|
return window->win32.transparent && _glfwIsCompositionEnabledWin32();
|
||||||
|
63
src/window.c
63
src/window.c
@ -93,6 +93,12 @@ void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
|||||||
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _glfwInputWindowContentScale(_GLFWwindow* window, float xscale, float yscale)
|
||||||
|
{
|
||||||
|
if (window->callbacks.scale)
|
||||||
|
window->callbacks.scale((GLFWwindow*) window, xscale, yscale);
|
||||||
|
}
|
||||||
|
|
||||||
void _glfwInputWindowDamage(_GLFWwindow* window)
|
void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (window->callbacks.refresh)
|
if (window->callbacks.refresh)
|
||||||
@ -126,7 +132,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
_GLFWctxconfig ctxconfig;
|
_GLFWctxconfig ctxconfig;
|
||||||
_GLFWwndconfig wndconfig;
|
_GLFWwndconfig wndconfig;
|
||||||
_GLFWwindow* window;
|
_GLFWwindow* window;
|
||||||
_GLFWwindow* previous;
|
|
||||||
|
|
||||||
assert(title != NULL);
|
assert(title != NULL);
|
||||||
assert(width >= 0);
|
assert(width >= 0);
|
||||||
@ -190,33 +195,20 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|||||||
window->numer = GLFW_DONT_CARE;
|
window->numer = GLFW_DONT_CARE;
|
||||||
window->denom = GLFW_DONT_CARE;
|
window->denom = GLFW_DONT_CARE;
|
||||||
|
|
||||||
// Save the currently current context so it can be restored later
|
|
||||||
previous = _glfwPlatformGetTls(&_glfw.contextSlot);
|
|
||||||
if (ctxconfig.client != GLFW_NO_API)
|
|
||||||
glfwMakeContextCurrent(NULL);
|
|
||||||
|
|
||||||
// Open the actual window and create its context
|
// Open the actual window and create its context
|
||||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
||||||
{
|
{
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctxconfig.client != GLFW_NO_API)
|
if (ctxconfig.client != GLFW_NO_API)
|
||||||
{
|
{
|
||||||
window->context.makeCurrent(window);
|
if (!_glfwRefreshContextAttribs(window, &ctxconfig))
|
||||||
|
|
||||||
// Retrieve the actual (as opposed to requested) context attributes
|
|
||||||
if (!_glfwRefreshContextAttribs(&ctxconfig))
|
|
||||||
{
|
{
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
|
||||||
glfwDestroyWindow((GLFWwindow*) window);
|
glfwDestroyWindow((GLFWwindow*) window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the previously current context (or NULL)
|
|
||||||
glfwMakeContextCurrent((GLFWwindow*) previous);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window->monitor)
|
if (!window->monitor)
|
||||||
@ -348,9 +340,6 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
||||||
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
return;
|
return;
|
||||||
case GLFW_COCOA_FRAME_AUTOSAVE:
|
|
||||||
_glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE;
|
|
||||||
return;
|
|
||||||
case GLFW_COCOA_GRAPHICS_SWITCHING:
|
case GLFW_COCOA_GRAPHICS_SWITCHING:
|
||||||
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
|
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
|
||||||
return;
|
return;
|
||||||
@ -395,6 +384,31 @@ GLFWAPI void glfwWindowHint(int hint, int value)
|
|||||||
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint 0x%08X", hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI void glfwWindowHintString(int hint, const char* value)
|
||||||
|
{
|
||||||
|
assert(value != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT();
|
||||||
|
|
||||||
|
switch (hint)
|
||||||
|
{
|
||||||
|
case GLFW_COCOA_FRAME_NAME:
|
||||||
|
strncpy(_glfw.hints.window.ns.frameName, value,
|
||||||
|
sizeof(_glfw.hints.window.ns.frameName) - 1);
|
||||||
|
return;
|
||||||
|
case GLFW_X11_CLASS_NAME:
|
||||||
|
strncpy(_glfw.hints.window.x11.className, value,
|
||||||
|
sizeof(_glfw.hints.window.x11.className) - 1);
|
||||||
|
return;
|
||||||
|
case GLFW_X11_INSTANCE_NAME:
|
||||||
|
strncpy(_glfw.hints.window.x11.instanceName, value,
|
||||||
|
sizeof(_glfw.hints.window.x11.instanceName) - 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint string 0x%08X", hint);
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
||||||
{
|
{
|
||||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
@ -770,6 +784,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
|||||||
return _glfwPlatformWindowVisible(window);
|
return _glfwPlatformWindowVisible(window);
|
||||||
case GLFW_MAXIMIZED:
|
case GLFW_MAXIMIZED:
|
||||||
return _glfwPlatformWindowMaximized(window);
|
return _glfwPlatformWindowMaximized(window);
|
||||||
|
case GLFW_HOVERED:
|
||||||
|
return _glfwPlatformWindowHovered(window);
|
||||||
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
case GLFW_TRANSPARENT_FRAMEBUFFER:
|
||||||
return _glfwPlatformFramebufferTransparent(window);
|
return _glfwPlatformFramebufferTransparent(window);
|
||||||
case GLFW_RESIZABLE:
|
case GLFW_RESIZABLE:
|
||||||
@ -1004,6 +1020,17 @@ GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle
|
|||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow* handle,
|
||||||
|
GLFWwindowcontentscalefun cbfun)
|
||||||
|
{
|
||||||
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||||
|
assert(window != NULL);
|
||||||
|
|
||||||
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
|
_GLFW_SWAP_POINTERS(window->callbacks.scale, cbfun);
|
||||||
|
return cbfun;
|
||||||
|
}
|
||||||
|
|
||||||
GLFWAPI void glfwPollEvents(void)
|
GLFWAPI void glfwPollEvents(void)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT();
|
_GLFW_REQUIRE_INIT();
|
||||||
|
@ -54,6 +54,8 @@ static void pointerHandleEnter(void* data,
|
|||||||
_glfw.wl.pointerSerial = serial;
|
_glfw.wl.pointerSerial = serial;
|
||||||
_glfw.wl.pointerFocus = window;
|
_glfw.wl.pointerFocus = window;
|
||||||
|
|
||||||
|
window->wl.hovered = GLFW_TRUE;
|
||||||
|
|
||||||
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
_glfwPlatformSetCursor(window, window->wl.currentCursor);
|
||||||
_glfwInputCursorEnter(window, GLFW_TRUE);
|
_glfwInputCursorEnter(window, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
@ -68,6 +70,8 @@ static void pointerHandleLeave(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
window->wl.hovered = GLFW_FALSE;
|
||||||
|
|
||||||
_glfw.wl.pointerSerial = serial;
|
_glfw.wl.pointerSerial = serial;
|
||||||
_glfw.wl.pointerFocus = NULL;
|
_glfw.wl.pointerFocus = NULL;
|
||||||
_glfwInputCursorEnter(window, GLFW_FALSE);
|
_glfwInputCursorEnter(window, GLFW_FALSE);
|
||||||
@ -137,6 +141,9 @@ static void pointerHandleAxis(void* data,
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
|
||||||
|
axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
|
||||||
|
|
||||||
/* Wayland scroll events are in pointer motion coordinate space (think
|
/* Wayland scroll events are in pointer motion coordinate space (think
|
||||||
* two finger scroll). The factor 10 is commonly used to convert to
|
* two finger scroll). The factor 10 is commonly used to convert to
|
||||||
* "scroll step means 1.0. */
|
* "scroll step means 1.0. */
|
||||||
@ -152,9 +159,6 @@ static void pointerHandleAxis(void* data,
|
|||||||
x = 0.0;
|
x = 0.0;
|
||||||
y = wl_fixed_to_double(value) * scrollFactor;
|
y = wl_fixed_to_double(value) * scrollFactor;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
assert(GLFW_FALSE);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwInputScroll(window, x, y);
|
_glfwInputScroll(window, x, y);
|
||||||
@ -264,6 +268,10 @@ static void keyboardHandleKeymap(void* data,
|
|||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
|
||||||
_glfw.wl.xkb.superMask =
|
_glfw.wl.xkb.superMask =
|
||||||
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
||||||
|
_glfw.wl.xkb.capsLockMask =
|
||||||
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
|
||||||
|
_glfw.wl.xkb.numLockMask =
|
||||||
|
1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboardHandleEnter(void* data,
|
static void keyboardHandleEnter(void* data,
|
||||||
@ -409,6 +417,10 @@ static void keyboardHandleModifiers(void* data,
|
|||||||
modifiers |= GLFW_MOD_SHIFT;
|
modifiers |= GLFW_MOD_SHIFT;
|
||||||
if (mask & _glfw.wl.xkb.superMask)
|
if (mask & _glfw.wl.xkb.superMask)
|
||||||
modifiers |= GLFW_MOD_SUPER;
|
modifiers |= GLFW_MOD_SUPER;
|
||||||
|
if (mask & _glfw.wl.xkb.capsLockMask)
|
||||||
|
modifiers |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
if (mask & _glfw.wl.xkb.numLockMask)
|
||||||
|
modifiers |= GLFW_MOD_NUM_LOCK;
|
||||||
_glfw.wl.xkb.modifiers = modifiers;
|
_glfw.wl.xkb.modifiers = modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,15 +775,22 @@ void _glfwPlatformTerminate(void)
|
|||||||
_glfwTerminateJoysticksLinux();
|
_glfwTerminateJoysticksLinux();
|
||||||
|
|
||||||
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
#ifdef HAVE_XKBCOMMON_COMPOSE_H
|
||||||
|
if (_glfw.wl.xkb.composeState)
|
||||||
xkb_compose_state_unref(_glfw.wl.xkb.composeState);
|
xkb_compose_state_unref(_glfw.wl.xkb.composeState);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (_glfw.wl.xkb.keymap)
|
||||||
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
xkb_keymap_unref(_glfw.wl.xkb.keymap);
|
||||||
|
if (_glfw.wl.xkb.state)
|
||||||
xkb_state_unref(_glfw.wl.xkb.state);
|
xkb_state_unref(_glfw.wl.xkb.state);
|
||||||
|
if (_glfw.wl.xkb.context)
|
||||||
xkb_context_unref(_glfw.wl.xkb.context);
|
xkb_context_unref(_glfw.wl.xkb.context);
|
||||||
|
|
||||||
dlclose(_glfw.wl.xkb.handle);
|
if (_glfw.wl.xkb.handle)
|
||||||
|
{
|
||||||
|
_glfw_dlclose(_glfw.wl.xkb.handle);
|
||||||
_glfw.wl.xkb.handle = NULL;
|
_glfw.wl.xkb.handle = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (_glfw.wl.cursorTheme)
|
if (_glfw.wl.cursorTheme)
|
||||||
wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
|
wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
|
||||||
|
@ -117,6 +117,7 @@ typedef struct _GLFWwindowWayland
|
|||||||
int width, height;
|
int width, height;
|
||||||
GLFWbool visible;
|
GLFWbool visible;
|
||||||
GLFWbool maximized;
|
GLFWbool maximized;
|
||||||
|
GLFWbool hovered;
|
||||||
GLFWbool transparent;
|
GLFWbool transparent;
|
||||||
struct wl_surface* surface;
|
struct wl_surface* surface;
|
||||||
struct wl_egl_window* native;
|
struct wl_egl_window* native;
|
||||||
@ -183,6 +184,8 @@ typedef struct _GLFWlibraryWayland
|
|||||||
xkb_mod_mask_t altMask;
|
xkb_mod_mask_t altMask;
|
||||||
xkb_mod_mask_t shiftMask;
|
xkb_mod_mask_t shiftMask;
|
||||||
xkb_mod_mask_t superMask;
|
xkb_mod_mask_t superMask;
|
||||||
|
xkb_mod_mask_t capsLockMask;
|
||||||
|
xkb_mod_mask_t numLockMask;
|
||||||
unsigned int modifiers;
|
unsigned int modifiers;
|
||||||
|
|
||||||
PFN_xkb_context_new context_new;
|
PFN_xkb_context_new context_new;
|
||||||
|
@ -125,6 +125,7 @@ static void checkScaleChange(_GLFWwindow* window)
|
|||||||
wl_surface_set_buffer_scale(window->wl.surface, scale);
|
wl_surface_set_buffer_scale(window->wl.surface, scale);
|
||||||
wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
|
wl_egl_window_resize(window->wl.native, scaledWidth, scaledHeight, 0, 0);
|
||||||
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
|
_glfwInputFramebufferSize(window, scaledWidth, scaledHeight);
|
||||||
|
_glfwInputWindowContentScale(window, scale, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,6 +693,11 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return window->wl.maximized;
|
return window->wl.maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
return window->wl.hovered;
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
return window->wl.transparent;
|
return window->wl.transparent;
|
||||||
|
@ -212,6 +212,10 @@ static int translateState(int state)
|
|||||||
mods |= GLFW_MOD_ALT;
|
mods |= GLFW_MOD_ALT;
|
||||||
if (state & Mod4Mask)
|
if (state & Mod4Mask)
|
||||||
mods |= GLFW_MOD_SUPER;
|
mods |= GLFW_MOD_SUPER;
|
||||||
|
if (state & LockMask)
|
||||||
|
mods |= GLFW_MOD_CAPS_LOCK;
|
||||||
|
if (state & Mod2Mask)
|
||||||
|
mods |= GLFW_MOD_NUM_LOCK;
|
||||||
|
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
@ -707,20 +711,25 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
XClassHint* hint = XAllocClassHint();
|
XClassHint* hint = XAllocClassHint();
|
||||||
|
|
||||||
if (strlen(_glfw.hints.init.x11.className) &&
|
if (strlen(wndconfig->x11.instanceName) &&
|
||||||
strlen(_glfw.hints.init.x11.classClass))
|
strlen(wndconfig->x11.className))
|
||||||
{
|
{
|
||||||
hint->res_name = (char*) _glfw.hints.init.x11.className;
|
hint->res_name = (char*) wndconfig->x11.instanceName;
|
||||||
hint->res_class = (char*) _glfw.hints.init.x11.classClass;
|
hint->res_class = (char*) wndconfig->x11.className;
|
||||||
}
|
|
||||||
else if (strlen(wndconfig->title))
|
|
||||||
{
|
|
||||||
hint->res_name = (char*) wndconfig->title;
|
|
||||||
hint->res_class = (char*) wndconfig->title;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
const char* resourceName = getenv("RESOURCE_NAME");
|
||||||
|
if (resourceName && strlen(resourceName))
|
||||||
|
hint->res_name = (char*) resourceName;
|
||||||
|
else if (strlen(wndconfig->title))
|
||||||
|
hint->res_name = (char*) wndconfig->title;
|
||||||
|
else
|
||||||
hint->res_name = (char*) "glfw-application";
|
hint->res_name = (char*) "glfw-application";
|
||||||
|
|
||||||
|
if (strlen(wndconfig->title))
|
||||||
|
hint->res_class = (char*) wndconfig->title;
|
||||||
|
else
|
||||||
hint->res_class = (char*) "GLFW-Application";
|
hint->res_class = (char*) "GLFW-Application";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2444,6 +2453,28 @@ int _glfwPlatformWindowMaximized(_GLFWwindow* window)
|
|||||||
return maximized;
|
return maximized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int _glfwPlatformWindowHovered(_GLFWwindow* window)
|
||||||
|
{
|
||||||
|
Window w = _glfw.x11.root;
|
||||||
|
while (w)
|
||||||
|
{
|
||||||
|
Window root;
|
||||||
|
int rootX, rootY, childX, childY;
|
||||||
|
unsigned int mask;
|
||||||
|
|
||||||
|
if (!XQueryPointer(_glfw.x11.display, w,
|
||||||
|
&root, &w, &rootX, &rootY, &childX, &childY, &mask))
|
||||||
|
{
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (w == window->x11.handle)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLFW_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
|
||||||
{
|
{
|
||||||
if (!window->x11.transparent)
|
if (!window->x11.transparent)
|
||||||
|
@ -33,7 +33,7 @@ add_executable(icon WIN32 MACOSX_BUNDLE icon.c ${GLAD})
|
|||||||
add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD})
|
add_executable(inputlag WIN32 MACOSX_BUNDLE inputlag.c ${GETOPT} ${GLAD})
|
||||||
add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD})
|
add_executable(joysticks WIN32 MACOSX_BUNDLE joysticks.c ${GLAD})
|
||||||
add_executable(opacity WIN32 MACOSX_BUNDLE opacity.c ${GLAD})
|
add_executable(opacity WIN32 MACOSX_BUNDLE opacity.c ${GLAD})
|
||||||
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GETOPT} ${GLAD})
|
add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD})
|
||||||
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD})
|
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD})
|
||||||
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD})
|
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD})
|
||||||
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD})
|
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD})
|
||||||
|
@ -244,6 +244,10 @@ static const char* get_mods_name(int mods)
|
|||||||
strcat(name, " alt");
|
strcat(name, " alt");
|
||||||
if (mods & GLFW_MOD_SUPER)
|
if (mods & GLFW_MOD_SUPER)
|
||||||
strcat(name, " super");
|
strcat(name, " super");
|
||||||
|
if (mods & GLFW_MOD_CAPS_LOCK)
|
||||||
|
strcat(name, " capslock-on");
|
||||||
|
if (mods & GLFW_MOD_NUM_LOCK)
|
||||||
|
strcat(name, " numlock-on");
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -289,6 +293,13 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
|
||||||
|
{
|
||||||
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
|
printf("%08x to %i at %0.3f: Window content scale: %0.3f %0.3f\n",
|
||||||
|
counter++, slot->number, glfwGetTime(), xscale, yscale);
|
||||||
|
}
|
||||||
|
|
||||||
static void window_close_callback(GLFWwindow* window)
|
static void window_close_callback(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
Slot* slot = glfwGetWindowUserPointer(window);
|
Slot* slot = glfwGetWindowUserPointer(window);
|
||||||
@ -411,6 +422,15 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled");
|
printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case GLFW_KEY_L:
|
||||||
|
{
|
||||||
|
const int state = glfwGetInputMode(window, GLFW_LOCK_KEY_MODS);
|
||||||
|
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, !state);
|
||||||
|
|
||||||
|
printf("(( lock key mods %s ))\n", !state ? "enabled" : "disabled");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,6 +617,7 @@ int main(int argc, char** argv)
|
|||||||
glfwSetWindowPosCallback(slots[i].window, window_pos_callback);
|
glfwSetWindowPosCallback(slots[i].window, window_pos_callback);
|
||||||
glfwSetWindowSizeCallback(slots[i].window, window_size_callback);
|
glfwSetWindowSizeCallback(slots[i].window, window_size_callback);
|
||||||
glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(slots[i].window, framebuffer_size_callback);
|
||||||
|
glfwSetWindowContentScaleCallback(slots[i].window, window_content_scale_callback);
|
||||||
glfwSetWindowCloseCallback(slots[i].window, window_close_callback);
|
glfwSetWindowCloseCallback(slots[i].window, window_close_callback);
|
||||||
glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback);
|
glfwSetWindowRefreshCallback(slots[i].window, window_refresh_callback);
|
||||||
glfwSetWindowFocusCallback(slots[i].window, window_focus_callback);
|
glfwSetWindowFocusCallback(slots[i].window, window_focus_callback);
|
||||||
|
@ -135,13 +135,13 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
glfwGetWindowSize(window, &width, &height);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
area = nk_rect(0.f, 0.f, (float) width, (float) height);
|
area = nk_rect(0.f, 0.f, (float) width, (float) height);
|
||||||
|
nk_window_set_bounds(nk, "", area);
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
nk_glfw3_new_frame();
|
nk_glfw3_new_frame();
|
||||||
if (nk_begin(nk, "", area, 0))
|
if (nk_begin(nk, "", area, 0))
|
||||||
{
|
{
|
||||||
const GLFWgammaramp* ramp;
|
const GLFWgammaramp* ramp;
|
||||||
nk_window_set_bounds(nk, area);
|
|
||||||
|
|
||||||
nk_layout_row_dynamic(nk, 30, 3);
|
nk_layout_row_dynamic(nk, 30, 3);
|
||||||
if (nk_slider_float(nk, 0.1f, &gamma_value, 5.f, 0.1f))
|
if (nk_slider_float(nk, 0.1f, &gamma_value, 5.f, 0.1f))
|
||||||
|
@ -85,6 +85,32 @@ static void joystick_callback(int jid, int event)
|
|||||||
glfwRequestWindowAttention(window);
|
glfwRequestWindowAttention(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void drop_callback(GLFWwindow* window, int count, const char** paths)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
long size;
|
||||||
|
char* text;
|
||||||
|
FILE* stream = fopen(paths[i], "rb");
|
||||||
|
if (!stream)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fseek(stream, 0, SEEK_END);
|
||||||
|
size = ftell(stream);
|
||||||
|
fseek(stream, 0, SEEK_SET);
|
||||||
|
|
||||||
|
text = malloc(size + 1);
|
||||||
|
text[size] = '\0';
|
||||||
|
if (fread(text, 1, size, stream) == size)
|
||||||
|
glfwUpdateGamepadMappings(text);
|
||||||
|
|
||||||
|
free(text);
|
||||||
|
fclose(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static const char* joystick_label(int jid)
|
static const char* joystick_label(int jid)
|
||||||
{
|
{
|
||||||
static char label[1024];
|
static char label[1024];
|
||||||
@ -176,6 +202,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
glfwSetJoystickCallback(joystick_callback);
|
glfwSetJoystickCallback(joystick_callback);
|
||||||
|
glfwSetDropCallback(window, drop_callback);
|
||||||
|
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "linmath.h"
|
#include "linmath.h"
|
||||||
#include "getopt.h"
|
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
@ -69,14 +68,6 @@ static int swap_tear;
|
|||||||
static int swap_interval;
|
static int swap_interval;
|
||||||
static double frame_rate;
|
static double frame_rate;
|
||||||
|
|
||||||
static void usage(void)
|
|
||||||
{
|
|
||||||
printf("Usage: tearing [-h] [-f]\n");
|
|
||||||
printf("Options:\n");
|
|
||||||
printf(" -f create full screen window\n");
|
|
||||||
printf(" -h show this help\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void update_window_title(GLFWwindow* window)
|
static void update_window_title(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
char title[256];
|
char title[256];
|
||||||
@ -138,64 +129,50 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
|||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
glfwSetWindowShouldClose(window, 1);
|
glfwSetWindowShouldClose(window, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GLFW_KEY_F11:
|
||||||
|
case GLFW_KEY_ENTER:
|
||||||
|
{
|
||||||
|
static int x, y, width, height;
|
||||||
|
|
||||||
|
if (mods != GLFW_MOD_ALT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (glfwGetWindowMonitor(window))
|
||||||
|
glfwSetWindowMonitor(window, NULL, x, y, width, height, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
||||||
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||||
|
glfwGetWindowPos(window, &x, &y);
|
||||||
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
glfwSetWindowMonitor(window, monitor,
|
||||||
|
0, 0, mode->width, mode->height,
|
||||||
|
mode->refreshRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ch, width, height;
|
|
||||||
unsigned long frame_count = 0;
|
unsigned long frame_count = 0;
|
||||||
double last_time, current_time;
|
double last_time, current_time;
|
||||||
int fullscreen = GLFW_FALSE;
|
|
||||||
GLFWmonitor* monitor = NULL;
|
|
||||||
GLFWwindow* window;
|
GLFWwindow* window;
|
||||||
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
|
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
|
||||||
GLint mvp_location, vpos_location;
|
GLint mvp_location, vpos_location;
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "fh")) != -1)
|
|
||||||
{
|
|
||||||
switch (ch)
|
|
||||||
{
|
|
||||||
case 'h':
|
|
||||||
usage();
|
|
||||||
exit(EXIT_SUCCESS);
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
fullscreen = GLFW_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
if (fullscreen)
|
|
||||||
{
|
|
||||||
const GLFWvidmode* mode;
|
|
||||||
|
|
||||||
monitor = glfwGetPrimaryMonitor();
|
|
||||||
mode = glfwGetVideoMode(monitor);
|
|
||||||
|
|
||||||
glfwWindowHint(GLFW_RED_BITS, mode->redBits);
|
|
||||||
glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits);
|
|
||||||
glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits);
|
|
||||||
glfwWindowHint(GLFW_REFRESH_RATE, mode->refreshRate);
|
|
||||||
|
|
||||||
width = mode->width;
|
|
||||||
height = mode->height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
width = 640;
|
|
||||||
height = 480;
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
|
||||||
|
|
||||||
window = glfwCreateWindow(width, height, "", monitor, NULL);
|
window = glfwCreateWindow(640, 480, "Tearing detector", NULL, NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
|
Loading…
Reference in New Issue
Block a user