Compare commits

...

131 Commits

Author SHA1 Message Date
Emmanuel Gil Peyrot 8e51c4a577 Tests: Add damage tracking to MSAA
This lets compositors avoid re-rendering the entire buffer when only the
outside of the squares changed.

If glfwGetBufferAge() returns 0 for any reason (the buffer was just
created, there was an error, or the underlying API doesn’t track buffer
age), we swap the entire buffer again.
2019-12-08 18:40:19 +01:00
Emmanuel Gil Peyrot c8233ce7d3 EGL: Implement glfwGetBufferAge()
This feature is provided by the EGL_EXT_buffer_age extension, otherwise
always return 0.
2019-12-08 18:40:19 +01:00
Emmanuel Gil Peyrot 0d2ce23071 Add a glfwGetBufferAge() symbol
This new API lets the application know when the current buffer was last
written to.  If it returns 0, it means the user shouldn’t rely on what
was last present in this buffer and should draw everything again, as
usual.

This provides a significant boost in efficiency, especially on tiling
GPUs, by letting the application avoid to clear and redraw everything at
every frame.
2019-12-08 18:40:19 +01:00
Emmanuel Gil Peyrot a94b96c954 Wayland: Bump wl_compositor for damage_buffer
wl_surface supports a damage_buffer request since its version 4, which
requires wl_compositor to have been bound at that version too.

damage_buffer can then be used by the EGL implementation to optimise
eglSwapBuffersWithDamageKHR().
2019-12-08 18:40:19 +01:00
Emmanuel Gil Peyrot 8e354c2259 EGL: Implement glfwSwapBufferWithDamage()
This is provided by the EGL_KHR_swap_buffers_with_damage extension.
2019-12-08 18:40:19 +01:00
Emmanuel Gil Peyrot e0b1f518cf Add a glfwSwapBuffersWithDamage() symbol
This new API helps the user’s compositor reduce memory bandwidth and
thus power usage by only re-rendering a bunch of dirty rectangles
instead of the entire application buffer.

There is no guarantee that it will effectively get used, it is perfectly
valid to continue damaging the entire buffer instead like with
glfwSwapBuffers() in some cases.
2019-12-08 18:40:19 +01:00
Camilla Löwy 7dbdd2e6a5 Add more standard cursors
This adds the standard cursors for diagonal and omnidirectional
resize/move and operation-not-allowed.  It also adds new (better?) names
for the horizontal and vertical resize/move and pointing hand cursors.

References:
 - https://developer.apple.com/documentation/appkit/nscursor
 - https://stackoverflow.com/questions/10733228/
 - https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setsystemcursor
 - https://freedesktop.org/wiki/Specifications/cursor-spec/
 - https://tronche.com/gui/x/xlib/appendix/b/

Related to #427.
2019-11-28 22:24:00 +01:00
Camilla Löwy 80fde12fda Wayland: Fix pointing hand cursor shape
Related to #1432.
2019-11-25 18:55:50 +01:00
Emmanuel Gil Peyrot a80788c17f Wayland: Don’t update cursor position in the frame
That way the application only sees the cursor moving when it is inside
of its area, it won’t go back to the top or left side when trying to
resize the window or just hovering the fallback decorations.
2019-11-21 13:53:08 +01:00
Emmanuel Gil Peyrot a9f674e719 Wayland: Don’t reload the cursor on every pointer motion
Previously, any pointer motion in the window decorations when using the
fallback implementation would obtain the wl_cursor again, and do the
attach danse for no benefit.

This will ultimately allow animated cursors to not reset to the first
frame on motion, once these will be implemented.
2019-11-21 13:52:37 +01:00
Camilla Löwy b5d4f24f74 Move CMake uninstall template file to CMake subdir 2019-11-14 21:49:14 +01:00
Camilla Löwy d861d7bffe Update .gitignore file
This adds missing entries for Ninja and the unavoidable clutter of the
modern Doxygen CMake module.
2019-11-14 19:50:19 +01:00
Camilla Löwy c42d8f3e5b Cleanup .gitignore file somewhat 2019-11-14 19:50:19 +01:00
Camilla Löwy 50a6270e55 Add initial CODEOWNERS file 2019-11-14 19:50:14 +01:00
Camilla Löwy b804379463 Add initial GH support file 2019-11-14 19:50:14 +01:00
Camilla Löwy 359758bb53 Add initial .mailmap file 2019-11-14 19:50:03 +01:00
Camilla Löwy e96dc5d219 X11: Assume 96 DPI if RandR monitor size is zero
This falls back to calculating the monitor physical size from the
current resolution and the default X11 DPI when the physical size
returned by RandR is zero.
2019-11-14 19:49:23 +01:00
Camilla Löwy 2c519709be Cocoa: Fix full screen window iconification
Iconification (miniaturization) of undecorated windows stopped working
unless the window has the NSWindowStyleMaskMiniaturizable style.
2019-11-13 14:08:28 +01:00
Camilla Löwy bd452016be Cocoa: Cleanup
Readability fix, does not affect generated code.
2019-11-11 22:49:00 +01:00
Camilla Löwy bac15f9449 Cocoa: Fix multiple methods warning
This fixes a warning due to us using bare ids and
NSCollectionLayoutAnchor having a message with the same name.
2019-11-11 22:49:00 +01:00
Camilla Löwy c819f27ce3 Cocoa: Process events after window destruction
On macOS a destroyed window remained on screen until the next time
events were processed.  This makes the behavior more consistent with
other platforms.

Fixes #1412.
2019-11-11 22:49:00 +01:00
Camilla Löwy 94cb0347ab Cocoa: Add comments for Cocoa symbol macros 2019-11-11 22:49:00 +01:00
Camilla Löwy 953a1c3f8b Cleanup 2019-11-11 22:37:18 +01:00
Guillaume Racicot 70a3104c49 Set C standard at 99 for all example targets
Closes #1593.
2019-11-11 22:37:18 +01:00
Guillaume Racicot bc5523e994 Set C standard at 99 for all test targets
Related to #1593.
2019-11-11 22:37:18 +01:00
Camilla Löwy 8e288dc94c Win32: Add GLFW_WIN32_KEYBOARD_MENU
This platform specific window hint enables access to the Windows window
menu via the keyboard shortcuts.
2019-11-11 22:37:18 +01:00
Camilla Löwy de23429455 Add reminder for why events test is not closing 2019-11-11 22:37:18 +01:00
Camilla Löwy 08f01c31a0 Add gamepad information to events test output 2019-11-11 22:37:18 +01:00
Camilla Löwy 20e522cdf4 Make events test output only UTF-8 in C locale 2019-11-11 22:37:18 +01:00
thewoz c5f1ca3e41 Add canonical build directory to .gitignore
Closes #1595.
2019-11-11 22:37:18 +01:00
Camilla Löwy b69fb99031 Remove mappings for GUID used by different devices
The SDL2 2.0.5+ controller GUID 03000000790000000600000000000000 matches
many devices with different layouts and element counts but with the same
chipset.  This issue is still being resolved upstream.  In the meantime
this removes those mappings from GLFW to avoid confusion and errors.

SDL upstream issue: https://bugzilla.libsdl.org/show_bug.cgi?id=4545

Related to #1583.
2019-11-11 22:37:18 +01:00
Camilla Löwy c88ee1c9d3 Win32: Change transparent framebuffer key color
This is a temporary fix while we determine if the color key workaround
should be removed completely.  See issue thread for discussion.

Related to #1512.
2019-11-11 22:37:13 +01:00
Camilla Löwy 28d8507700 Fix order of words in window guide
Fixes #1571.
2019-11-01 13:43:47 +01:00
Camilla Löwy 75294462b3 X11: Fix content scale fallback value on KDE
KDE sometimes removes the Xft.dpi resource when it would be set to the
X11 default value of 96, causing GLFW to fall back to a value calculated
from the core display sizes in pixels and mm in a desktop environment
that supports Xft.dpi.

This moves to a hardcoded fallback value of 96 on the assumption that
there are more people running KDE with 96 DPI than there are people
running desktop environments that do not support Xft.dpi.

All of this is terrible please send help.

Fixes #1578.
2019-10-29 12:04:47 +01:00
Camilla Löwy 5fc4c01302 X11: Fix decoration enabling after window creation
This fixes the enabling of window decorations after creation.  Instead
of removing the _MOTIF_WM_HINTS property, we now set or unset the
MWM_DECOR_ALL bit of the decorations field.

Fixes #1566.
2019-10-29 12:04:47 +01:00
Camilla Löwy 33683ec60e Remove stray characters from hardcoded CFLAGS
The additional '>' characters were appended to the compiler option.

Related to #1576.
2019-10-29 12:04:47 +01:00
Camilla Löwy 04f7f55f07 Cleanup
Related to #1585.
2019-10-29 12:04:47 +01:00
Pablo Prietz 4d0ae4ffa7 Fix CMake 3.0 - 3.6 support regression
Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR
VERSION_GREATER`.  `VERSION_GREATER_EQUAL` was only added in CMake 3.7.

Fixes #1584.
Closes #1585.
2019-10-29 12:04:46 +01:00
Camilla Löwy 82978bb3af Documentation work
This is the documentation update for the change introduced with
0b01d850ed, removing the requirement for
the forward-compatibility flag on macOS.
2019-10-29 12:04:22 +01:00
Camilla Löwy 376897a344 Replace notes for previous releases with links
The news / release notes page was getting a bit long.
2019-10-28 20:02:12 +01:00
Camilla Löwy 36c547875c Update changelog 2019-10-17 20:09:38 +02:00
Camilla Löwy 692754a2c5 Allow AppVeyor to skip pure documentation updates 2019-10-17 20:09:38 +02:00
Corentin Wallez 3a37a08998 Fix -Wextra-semi warnings
Closes #1440.
2019-10-17 20:09:38 +02:00
Luflosi 7749aac50d Use the correct type in a for loop
The `monitorCount` member in the `_GLFWlibrary` struct is of type `int`, so the `for` loop iterating over it should also use the type `int`.

Closes #1572.
2019-10-17 13:47:28 +02:00
Camilla Löwy 1e20218b3d Use HTTPS for Discourse forum 2019-10-16 02:33:12 +02:00
Camilla Löwy 545f409592 Add credit
Related to #1576.
2019-10-16 02:33:12 +02:00
Guillaume Racicot 8f852e0833 Enable C99 explicitly with CMake where available
This enables compilation as C99 where supported by the compiler.
A workaround with per-compiler hardcoded flags is used for CMake 3.0,
which does not support the C_STANDARD target property.

Fixes #1560.
Closes #1576.
2019-10-16 02:33:12 +02:00
Camilla Löwy f71b55f83d Clean up monitors tool output 2019-10-16 02:33:12 +02:00
Luflosi d25248343e Use the correct type for a struct member
The `name` member in the `_GLFWmonitorWayland` struct is used in two places. It is assigned the value from a variable of type `uint32_t` and is compared to another variable of type `uint32_t`, so `name` should also have the same type.

Closes #1569.
2019-10-06 17:36:46 +02:00
Camilla Löwy 1bd0a55aa7 Add VS 2010 and MinGW to AppVeyor build matrix
VS 2010 and MinGW are the two trickiest Windows environments so this
should hopefully catch more mistakes.  This is probably not the right
way to set up any of this, but it works for now.

This is also a first step towards building our release binaries with CI.

[skip travis]
2019-10-03 21:05:49 +02:00
Camilla Löwy 3d2540c373 Win32: Cleanup keyboard input flag parsing
This replaces some magic numbers with the corresponding winuser.h
provided macros and unifies how the MSB from Get*KeyState is tested.
2019-10-03 21:05:49 +02:00
Camilla Löwy 3ec8f4a7f5 Win32: Disable dynamic libgcc for MinGW DLL 2019-10-03 21:05:49 +02:00
Luflosi 243b1bc292 Use the correct type in a for loop
The `size` member in the `GLFWgammaramp` struct is of type `unsigned int`, so the `for` loop iterating over it should also use the type `unsigned int`.

Closes #1541.
2019-09-23 13:43:05 +02:00
luz.paz 7105ff2dfd Fix typos
Found via `codespell -q 3 -S ./deps -L fo,numer,te,uint,wille`
2019-09-16 12:30:25 +02:00
Camilla Löwy 7f02898264 Cocoa: Fix glfwSetWindowSize anchor point
This makes glfwSetWindowSize use the top-left corner as anchor point
instead of the bottom-left corner.

Fixes #1553.
2019-09-06 16:57:37 +02:00
Camilla Löwy aa8e8ab960 Remove deprecated tags from Doxyfile.in
This fixes warnings emitted by Doxygen 1.8.16.
2019-09-06 15:55:59 +02:00
Camilla Löwy 26aac53e1d Update changelog and add credit
Related to #1556.
2019-09-01 21:58:25 +02:00
httpdigest 2777f6a754 Fix comparison of video modes of equal area
This fixes the bug of video modes being discarded if they had
a different resolution but the same area as another mode.

Fixes #1555.
Closes #1556.
2019-09-01 21:57:06 +02:00
Camilla Löwy cbf23e5615 Win32: Fix VS static analysis false positive
This way is perhaps also more readable for humans.
2019-08-28 20:59:49 +02:00
Camilla Löwy 56ca0cb3b3 Unify key name string handling
This makes key names per-key static strings for all supported platforms.

Fixes #1200.
2019-08-27 19:29:56 +02:00
Camilla Löwy 4cc5d2e623 Clarify comment 2019-08-15 17:25:36 +02:00
Camilla Löwy f764836e58 Fix license copyright year and formatting 2019-08-15 16:59:54 +02:00
Camilla Löwy 2c7ef5b480 Win32: Fix initial state of maximized state cache 2019-08-14 19:18:29 +02:00
Camilla Löwy 711b9694a1 Win32: Fix GLFW_MAXIMIZED not maximizing window
The window rect adjustment for content scale broke the initial, correct
maximization performed when creating the window with WS_MAXIMIZE.  This
switches to updating the restored rect instead of the current rect.

Fixes #1499.
Closes #1503.
2019-08-13 16:08:15 +02:00
Camilla Löwy efda4afb49 Put fix in correct position
This fixes a mismerge by @elmindreda in
65748fb8f3.
2019-07-25 20:32:51 +02:00
Camilla Löwy 65748fb8f3 Fix Vulkan triangle test segfault on resize
The command buffer handle was not reset after being freed on window
resize, leading to a segfault when the stale handle was used.
2019-07-25 19:56:03 +02:00
Camilla Löwy 6abad2efd2 Fix conflict with DEBUG macro defined by Bazel
The Bazel build system may define DEBUG when compiling on macOS, which
caused the glfwinfo test program to fail to build.

Fixes #1537.
2019-07-24 21:29:46 +02:00
Camilla Löwy eecf83c5d0 Add credit 2019-07-22 21:37:22 +02:00
Ave Milia 2e039d9275 CMake: remove -DGLFW_DLL on non-Windows targets
When using GLFW with CMake and installed GLFW binaries, `-DGLFW_DLL` is
passed on Linux, which should not happen.

Closes #1530.
2019-07-22 21:37:22 +02:00
Camilla Löwy b430bc4935 Cocoa: Fix internal symbol hiding for dylib
The default symbol visibility was not set to hidden on macOS.
2019-07-16 23:14:16 +02:00
Camilla Löwy 062a1c22b5 Cocoa: Fix file-local function not declared static 2019-07-16 23:12:20 +02:00
Camilla Löwy a4d910b4a7 Documentation work
[ci skip]
2019-07-12 19:04:57 +02:00
Leon Linhart 4f0b8b0dda Win32: Fix cursor enter/position event order
This fixes the cursor enter event being emitted after the first cursor
position event on Windows.

Closes #1490.
2019-07-12 16:39:17 +02:00
Camilla Löwy 7bd0af3089 Add credits 2019-07-12 16:38:06 +02:00
Lukas Zanner 84b13113ed Fix typo in glfwGetRequiredInstanceExtensions docs
Closes #1500.
2019-07-12 15:03:44 +02:00
Camilla Löwy 62b7fe8311 Cleanup 2019-07-12 15:02:04 +02:00
Camilla Löwy 773f4495f0 Win32: Fix symbol redefinition warnings
When both GLFW_INCLUDE_VULKAN and VK_USE_PLATFORM_WIN32_KHR were
defined, the GLFW header would define replacement versions of APIENTRY
and WINGDIAPI /before/ including the Vulkan header, which would include
windows.h, which (justifiably) defines APIENTRY and WINGDIAPI blindly.

Fixes #1524.
2019-07-12 15:02:04 +02:00
Camilla Löwy 5bea122211 Update changelog
Related to #1528.
2019-07-12 15:02:04 +02:00
Camilla Löwy d232bcfcdd Cleanup
Related to #1528.
2019-07-12 15:00:51 +02:00
Denis Bernard 36f90800d8 X11: Query and keep track of Xkb group index
For users with multiple keyboard layouts configured, glfwGetKeyName
works fine only with the primary layout.  Switching layouts results in
changing the group index.  This commit querries the current group index
when initializing keyboard input and keeps track of any change to it.

As a result the scancode -> keyname mapping may change while the program
is running (needs to be documented).

Fixes #1462.
Closes #1528.
2019-07-12 14:08:43 +02:00
Camilla Löwy c6b95e3b07 X11: Fix focus events not being filtered
The filter condition had ended up below the action.
2019-07-11 00:36:34 +02:00
Luflosi e463e85bba Fix typo
Closes #1513.
2019-07-01 11:30:57 +02:00
Camilla Löwy 3a5e99e59a Remove unused function in tearing test 2019-06-27 20:07:19 +02:00
Camilla Löwy 3262c29440 Cocoa: Cleanup
This makes the Cocoa _glfwPlatformSetWindowMonitor consistent with its
X11 and Win32 counterparts.
2019-06-27 18:14:48 +02:00
A. Tombs 1d62157268 Win32: Cleanup pointer test in win32_window.c
MSVC 2019 complains that the code at line 1744
(`GetMonitorInfo(window->monitor->win32.handle, &mi);`) can potentially
dereference a null pointer. The compiler is wrong in this case (it has
not spotted that `monitor` and `window->monitor` must be equal), but
I think it makes sense for our non-NULL test to be on the variable we
actually use rather than the one it was set from.

Related to #1491.
2019-06-27 18:14:48 +02:00
Camilla Löwy 1f508530f0 X11: Let the language initialize XEvent structs 2019-06-27 18:14:48 +02:00
Camilla Löwy fad9896d38 X11: Clean up EWMH feature detection
The EWMH feature detection atoms are now named and loaded the same way
as other X11 atoms.  Detection is now performed after all
non-conditional atoms have been loaded.  The EWMH detection now has
hopefully more readable comments.
2019-06-27 18:14:48 +02:00
Camilla Löwy 0c6b505619 Convert some declarations to C99 style 2019-06-27 18:13:29 +02:00
Luflosi 2db3b9688d Replace some tabs with spaces
I found some tabs where there should be spaces for consistency.
Closes #1496.
2019-06-16 16:57:09 +02:00
Camilla Löwy d834f01ca4 Rename legacy Vulkan triangle program
Fixes #1477.
2019-05-24 17:28:32 +02:00
Camilla Löwy 537ea4ccf1 Explicitly disable inclusion for test and examples
Thank you, Travis CI, for reminding me that one cannot disable a header
with inclusion guards if it doesn't exist.
2019-05-24 17:28:32 +02:00
Camilla Löwy 51bb76c7c3 Improve (?) reference documentation for callbacks 2019-05-24 14:58:54 +02:00
Camilla Löwy 71e6ff386d Enable CMake policy CMP0077 where available
This will let higher-level projects override GLFW CMake options with
normal variables instead of having to use cache variables.

This means with CMake 3.13 and later you can now do:

set(GLFW_BUILD_TESTS ON)
add_subdirectory(path/to/glfw)

Instead of the more verbose:

set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)
2019-05-24 14:58:54 +02:00
Camilla Löwy 98dde03ce1 Fix variable dereferencing 2019-05-24 14:58:54 +02:00
Camilla Löwy e1d9e2ba73 Clarify Doxyfile INPUT value generation 2019-05-24 14:43:49 +02:00
Camilla Löwy 84ec99bb01 Remove pointless comments 2019-05-24 14:43:49 +02:00
Camilla Löwy d0c3fa900a Win32: Fix non-client actions for disabled cursor
Disabled cursor mode interfered with some non-client actions.
2019-05-24 14:43:49 +02:00
Camilla Löwy 267e06a41e Win32: Remove stale comment 2019-05-24 14:43:49 +02:00
Camilla Löwy bb6945a18a Clarify difference between time and timer in docs 2019-05-24 14:43:49 +02:00
Camilla Löwy 22a6c02a4c WGL: Add extension function macro aliases
This should have been done when the WGL extension members were moved
from the context struct to the library struct.
2019-05-24 14:43:49 +02:00
Camilla Löwy 3fd4e79adb WGL: Fix misplaced block comment 2019-05-24 14:43:49 +02:00
Camilla Löwy 56aad76b16 Add C dialect reminders to each source file
Files built for Win32 must use C89 style declarations for compatibility
with VS 2010 and 2012, which are still supported by GLFW.
2019-05-24 14:43:49 +02:00
Camilla Löwy feaa532886 Add missing word 2019-05-24 14:43:49 +02:00
Camilla Löwy e91d0fc499 Clarify triangle-opengl uniform uniform update
The previous way worked as mat4 is an array typedef but this way may be
clearer to people new to the linmath header.
2019-05-24 14:43:49 +02:00
Camilla Löwy 3cf7645b96 Documentation work
Most context related hint and attribute links had copypaste errors.
The GLFW_CONTEXT_RELEASE_BEHAVIOR and GLFW_CONTEXT_NO_ERROR attributes
did not have guide documentation.
2019-05-24 14:43:49 +02:00
Camilla Löwy e4aba7feaa Convert triangle-opengl example to 3.3 core 2019-05-24 14:43:49 +02:00
Camilla Löwy a639d6e635 Rename OpenGL triangle example to triangle-opengl 2019-05-24 14:43:39 +02:00
Camilla Löwy d44bfe0264 Add vertex type and offsetof to OpenGL triangle 2019-05-24 14:39:35 +02:00
Camilla Löwy f61d0916fd Convert OpenGL triangle example to C99 2019-05-19 21:10:29 +02:00
Camilla Löwy c415c71947 Clean up glfwinfo Vulkan version output 2019-05-19 21:10:29 +02:00
Camilla Löwy 144c98bcb3 Simplify glfwinfo Vulkan enumerations 2019-05-19 21:10:29 +02:00
Camilla Löwy fa025d8f80 Convert glfwinfo to C99 2019-05-19 21:10:29 +02:00
Camilla Löwy 700d1f28d8 Add Vulkan 1.1 support to glfwinfo 2019-05-19 21:10:29 +02:00
Camilla Löwy 0b01d850ed NSGL: Remove enforcement of forward-compatible flag
This sharp corner should have been addressed a long time ago.
2019-05-19 21:10:29 +02:00
Camilla Löwy 57bf6b2f75 Add credit
Related to #1480.
2019-05-17 19:19:07 +02:00
Camilla Löwy ceb16cb5f1 X11: Fix CMake check for XInput headers
The X11_Xinput_* variables have been removed in recent CMake, leaving
only the X11_Xi_* set.

Related to #1480.
2019-05-17 17:26:46 +02:00
Camilla Löwy 0ccb690853 Add stable release branch to CI 2019-05-17 17:02:09 +02:00
Camilla Löwy 535491c4f3 Remove cmake from Travis CI package list
This was left over from an old workaround for Travis CI having an
ancient version of CMake pre-installed.
2019-05-17 17:02:09 +02:00
Camilla Löwy 7dc36dd7da Format Travis CI inline script for readability 2019-05-17 16:53:40 +02:00
Camilla Löwy c0eabc594f Add descriptive names for Travis CI jobs 2019-05-17 16:15:59 +02:00
Camilla Löwy 8ee589e43b Disable examples and tests when a subproject
This changes the default value of the GLFW_BUILD_EXAMPLES and
GLFW_BUILD_TESTS CMake options to false when GLFW is being added as
a subdirectory by another CMake project.

If you want the previous behavior, force these options to true before
adding the GLFW subdirectory:

set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)

Doing this is backward compatible with earlier versions of GLFW.

The GLFW_BUILD_DOCS option is left enabled as it also requires Doxygen
to have any effect, is quicker to build and is more likely to be useful
when GLFW is a subproject.
2019-05-17 16:12:52 +02:00
Camilla Löwy cd290f767f Use CMakeDependentOption for dependent options
This replaces the earlier manual logic for dependent CMake options with
the cmake_dependent_option function from CMakeDependentOption.
2019-05-17 16:12:52 +02:00
Camilla Löwy a255e7ace6 Move to the modern CMake project version option
This replaces the manual ad-hoc version variables we have used since
CMake 2.x (and GLFW 2.x lite).
2019-05-17 16:12:52 +02:00
Camilla Löwy 5c5963f1c0 X11: Only check for headers at build time
GLFW does not require the X11 extension libraries to build or run, so
only fail if the headers are unavailable.
2019-05-17 16:12:52 +02:00
Camilla Löwy 090b16bfae X11: Fix CMake not checking for XInput2 headers
Fixes #1480.
2019-05-17 16:12:52 +02:00
Camilla Löwy 42a3e4434f Update changelog and add credit 2019-05-17 16:12:52 +02:00
Konstantin Podsvirov 15af302f77 Fix use of absolute path in INSTALL_INTERFACE
Closes #1470.
2019-05-17 16:12:52 +02:00
Camilla Löwy be71147ad5 Documentation work
The monitor content scale was missing from the monitor properties
paragraph.
2019-05-17 16:12:52 +02:00
Camilla Löwy ff7d42a55e Update Travis CI build
- Migrate to Xenial
 - Use whitelisted PPA instead of hardcoded deb URL
 - Only add X11 dependencies for X11 builds
 - Only set sudo on matrix entries
2019-05-17 16:12:52 +02:00
Emmanuel Gil Peyrot 599fb3de34 Wayland: Remove wl_shell support
This protocol is part of the core Wayland, but it is pretty badly
designed and is missing quite a few features, and is in the process of
being phased out in compositors.  Its support in GLFW requires
duplicating pretty much every single window management codepath.

This bumps the required compositor versions to the ones which have
implemented xdg-shell, approximately two years ago, which seems sensible
to me.
2019-04-20 10:05:15 +02:00
Camilla Löwy a337c56848 Start 3.4 2019-04-16 23:08:39 +02:00
114 changed files with 2175 additions and 2302 deletions
+49 -7
View File
@@ -1,20 +1,62 @@
image:
- Visual Studio 2015
- Visual Studio 2019
branches: branches:
only: only:
- ci - ci
- master - master
- 3.3-stable
skip_tags: true skip_tags: true
skip_commits:
files:
- README.md
- LICENSE.md
- docs/*
environment: environment:
matrix:
- GENERATOR: MinGW Makefiles
BUILD_SHARED_LIBS: ON
CFLAGS: -Werror
- GENERATOR: MinGW Makefiles
BUILD_SHARED_LIBS: OFF
CFLAGS: -Werror
- GENERATOR: Visual Studio 10 2010
BUILD_SHARED_LIBS: ON
CFLAGS: /WX
- GENERATOR: Visual Studio 10 2010
BUILD_SHARED_LIBS: OFF
CFLAGS: /WX
- GENERATOR: Visual Studio 16 2019
BUILD_SHARED_LIBS: ON
CFLAGS: /WX
- GENERATOR: Visual Studio 16 2019
BUILD_SHARED_LIBS: OFF
CFLAGS: /WX CFLAGS: /WX
matrix:
- BUILD_SHARED_LIBS: ON
- BUILD_SHARED_LIBS: OFF
matrix: matrix:
fast_finish: true fast_finish: true
exclude:
- image: Visual Studio 2015
GENERATOR: Visual Studio 16 2019
- image: Visual Studio 2019
GENERATOR: Visual Studio 10 2010
- image: Visual Studio 2019
GENERATOR: MinGW Makefiles
for:
-
matrix:
except:
- GENERATOR: Visual Studio 10 2010
build_script: build_script:
- mkdir build - set PATH=%PATH:C:\Program Files\Git\usr\bin=C:\MinGW\bin%
- cd build - cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% .. - cmake --build build
- cmake --build . -
matrix:
only:
- GENERATOR: Visual Studio 10 2010
build_script:
- cmake -S . -B build -G "%GENERATOR%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS%
- cmake --build build --target glfw
notifications: notifications:
- provider: Email - provider: Email
to: to:
+23 -8
View File
@@ -1,7 +1,8 @@
# External junk # The canonical out-of-tree build subdirectory
.DS_Store build
# Visual Studio clutter
_ReSharper* _ReSharper*
*.opensdf
*.sdf *.sdf
*.suo *.suo
*.dir *.dir
@@ -15,12 +16,26 @@ Release
MinSizeRel MinSizeRel
RelWithDebInfo RelWithDebInfo
*.xcodeproj *.xcodeproj
*.opensdf
# CMake files # macOS clutter
.DS_Store
# Makefile generator clutter
Makefile Makefile
# Ninja generator clutter
build.ninja
rules.ninja
.ninja_deps
.ninja_log
# CMake clutter
CMakeCache.txt CMakeCache.txt
CMakeFiles CMakeFiles
CMakeScripts CMakeScripts
CMakeDoxyfile.in
CMakeDoxygenDefaults.cmake
cmake_install.cmake cmake_install.cmake
cmake_uninstall.cmake cmake_uninstall.cmake
@@ -41,11 +56,11 @@ src/wayland-relative-pointer-unstable-v1-protocol.c
# Compiled binaries # Compiled binaries
src/libglfw.so src/libglfw.so
src/libglfw.so.3 src/libglfw.so.3
src/libglfw.so.3.3 src/libglfw.so.3.4
src/libglfw.dylib src/libglfw.dylib
src/libglfw.dylib src/libglfw.dylib
src/libglfw.3.dylib src/libglfw.3.dylib
src/libglfw.3.3.dylib src/libglfw.3.4.dylib
src/libglfw3.a src/libglfw3.a
src/glfw3.lib src/glfw3.lib
src/glfw3.dll src/glfw3.dll
@@ -60,7 +75,7 @@ examples/offscreen
examples/particles examples/particles
examples/splitview examples/splitview
examples/sharing examples/sharing
examples/simple examples/triangle-opengl
examples/wave examples/wave
tests/*.app tests/*.app
tests/*.exe tests/*.exe
@@ -80,6 +95,6 @@ tests/tearing
tests/threads tests/threads
tests/timeout tests/timeout
tests/title tests/title
tests/vulkan tests/triangle-vulkan
tests/windows tests/windows
+10
View File
@@ -0,0 +1,10 @@
Camilla Löwy <elmindreda@glfw.org> <elmindreda@users.sourceforge.net>
Camilla Löwy <elmindreda@glfw.org> <elmindreda@elmindreda.org>
Camilla Löwy <elmindreda@glfw.org>
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Marcus Geelnard <m@bitsnbites.eu> <marcus256@users.sourceforge.net>
Marcus Geelnard <m@bitsnbites.eu> <marcus@geelnards-pc.(none)>
Marcus Geelnard <m@bitsnbites.eu>
+35 -9
View File
@@ -4,31 +4,47 @@ branches:
only: only:
- ci - ci
- master - master
- 3.3-stable
matrix:
include:
- os: linux
dist: xenial
sudo: false sudo: false
dist: trusty name: "X11 shared library"
addons: addons:
apt: apt:
packages: packages:
- cmake
- libxrandr-dev - libxrandr-dev
- libxinerama-dev - libxinerama-dev
- libxcursor-dev - libxcursor-dev
- libxi-dev - libxi-dev
matrix:
include:
- os: linux
env: env:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: xenial
sudo: false
name: "X11 static library"
addons:
apt:
packages:
- libxrandr-dev
- libxinerama-dev
- libxcursor-dev
- libxi-dev
env: env:
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: xenial
sudo: required sudo: required
name: "Wayland shared library"
addons: addons:
apt: apt:
sources:
- ppa:kubuntu-ppa/backports
packages: packages:
- extra-cmake-modules
- libwayland-dev - libwayland-dev
- libxkbcommon-dev - libxkbcommon-dev
- libegl1-mesa-dev - libegl1-mesa-dev
@@ -37,10 +53,15 @@ matrix:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- os: linux - os: linux
dist: xenial
sudo: required sudo: required
name: "Wayland static library"
addons: addons:
apt: apt:
sources:
- ppa:kubuntu-ppa/backports
packages: packages:
- extra-cmake-modules
- libwayland-dev - libwayland-dev
- libxkbcommon-dev - libxkbcommon-dev
- libegl1-mesa-dev - libegl1-mesa-dev
@@ -49,20 +70,25 @@ matrix:
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror - CFLAGS=-Werror
- os: osx - os: osx
sudo: false
name: "Cocoa shared library"
env: env:
- BUILD_SHARED_LIBS=ON - BUILD_SHARED_LIBS=ON
- CFLAGS=-Werror - CFLAGS=-Werror
- os: osx - os: osx
sudo: false
name: "Cocoa static library"
env: env:
- BUILD_SHARED_LIBS=OFF - BUILD_SHARED_LIBS=OFF
- CFLAGS=-Werror - CFLAGS=-Werror
script: script:
- if grep -Inr '\s$' src include docs tests examples CMake *.md .gitattributes .gitignore; then echo Trailing whitespace found, aborting.; exit 1; fi - 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}"; - if test -n "${USE_WAYLAND}"; then
then wget https://mirrors.kernel.org/ubuntu/pool/universe/e/extra-cmake-modules/extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
sudo dpkg -i extra-cmake-modules_5.38.0a-0ubuntu1_amd64.deb;
git clone git://anongit.freedesktop.org/wayland/wayland-protocols; git clone git://anongit.freedesktop.org/wayland/wayland-protocols;
pushd wayland-protocols; pushd wayland-protocols;
git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install; git checkout 1.15 && ./autogen.sh --prefix=/usr && make && sudo make install;
@@ -1,9 +1,9 @@
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") if (NOT EXISTS "@GLFW_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") message(FATAL_ERROR "Cannot find install manifest: \"@GLFW_BINARY_DIR@/install_manifest.txt\"")
endif() endif()
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) file(READ "@GLFW_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}") string(REGEX REPLACE "\n" ";" files "${files}")
foreach (file ${files}) foreach (file ${files})
+32 -31
View File
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(GLFW C) project(GLFW VERSION 3.4.0 LANGUAGES C)
set(CMAKE_LEGACY_CYGWIN_WIN32 OFF) set(CMAKE_LEGACY_CYGWIN_WIN32 OFF)
@@ -8,39 +8,34 @@ if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0054 NEW)
endif() endif()
set(GLFW_VERSION_MAJOR "3") if (POLICY CMP0077)
set(GLFW_VERSION_MINOR "3") cmake_policy(SET CMP0077 NEW)
set(GLFW_VERSION_PATCH "0") endif()
set(GLFW_VERSION_EXTRA "")
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}")
set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}")
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
set(GLFW_STANDALONE TRUE)
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" OFF) option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ${GLFW_STANDALONE})
option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ${GLFW_STANDALONE})
option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON) option(GLFW_BUILD_DOCS "Build the GLFW documentation" ON)
option(GLFW_INSTALL "Generate installation target" ON) option(GLFW_INSTALL "Generate installation target" ON)
option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF) option(GLFW_VULKAN_STATIC "Assume the Vulkan loader is linked with the application" OFF)
include(GNUInstallDirs) include(GNUInstallDirs)
include(CMakeDependentOption)
if (UNIX) cmake_dependent_option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF
option(GLFW_USE_OSMESA "Use OSMesa for offscreen context creation" OFF) "UNIX" OFF)
endif() cmake_dependent_option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF
"WIN32" OFF)
if (WIN32) cmake_dependent_option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF
option(GLFW_USE_HYBRID_HPG "Force use of high-performance GPU on hybrid systems" OFF) "UNIX;NOT APPLE" OFF)
endif() cmake_dependent_option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON
"MSVC" OFF)
if (UNIX AND NOT APPLE)
option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
endif()
if (MSVC)
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" ON)
endif()
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
set(_GLFW_BUILD_DLL 1) set(_GLFW_BUILD_DLL 1)
@@ -211,29 +206,35 @@ if (_GLFW_X11)
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}") list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
# Check for XRandR (modern resolution switching and gamma control) # Check for XRandR (modern resolution switching and gamma control)
if (NOT X11_Xrandr_FOUND) if (NOT X11_Xrandr_INCLUDE_PATH)
message(FATAL_ERROR "The RandR headers were not found") message(FATAL_ERROR "The RandR headers were not found")
endif() endif()
# Check for Xinerama (legacy multi-monitor support) # Check for Xinerama (legacy multi-monitor support)
if (NOT X11_Xinerama_FOUND) if (NOT X11_Xinerama_INCLUDE_PATH)
message(FATAL_ERROR "The Xinerama headers were not found") message(FATAL_ERROR "The Xinerama headers were not found")
endif() endif()
# Check for Xkb (X keyboard extension) # Check for Xkb (X keyboard extension)
if (NOT X11_Xkb_FOUND) if (NOT X11_Xkb_INCLUDE_PATH)
message(FATAL_ERROR "The X keyboard extension headers were not found") message(FATAL_ERROR "The X keyboard extension headers were not found")
endif() endif()
# Check for Xcursor (cursor creation from RGBA images) # Check for Xcursor (cursor creation from RGBA images)
if (NOT X11_Xcursor_FOUND) if (NOT X11_Xcursor_INCLUDE_PATH)
message(FATAL_ERROR "The Xcursor headers were not found") message(FATAL_ERROR "The Xcursor headers were not found")
endif() endif()
# Check for XInput (modern HID input)
if (NOT X11_Xi_INCLUDE_PATH)
message(FATAL_ERROR "The XInput headers were not found")
endif()
list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}" list(APPEND glfw_INCLUDE_DIRS "${X11_Xrandr_INCLUDE_PATH}"
"${X11_Xinerama_INCLUDE_PATH}" "${X11_Xinerama_INCLUDE_PATH}"
"${X11_Xkb_INCLUDE_PATH}" "${X11_Xkb_INCLUDE_PATH}"
"${X11_Xcursor_INCLUDE_PATH}") "${X11_Xcursor_INCLUDE_PATH}"
"${X11_Xi_INCLUDE_PATH}")
endif() endif()
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@@ -322,7 +323,7 @@ configure_package_config_file(src/glfw3Config.cmake.in
NO_CHECK_REQUIRED_COMPONENTS_MACRO) NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(src/glfw3ConfigVersion.cmake write_basic_package_version_file(src/glfw3ConfigVersion.cmake
VERSION ${GLFW_VERSION_FULL} VERSION ${GLFW_VERSION}
COMPATIBILITY SameMajorVersion) COMPATIBILITY SameMajorVersion)
configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY) configure_file(src/glfw_config.h.in src/glfw_config.h @ONLY)
@@ -366,7 +367,7 @@ if (GLFW_INSTALL)
# Only generate this target if no higher-level project already has # Only generate this target if no higher-level project already has
if (NOT TARGET uninstall) if (NOT TARGET uninstall)
configure_file(cmake_uninstall.cmake.in configure_file(CMake/cmake_uninstall.cmake.in
cmake_uninstall.cmake IMMEDIATE @ONLY) cmake_uninstall.cmake IMMEDIATE @ONLY)
add_custom_target(uninstall add_custom_target(uninstall
+2 -1
View File
@@ -1,5 +1,6 @@
Copyright (c) 2002-2006 Marcus Geelnard Copyright (c) 2002-2006 Marcus Geelnard
Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
Copyright (c) 2006-2019 Camilla Löwy
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
+41 -183
View File
@@ -118,188 +118,34 @@ information on what to include when reporting a bug.
## Changelog ## Changelog
- Added `glfwGetError` function for querying the last error code and its - Added `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR`,
description (#970) `GLFW_RESIZE_ALL_CURSOR` and `GLFW_NOT_ALLOWED_CURSOR` cursor shapes (#427)
- Added `glfwUpdateGamepadMappings` function for importing gamepad mappings in - Added `GLFW_RESIZE_EW_CURSOR` alias for `GLFW_HRESIZE_CURSOR` (#427)
SDL\_GameControllerDB format (#900) - Added `GLFW_RESIZE_NS_CURSOR` alias for `GLFW_VRESIZE_CURSOR` (#427)
- Added `glfwJoystickIsGamepad` function for querying whether a joystick has - Added `GLFW_POINTING_HAND_CURSOR` alias for `GLFW_HAND_CURSOR` (#427)
a gamepad mapping (#900) - Disabled tests and examples by default when built as a CMake subdirectory
- Added `glfwGetJoystickGUID` function for querying the SDL compatible GUID of - Bugfix: The CMake config-file package used an absolute path and was not
a joystick (#900) relocatable (#1470)
- Added `glfwGetGamepadName` function for querying the name provided by the - Bugfix: Video modes with a duplicate screen area were discarded (#1555,#1556)
gamepad mapping (#900) - Bugfix: Compiling with -Wextra-semi caused warnings (#1440)
- Added `glfwGetGamepadState` function, `GLFW_GAMEPAD_*` and `GLFWgamepadstate` - [Win32] Added the `GLFW_WIN32_KEYBOARD_MENU` window hint for enabling access
for retrieving gamepad input state (#900) to the window menu
- Added `glfwGetWindowContentScale`, `glfwGetMonitorContentScale` and - [Win32] Bugfix: `GLFW_INCLUDE_VULKAN` plus `VK_USE_PLATFORM_WIN32_KHR` caused
`glfwSetWindowContentScaleCallback` for DPI-aware rendering symbol redefinition (#1524)
(#235,#439,#677,#845,#898) - [Win32] Bugfix: The cursor position event was emitted before its cursor enter
- Added `glfwRequestWindowAttention` function for requesting attention from the event (#1490)
user (#732,#988) - [Win32] Bugfix: The window hint `GLFW_MAXIMIZED` did not move or resize the
- Added `glfwGetMonitorWorkarea` function for retrieving the monitor work area window (#1499)
(#920,#989,#1322) - [Cocoa] Bugfix: `glfwSetWindowSize` used a bottom-left anchor point (#1553)
- Added `glfwGetKeyScancode` function that allows retrieving platform dependent - [Cocoa] Bugfix: Window remained on screen after destruction until event poll
scancodes for keys (#830) (#1412)
- Added `glfwSetWindowMaximizeCallback` and `GLFWwindowmaximizefun` for - [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
receiving window maximization events (#778) - [X11] Bugfix: Key names were not updated when the keyboard layout changed
- Added `glfwSetWindowAttrib` function for changing window attributes (#537) (#1462,#1528)
- Added `glfwGetJoystickHats` function for querying joystick hats - [X11] Bugfix: Decorations could not be enabled after window creation (#1566)
(#889,#906,#934) - [X11] Bugfix: Content scale fallback value could be inconsistent (#1578)
- Added `glfwInitHint` for setting initialization hints - [Wayland] Bugfix: The `GLFW_HAND_CURSOR` shape used the wrong image (#1432)
- Added `glfwWindowHintString` for setting string type window hints (#893,#1139) - [NSGL] Removed enforcement of forward-compatible flag for core contexts
- Added `glfwGetWindowOpacity` and `glfwSetWindowOpacity` for controlling whole
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`
functions for accessing X11 primary selection (#894,#1056)
- Added `glfwRawMouseMotionSupported` function for querying raw motion support
(#125,#1400,#1401)
- Added headless [OSMesa](http://mesa3d.org/osmesa.html) backend (#850)
- Added definition of `GLAPIENTRY` to public header
- Added `GLFW_TRANSPARENT_FRAMEBUFFER` window hint and attribute for controlling
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
(#749,#842)
- Added `GLFW_FOCUS_ON_SHOW` window hint and attribute to control input focus
on calling show window (#1189)
- Added `GLFW_SCALE_TO_MONITOR` window hint for automatic window resizing
(#676,#1115)
- Added `GLFW_JOYSTICK_HAT_BUTTONS` init hint (#889)
- Added `GLFW_LOCK_KEY_MODS` input mode and `GLFW_MOD_*_LOCK` mod bits (#946)
- Added `GLFW_RAW_MOUSE_MOTION` input mode for selecting raw motion input
(#125,#1400,#1401)
- Added macOS specific `GLFW_COCOA_RETINA_FRAMEBUFFER` window hint
- 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_CHDIR_RESOURCES` init hint
- Added macOS specific `GLFW_COCOA_MENUBAR` init hint
- Added X11 specific `GLFW_X11_CLASS_NAME` and `GLFW_X11_INSTANCE_NAME` window
hints (#893,#1139)
- Added `GLFW_INCLUDE_ES32` for including the OpenGL ES 3.2 header
- Added `GLFW_OSMESA_CONTEXT_API` for creating OpenGL contexts with
[OSMesa](https://www.mesa3d.org/osmesa.html) (#281)
- Added `GenerateMappings.cmake` script for updating gamepad mappings
- Made `glfwCreateWindowSurface` emit an error when the window has a context
(#1194,#1205)
- Deprecated window parameter of clipboard string functions
- Deprecated charmods callback
- Removed `GLFW_USE_RETINA` compile-time option
- Removed `GLFW_USE_CHDIR` compile-time option
- Removed `GLFW_USE_MENUBAR` compile-time option
- Removed requirement of at least one window for `glfwWaitEvents` and
`glfwPostEmptyEvent` (#1317)
- Removed all dependencies on the Vulkan SDK
- Bugfix: Calling `glfwMaximizeWindow` on a full screen window was not ignored
- Bugfix: `GLFW_INCLUDE_VULKAN` could not be combined with the corresponding
OpenGL and OpenGL ES header macros
- Bugfix: `glfwGetInstanceProcAddress` returned `NULL` for
`vkGetInstanceProcAddr` when `_GLFW_VULKAN_STATIC` was enabled
- Bugfix: Invalid library paths were used in test and example CMake files (#930)
- Bugfix: The scancode for synthetic key release events was always zero
- Bugfix: The generated Doxyfile did not handle paths with spaces (#1081)
- Bugfix: The gamma ramp generated by `glfwSetGamma` did not use the monitor
ramp size (#1387,#1388)
- [Win32] Added system error strings to relevant GLFW error descriptions (#733)
- [Win32] Removed XInput circular deadzone from joystick axis data (#1045)
- [Win32] Bugfix: Undecorated windows could not be iconified by the user (#861)
- [Win32] Bugfix: Deadzone logic could underflow with some controllers (#910)
- [Win32] Bugfix: `glfwVulkanSupported` emitted an error on systems with
a loader but no ICD (#916)
- [Win32] Bugfix: Non-iconified full sreeen windows did not prevent screen
blanking or password enabled screensavers (#851)
- [Win32] Bugfix: Mouse capture logic lost secondary release messages (#954)
- [Win32] Bugfix: Monitors with no display devices were not enumerated (#960)
- [Win32] Bugfix: Monitor events were not emitted (#784)
- [Win32] Bugfix: The DLL was installed to the wrong directory on Cygwin (#1035)
- [Win32] Bugfix: Normalization of axis data via XInput was incorrect (#1045)
- [Win32] Bugfix: `glfw3native.h` would undefine a foreign `APIENTRY` (#1062)
- [Win32] Bugfix: Disabled cursor mode prevented use of caption buttons
(#650,#1071)
- [Win32] Bugfix: Returned key names did not match other platforms (#943)
- [Win32] Bugfix: Undecorated windows did not maximize to workarea (#899)
- [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)
- [Win32] Bugfix: The keypad equals key was reported as `GLFW_KEY_UNKNOWN`
(#1315,#1316)
- [Win32] Bugfix: A title bar would be drawn over undecorated windows in some
circumstances (#1383)
- [Win32] Bugfix: Standard cursors were not per-monitor DPI aware (#1431)
- [X11] Replaced `_GLFW_HAS_XF86VM` compile-time option with dynamic loading
- [X11] Bugfix: `glfwGetVideoMode` would segfault on Cygwin/X
- [X11] Bugfix: Dynamic X11 library loading did not use full sonames (#941)
- [X11] Bugfix: Window creation on 64-bit would read past top of stack (#951)
- [X11] Bugfix: XDND support had multiple non-conformance issues (#968)
- [X11] Bugfix: The RandR monitor path was disabled despite working RandR (#972)
- [X11] Bugfix: IM-duplicated key events would leak at low polling rates (#747)
- [X11] Bugfix: Gamma ramp setting via RandR did not validate ramp size
- [X11] Bugfix: Key name string encoding depended on current locale (#981,#983)
- [X11] Bugfix: Incremental reading of selections was not supported (#275)
- [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT`
- [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8
- [X11] Bugfix: NVidia EGL would segfault if unloaded before closing the display
- [X11] Bugfix: Checking window maximized attrib could crash some WMs (#1356)
- [X11] Bugfix: Update cursor position on enter event (#1366)
- [X11] Bugfix: `glfwSetWindowMonitor` did not update hints when resizing
non-user-resizable windows
- [X11] Bugfix: `glfwSetWindowMonitor` did not flush output buffer in some cases
- [X11] Bugfix: `glfwSetWindowMonitor` did not update the EWMH state of hidden
windows (#1358)
- [Linux] Added workaround for missing `SYN_DROPPED` in pre-2.6.39 kernel
headers (#1196)
- [Linux] Moved to evdev for joystick input (#906,#1005)
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
- [Linux] Bugfix: The joystick device path could be truncated (#1025)
- [Linux] Bugfix: `glfwInit` would fail if inotify creation failed (#833)
- [Linux] Bugfix: `strdup` was used without any required feature macro (#1055)
- [Cocoa] Added support for Vulkan window surface creation via
[MoltenVK](https://moltengl.com/moltenvk/) (#870)
- [Cocoa] Added support for loading a `MainMenu.nib` when available
- [Cocoa] Disabled automatic window tabbing for created windows (#1250)
- [Cocoa] Bugfix: Disabling window aspect ratio would assert (#852)
- [Cocoa] Bugfix: Window creation failed to set first responder (#876,#883)
- [Cocoa] Bugfix: Removed use of deprecated `CGDisplayIOServicePort` function
(#165,#192,#508,#511)
- [Cocoa] Bugfix: Disabled use of deprecated `CGDisplayModeCopyPixelEncoding`
function on macOS 10.12+
- [Cocoa] Bugfix: Running in AppSandbox would emit warnings (#816,#882)
- [Cocoa] Bugfix: Windows created after the first were not cascaded (#195)
- [Cocoa] Bugfix: Leaving video mode with `glfwSetWindowMonitor` would set
incorrect position and size (#748)
- [Cocoa] Bugfix: Iconified full screen windows could not be restored (#848)
- [Cocoa] Bugfix: Value range was ignored for joystick hats and buttons (#888)
- [Cocoa] Bugfix: Full screen framebuffer was incorrectly sized for some video
modes (#682)
- [Cocoa] Bugfix: A string object for IME was updated non-idiomatically (#1050)
- [Cocoa] Bugfix: A hidden or disabled cursor would become visible when a user
notification was shown (#971,#1028)
- [Cocoa] Bugfix: Some characters did not repeat due to Press and Hold (#1010)
- [Cocoa] Bugfix: Window title was lost when full screen or undecorated (#1082)
- [Cocoa] Bugfix: Window was resized twice when entering full screen (#1085)
- [Cocoa] Bugfix: Duplicate size events were not filtered (#1085)
- [Cocoa] Bugfix: Event polling did not initialize AppKit if necessary (#1218)
- [Cocoa] Bugfix: OpenGL rendering was not visible before resize on early macOS
10.14 (#1334,#1346)
- [Cocoa] Bugfix: Caps Lock did not generate any key events (#1368,#1373)
- [Cocoa] Bugfix: Some buttons for some joysticks were ignored (#1385)
- [Cocoa] Bugfix: Analog joystick buttons were not translated correctly (#1385)
- [Cocoa] Bugfix: OpenGL swap interval was ignored for occluded windows (#680)
- [Cocoa] Bugfix: OpenGL swap interval was ignored on early macOS 10.14
(#1337,#1417,#1435)
- [Cocoa] Bugfix: The y-coordinate was incorrect for `glfwGetCursorPos` and
`glfwSetCursorPos` (#1461)
- [WGL] Added support for `WGL_EXT_colorspace` for OpenGL ES contexts
- [WGL] Added support for `WGL_ARB_create_context_no_error`
- [GLX] Added support for `GLX_ARB_create_context_no_error`
- [GLX] Bugfix: Context creation could segfault if no GLXFBConfigs were
available (#1040)
- [EGL] Added support for `EGL_KHR_get_all_proc_addresses` (#871)
- [EGL] Added support for `EGL_KHR_context_flush_control`
- [EGL] Bugfix: The test for `EGL_RGB_BUFFER` was invalid
## Contact ## Contact
@@ -308,7 +154,7 @@ On [glfw.org](http://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project. well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a If you have questions related to the use of GLFW, we have a
[forum](http://discourse.glfw.org/), and the `#glfw` IRC channel on [forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Freenode](http://freenode.net/). [Freenode](http://freenode.net/).
If you have a bug to report, a patch to submit or a feature you'd like to If you have a bug to report, a patch to submit or a feature you'd like to
@@ -338,6 +184,7 @@ skills.
- blanco - blanco
- Kyle Brenneman - Kyle Brenneman
- Rok Breulj - Rok Breulj
- Kai Burjack
- Martin Capitanio - Martin Capitanio
- David Carlier - David Carlier
- Arturo Castro - Arturo Castro
@@ -370,6 +217,7 @@ skills.
- Mário Freitas - Mário Freitas
- GeO4d - GeO4d
- Marcus Geelnard - Marcus Geelnard
- Charles Giessen
- Stephen Gowen - Stephen Gowen
- Kovid Goyal - Kovid Goyal
- Eloi Marín Gratacós - Eloi Marín Gratacós
@@ -381,6 +229,7 @@ skills.
- Lucas Hinderberger - Lucas Hinderberger
- Paul Holden - Paul Holden
- Warren Hu - Warren Hu
- Charles Huber
- IntellectualKitty - IntellectualKitty
- Aaron Jacobs - Aaron Jacobs
- Erik S. V. Jansson - Erik S. V. Jansson
@@ -393,13 +242,17 @@ skills.
- Peter Knut - Peter Knut
- Christoph Kubisch - Christoph Kubisch
- Yuri Kunde Schlesner - Yuri Kunde Schlesner
- Rokas Kupstys
- Konstantin Käfer - Konstantin Käfer
- Eric Larson - Eric Larson
- Robin Leffmann - Robin Leffmann
- Glenn Lewis - Glenn Lewis
- Shane Liesegang - Shane Liesegang
- Anders Lindqvist
- Leon Linhart
- Eyal Lotem - Eyal Lotem
- Aaron Loucks - Aaron Loucks
- Luflosi
- Tristam MacDonald - Tristam MacDonald
- Hans Mackowiak - Hans Mackowiak
- Дмитри Малышев - Дмитри Малышев
@@ -412,6 +265,7 @@ skills.
- Jonathan Mercier - Jonathan Mercier
- Marcel Metz - Marcel Metz
- Liam Middlebrook - Liam Middlebrook
- Ave Milia
- Jonathan Miller - Jonathan Miller
- Kenneth Miller - Kenneth Miller
- Bruce Mitchener - Bruce Mitchener
@@ -439,9 +293,12 @@ skills.
- Cyril Pichard - Cyril Pichard
- Keith Pitt - Keith Pitt
- Stanislav Podgorskiy - Stanislav Podgorskiy
- Konstantin Podsvirov
- Nathan Poirier - Nathan Poirier
- Alexandre Pretyman - Alexandre Pretyman
- Pablo Prietz
- przemekmirek - przemekmirek
- Guillaume Racicot
- Philip Rideout - Philip Rideout
- Eddie Ringle - Eddie Ringle
- Max Risuhin - Max Risuhin
@@ -490,6 +347,7 @@ skills.
- Jay Weisskopf - Jay Weisskopf
- Frank Wille - Frank Wille
- Ryogo Yoshimura - Ryogo Yoshimura
- Lukas Zanner
- Andrey Zholos - Andrey Zholos
- Santi Zupancic - Santi Zupancic
- Jonas Ådahl - Jonas Ådahl
+22 -19
View File
@@ -1,24 +1,27 @@
set(glfw_DOCS_SOURCES # NOTE: The order of this list determines the order of items in the Guides
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" # (i.e. Pages) list in the generated documentation
"${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" set(GLFW_DOXYGEN_SOURCES
"${GLFW_SOURCE_DIR}/docs/main.dox" "include/GLFW/glfw3.h"
"${GLFW_SOURCE_DIR}/docs/news.dox" "include/GLFW/glfw3native.h"
"${GLFW_SOURCE_DIR}/docs/quick.dox" "docs/main.dox"
"${GLFW_SOURCE_DIR}/docs/moving.dox" "docs/news.dox"
"${GLFW_SOURCE_DIR}/docs/compile.dox" "docs/quick.dox"
"${GLFW_SOURCE_DIR}/docs/build.dox" "docs/moving.dox"
"${GLFW_SOURCE_DIR}/docs/intro.dox" "docs/compile.dox"
"${GLFW_SOURCE_DIR}/docs/context.dox" "docs/build.dox"
"${GLFW_SOURCE_DIR}/docs/monitor.dox" "docs/intro.dox"
"${GLFW_SOURCE_DIR}/docs/window.dox" "docs/context.dox"
"${GLFW_SOURCE_DIR}/docs/input.dox" "docs/monitor.dox"
"${GLFW_SOURCE_DIR}/docs/vulkan.dox" "docs/window.dox"
"${GLFW_SOURCE_DIR}/docs/compat.dox" "docs/input.dox"
"${GLFW_SOURCE_DIR}/docs/internal.dox") "docs/vulkan.dox"
"docs/compat.dox"
"docs/internal.dox")
foreach(arg ${glfw_DOCS_SOURCES}) # Format the source list into a Doxyfile INPUT value that Doxygen can parse
set(GLFW_DOCS_SOURCES "${GLFW_DOCS_SOURCES} \\\n\"${arg}\"") foreach(path IN LISTS GLFW_DOXYGEN_SOURCES)
set(GLFW_DOXYGEN_INPUT "${GLFW_DOXYGEN_INPUT} \\\n\"${GLFW_SOURCE_DIR}/${path}\"")
endforeach() endforeach()
configure_file(Doxyfile.in Doxyfile @ONLY) configure_file(Doxyfile.in Doxyfile @ONLY)
+10
View File
@@ -0,0 +1,10 @@
* @elmindreda
src/wl_* @linkmauve
docs/*.css @glfw/webdev
docs/*.less @glfw/webdev
docs/*.html @glfw/webdev
docs/*.xml @glfw/webdev
+2 -2
View File
@@ -20,14 +20,14 @@
## Asking a question ## Asking a question
Questions about how to use GLFW should be asked either in the [support Questions about how to use GLFW should be asked either in the [support
section](http://discourse.glfw.org/c/support) of the forum, under the [Stack section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
Stack Exchange or in the IRC channel `#glfw` on Stack Exchange or in the IRC channel `#glfw` on
[Freenode](http://freenode.net/). [Freenode](http://freenode.net/).
Questions about the design or implementation of GLFW or about future plans Questions about the design or implementation of GLFW or about future plans
should be asked in the [dev section](http://discourse.glfw.org/c/dev) of the should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
forum or in the IRC channel. Please don't open a GitHub issue to discuss design forum or in the IRC channel. Please don't open a GitHub issue to discuss design
questions without first checking with a maintainer. questions without first checking with a maintainer.
+4 -17
View File
@@ -32,7 +32,7 @@ PROJECT_NAME = "GLFW"
# This could be handy for archiving the generated documentation or # This could be handy for archiving the generated documentation or
# if some version control system is used. # if some version control system is used.
PROJECT_NUMBER = @GLFW_VERSION_FULL@ PROJECT_NUMBER = @GLFW_VERSION@
# Using the PROJECT_BRIEF tag one can provide an optional one line description # Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer # for a project that appears at the top of each page and should give viewer
@@ -200,6 +200,7 @@ ALIASES = "thread_safety=@par Thread safety^^" \
"analysis=@par Analysis^^" \ "analysis=@par Analysis^^" \
"reentrancy=@par Reentrancy^^" \ "reentrancy=@par Reentrancy^^" \
"errors=@par Errors^^" \ "errors=@par Errors^^" \
"callback_signature=@par Callback signature^^" \
"glfw3=__GLFW 3:__" \ "glfw3=__GLFW 3:__" \
"x11=__X11:__" \ "x11=__X11:__" \
"wayland=__Wayland:__" \ "wayland=__Wayland:__" \
@@ -662,7 +663,7 @@ WARN_LOGFILE = "@GLFW_BINARY_DIR@/docs/warnings.txt"
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = @GLFW_DOCS_SOURCES@ INPUT = @GLFW_DOXYGEN_INPUT@
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -1631,11 +1632,6 @@ ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES EXTERNAL_GROUPS = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
PERL_PATH = /usr/bin/perl
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Configuration options related to the dot tool # Configuration options related to the dot tool
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@@ -1648,15 +1644,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = YES CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# If set to YES, the inheritance and collaboration graphs will hide # If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented # inheritance and usage relations if the target is undocumented
# or is not a class. # or is not a class.
@@ -1727,7 +1714,7 @@ UML_LOOK = NO
# the class node. If there are many fields or methods and many nodes the # the class node. If there are many fields or methods and many nodes the
# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
# threshold limits the number of items for each type to make the size more # threshold limits the number of items for each type to make the size more
# managable. Set this to 0 for no limit. Note that the threshold may be # manageable. Set this to 0 for no limit. Note that the threshold may be
# exceeded by 50% before the limit is enforced. # exceeded by 50% before the limit is enforced.
UML_LIMIT_NUM_FIELDS = 10 UML_LIMIT_NUM_FIELDS = 10
+14
View File
@@ -0,0 +1,14 @@
# Support resources
See the [latest documentation](http://www.glfw.org/docs/latest/) for tutorials,
guides and the API reference.
If you have questions about using GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Freenode](http://freenode.net/).
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please check the [contribution
guide](https://github.com/glfw/glfw/blob/master/docs/CONTRIBUTING.md) for
information on what to include when reporting a bug.
+3 -13
View File
@@ -186,18 +186,8 @@ build_link_cmake_package.
With a few changes to your `CMakeLists.txt` you can have the GLFW source tree With a few changes to your `CMakeLists.txt` you can have the GLFW source tree
built along with your application. built along with your application.
When including GLFW as part of your build, you probably don't want to build the Add the root directory of the GLFW source tree to your project. This will add
GLFW tests, examples and documentation. To disable these, set the corresponding the `glfw` target and the necessary cache variables to your project.
cache variables before adding the GLFW source tree.
@code
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
@endcode
Then add the root directory of the GLFW source tree to your project. This
will add the `glfw` target and the necessary cache variables to your project.
@code{.cmake} @code{.cmake}
add_subdirectory(path/to/glfw) add_subdirectory(path/to/glfw)
@@ -253,7 +243,7 @@ With a few changes to your `CMakeLists.txt` you can locate the package and
target files generated when GLFW is installed. target files generated when GLFW is installed.
@code{.cmake} @code{.cmake}
find_package(glfw3 3.3 REQUIRED) find_package(glfw3 3.4 REQUIRED)
@endcode @endcode
Once GLFW has been added to the project, link against it with the `glfw` target. Once GLFW has been added to the project, link against it with the `glfw` target.
+9 -7
View File
@@ -85,6 +85,13 @@ transparent window framebuffers. If the running X server does not support this
extension or there is no running compositing manager, the extension or there is no running compositing manager, the
`GLFW_TRANSPARENT_FRAMEBUFFER` framebuffer hint will have no effect. `GLFW_TRANSPARENT_FRAMEBUFFER` framebuffer hint will have no effect.
GLFW uses both the Xcursor extension and the freedesktop cursor conventions to
provide an expanded set of standard cursor shapes. If the running X server does
not support this extension or the current cursor theme does not support the
conventions, the `GLFW_RESIZE_NWSE_CURSOR`, `GLFW_RESIZE_NESW_CURSOR` and
`GLFW_NOT_ALLOWED_CURSOR` shapes will not be available and other shapes may use
legacy images.
@section compat_wayland Wayland protocols and IPC standards @section compat_wayland Wayland protocols and IPC standards
@@ -104,11 +111,7 @@ has been configured in the compositor.
GLFW uses the [xdg-shell GLFW uses the [xdg-shell
protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml) protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/stable/xdg-shell/xdg-shell.xml)
to provide better window management. This protocol is part of to provide better window management. This protocol is part of
wayland-protocols 1.12, and mandatory at build time. If the running compositor wayland-protocols 1.12, and mandatory at build time.
does not support this protocol, the older [wl_shell
interface](https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml#n972)
will be used instead. This will result in a worse integration with the
desktop, especially on tiling compositors.
GLFW uses the [relative pointer GLFW uses the [relative pointer
protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/relative-pointer/relative-pointer-unstable-v1.xml) protocol](https://cgit.freedesktop.org/wayland/wayland-protocols/tree/unstable/relative-pointer/relative-pointer-unstable-v1.xml)
@@ -234,8 +237,7 @@ at most OpenGL version 2.1.
Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and Because of this, on OS X 10.7 and later, the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if `GLFW_CONTEXT_VERSION_MINOR` hints will cause @ref glfwCreateWindow to fail if
given version 3.0 or 3.1. The `GLFW_OPENGL_FORWARD_COMPAT` hint must be set to given version 3.0 or 3.1. The `GLFW_OPENGL_PROFILE` hint must be set to
`GLFW_TRUE` and the `GLFW_OPENGL_PROFILE` hint must be set to
`GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The `GLFW_OPENGL_CORE_PROFILE` when creating OpenGL 3.2 and later contexts. The
`GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored. `GLFW_OPENGL_DEBUG_CONTEXT` and `GLFW_CONTEXT_NO_ERROR` hints are ignored.
+4 -2
View File
@@ -212,11 +212,13 @@ library or as a DLL / shared library / dynamic library.
@anchor GLFW_BUILD_EXAMPLES @anchor GLFW_BUILD_EXAMPLES
__GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built __GLFW_BUILD_EXAMPLES__ determines whether the GLFW examples are built
along with the library. along with the library. This is enabled by default unless GLFW is being built
as a sub-project.
@anchor GLFW_BUILD_TESTS @anchor GLFW_BUILD_TESTS
__GLFW_BUILD_TESTS__ determines whether the GLFW test programs are __GLFW_BUILD_TESTS__ determines whether the GLFW test programs are
built along with the library. built along with the library. This is enabled by default unless GLFW is being
built as a sub-project.
@anchor GLFW_BUILD_DOCS @anchor GLFW_BUILD_DOCS
__GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along __GLFW_BUILD_DOCS__ determines whether the GLFW documentation is built along
+16 -12
View File
@@ -373,12 +373,15 @@ A cursor with a [standard shape](@ref shapes) from the current system cursor
theme can be can be created with @ref glfwCreateStandardCursor. theme can be can be created with @ref glfwCreateStandardCursor.
@code @code
GLFWcursor* cursor = glfwCreateStandardCursor(GLFW_HRESIZE_CURSOR); GLFWcursor* url_cursor = glfwCreateStandardCursor(GLFW_POINTING_HAND_CURSOR);
@endcode @endcode
These cursor objects behave in the exact same way as those created with @ref These cursor objects behave in the exact same way as those created with @ref
glfwCreateCursor except that the system cursor theme provides the actual image. glfwCreateCursor except that the system cursor theme provides the actual image.
A few of these shapes are not available everywhere. If a shape is unavailable,
`NULL` is returned. See @ref glfwCreateStandardCursor for details.
@subsubsection cursor_destruction Cursor destruction @subsubsection cursor_destruction Cursor destruction
@@ -864,31 +867,32 @@ GLFW provides high-resolution time input, in seconds, with @ref glfwGetTime.
double seconds = glfwGetTime(); double seconds = glfwGetTime();
@endcode @endcode
It returns the number of seconds since the timer was started when the library It returns the number of seconds since the library was initialized with @ref
was initialized with @ref glfwInit. The platform-specific time sources used glfwInit. The platform-specific time sources used typically have micro- or
usually have micro- or nanosecond resolution. nanosecond resolution.
You can modify the reference time with @ref glfwSetTime. You can modify the base time with @ref glfwSetTime.
@code @code
glfwSetTime(4.0); glfwSetTime(4.0);
@endcode @endcode
This sets the timer to the specified time, in seconds. This sets the time to the specified time, in seconds, and it continues to count
from there.
You can also access the raw timer value, measured in 1&nbsp;/&nbsp;frequency You can also access the raw timer used to implement the functions above,
seconds, with @ref glfwGetTimerValue. with @ref glfwGetTimerValue.
@code @code
uint64_t value = glfwGetTimerValue(); uint64_t value = glfwGetTimerValue();
@endcode @endcode
The frequency of the raw timer varies depending on what time sources are This value is in 1&nbsp;/&nbsp;frequency seconds. The frequency of the raw
available on the machine. You can query its frequency, in Hz, with @ref timer varies depending on the operating system and hardware. You can query the
glfwGetTimerFrequency. frequency, in Hz, with @ref glfwGetTimerFrequency.
@code @code
uint64_t freqency = glfwGetTimerFrequency(); uint64_t frequency = glfwGetTimerFrequency();
@endcode @endcode
+1 -1
View File
@@ -8,7 +8,7 @@ GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and
Vulkan application development. It provides a simple, platform-independent API Vulkan application development. It provides a simple, platform-independent API
for creating windows, contexts and surfaces, reading input, handling events, etc. for creating windows, contexts and surfaces, reading input, handling events, etc.
@ref news_33 list new features, caveats and deprecations. @ref news_34 list new features, caveats and deprecations.
@ref quick_guide is a guide for users new to GLFW. It takes you through how to @ref quick_guide is a guide for users new to GLFW. It takes you through how to
write a small but complete program. write a small but complete program.
+2 -2
View File
@@ -94,8 +94,8 @@ 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, a user pointer, an estimated physical a virtual position, a content scale, a human-readable name, a user pointer, an
size and a gamma ramp. estimated physical size and a gamma ramp.
@subsection monitor_modes Video modes @subsection monitor_modes Video modes
+51 -824
View File
@@ -5,852 +5,79 @@
@tableofcontents @tableofcontents
@section news_33 Release notes for version 3.3 @section news_34 Release notes for version 3.4
These are the release notes for version 3.3. For a more detailed view including @subsection features_34 New features in version 3.4
all fixed bugs see the [version history](https://www.glfw.org/changelog.html).
Please review the caveats, deprecations and removals if your project was written @subsubsection standard_cursors_34 More standard cursors
against an earlier version of GLFW 3.
GLFW now provides the standard cursor shapes @ref GLFW_RESIZE_NWSE_CURSOR and
@ref GLFW_RESIZE_NESW_CURSOR for diagonal resizing, @ref GLFW_RESIZE_ALL_CURSOR
for omni-directional resizing and @ref GLFW_NOT_ALLOWED_CURSOR for showing an
action is not allowed.
@subsection features_33 New features in version 3.3 Unlike the original set, these shapes may not be available everywhere and
creation will then fail with the new @ref GLFW_CURSOR_UNAVAILABLE error.
@subsubsection gamepad_33 Gamepad input via SDL_GameControllerDB The cursors for horizontal and vertical resizing are now referred to as @ref
GLFW_RESIZE_EW_CURSOR and @ref GLFW_RESIZE_NS_CURSOR, and the pointing hand
cursor is now referred to as @ref GLFW_POINTING_HAND_CURSOR. The older names
are still available.
GLFW can now remap game controllers to a standard Xbox-like layout using For more information see @ref cursor_standard.
a built-in copy of SDL_GameControllerDB. Call @ref glfwJoystickIsGamepad to
check if a joystick has a mapping, @ref glfwGetGamepadState to retrieve its
input state, @ref glfwUpdateGamepadMappings to add newer mappings and @ref
glfwGetGamepadName and @ref glfwGetJoystickGUID for mapping related information.
For more information see @ref gamepad.
@subsubsection features_34_win32_keymenu Support for keyboard access to Windows window menu
@subsubsection moltenvk_33 Support for Vulkan on macOS via MoltenVK GLFW now provides the
[GLFW_WIN32_KEYBOARD_MENU](@ref GLFW_WIN32_KEYBOARD_MENU_hint) window hint for
enabling keyboard access to the window menu via the Alt+Space and
Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented
applications.
GLFW now supports [MoltenVK](https://moltengl.com/moltenvk/), a Vulkan
implementation on top of the Metal API, and its `VK_MVK_macos_surface` window
surface creation extension. MoltenVK is included in the [macOS Vulkan
SDK](https://vulkan.lunarg.com/).
For more information see @ref vulkan_guide. @subsection caveats_34 Caveats for version 3.4
@subsubsection standalone_34 Tests and examples are disabled when built as a sub-project
@subsubsection content_scale_33 Content scale queries for DPI-aware rendering GLFW now does not build the tests and examples when it is added as
a subdirectory of another CMake project. To enable these, set the @ref
GLFW_BUILD_TESTS and @ref GLFW_BUILD_EXAMPLES cache variables before adding the
GLFW subdirectory.
GLFW now provides content scales for windows and monitors, i.e. the ratio @code{.cmake}
between their current DPI and the platform's default DPI, with @ref set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE)
glfwGetWindowContentScale and @ref glfwGetMonitorContentScale. set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)
@endcode
Changes of the content scale of a window can be received with the window content
scale callback, set with @ref glfwSetWindowContentScaleCallback.
The @ref GLFW_SCALE_TO_MONITOR window hint enables automatic resizing of a @subsection deprecations_34 Deprecations in version 3.4
window by the content scale of the monitor it is placed, on platforms like
Windows where this is necessary. This takes effect both on creation and when
the window is moved between monitors. It is related to but different from
[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint).
For more information see @ref window_scale. @subsection removals_34 Removals in 3.4
@subsection symbols_34 New symbols in version 3.4
@subsubsection setwindowattrib_33 Support for updating window attributes @subsubsection functions_34 New functions in version 3.4
@subsubsection types_34 New types in version 3.4
@subsubsection constants_34 New constants in version 3.4
GLFW now supports changing the [GLFW_DECORATED](@ref GLFW_DECORATED_attrib), - @ref GLFW_POINTING_HAND_CURSOR
[GLFW_RESIZABLE](@ref GLFW_RESIZABLE_attrib), - @ref GLFW_RESIZE_EW_CURSOR
[GLFW_FLOATING](@ref GLFW_FLOATING_attrib), - @ref GLFW_RESIZE_NS_CURSOR
[GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_attrib) and - @ref GLFW_RESIZE_NWSE_CURSOR
[GLFW_FOCUS_ON_SHOW](@ref GLFW_FOCUS_ON_SHOW_attrib) attributes for existing - @ref GLFW_RESIZE_NESW_CURSOR
windows with @ref glfwSetWindowAttrib. - @ref GLFW_RESIZE_ALL_CURSOR
- @ref GLFW_NOT_ALLOWED_CURSOR
- @ref GLFW_CURSOR_UNAVAILABLE
- @ref GLFW_WIN32_KEYBOARD_MENU
For more information see @ref window_attribs.
@section news_archive Release notes for earlier versions
@subsubsection raw_motion_33 Support for raw mouse motion - [Release notes for 3.3](https://www.glfw.org/docs/3.3/news.html)
- [Release notes for 3.2](https://www.glfw.org/docs/3.2/news.html)
GLFW now supports raw (unscaled and unaccelerated) mouse motion in disabled - [Release notes for 3.1](https://www.glfw.org/docs/3.1/news.html)
cursor mode with the [GLFW_RAW_MOUSE_MOTION](@ref GLFW_RAW_MOUSE_MOTION) input - [Release notes for 3.0](https://www.glfw.org/docs/3.0/news.html)
mode. Raw mouse motion input is not yet implemented on macOS. Call @ref
glfwRawMouseMotionSupported to check if GLFW can provide raw mouse motion on the
current system.
For more information see @ref raw_mouse_motion.
@subsubsection joysticks_33 Joystick hats
GLFW can now return the state of hats (i.e. POVs or D-pads) of a joystick with
@ref glfwGetJoystickHats. For compatibility, hats are also exposed as buttons.
This can be disabled with the @ref GLFW_JOYSTICK_HAT_BUTTONS initialization
hint.
For more information see @ref joystick_hat.
@subsubsection geterror_33 Error query
GLFW now supports querying the last error code for the calling thread and its
human-readable description with @ref glfwGetError. This can be used instead of
or together with the error callback.
For more information see @ref error_handling.
@subsubsection init_hints_33 Support for initialization hints
GLFW now supports setting library initialization hints with @ref glfwInitHint.
These must be set before initialization to take effect. Some of these hints are
platform specific but are safe to set on any platform.
For more information see @ref init_hints.
@subsubsection attention_33 User attention request
GLFW now supports requesting user attention with @ref
glfwRequestWindowAttention. Where possible this calls attention to the
specified window. On platforms like macOS it calls attention to the whole
application.
For more information see @ref window_attention.
@subsubsection maximize_33 Window maximization callback
GLFW now supports notifying the application that the window has been maximized
@ref glfwSetWindowMaximizeCallback. This is called both when the window was
maximized by the user and when it was done with @ref glfwMaximizeWindow.
For more information see @ref window_maximize.
@subsubsection workarea_33 Query for the monitor work area
GLFW now supports querying the work area of a monitor, i.e. the area not
occupied by task bars or global menu bars, with @ref glfwGetMonitorWorkarea. On
platforms that lack this concept, the whole area of the monitor is returned.
For more information see @ref monitor_workarea.
@subsubsection transparency_33 Transparent windows and framebuffers
GLFW now supports the creation of windows with transparent framebuffers on
systems with desktop compositing enabled with the @ref
GLFW_TRANSPARENT_FRAMEBUFFER window hint and attribute. This hint must be set
before window creation and leaves any window decorations opaque.
GLFW now also supports whole window transparency with @ref glfwGetWindowOpacity
and @ref glfwSetWindowOpacity. This value controls the opacity of the whole
window including decorations and unlike framebuffer transparency can be changed
at any time after window creation.
For more information see @ref window_transparency.
@subsubsection key_scancode_33 Query for the scancode of a key
GLFW now supports querying the platform dependent scancode of any physical key
with @ref glfwGetKeyScancode.
For more information see @ref input_key.
@subsubsection center_cursor_33 Cursor centering window hint
GLFW now supports controlling whether the cursor is centered over newly created
full screen windows with the [GLFW_CENTER_CURSOR](@ref GLFW_CENTER_CURSOR_hint)
window hint. It is enabled by default.
@subsubsection cursor_hover_33 Mouse cursor hover window attribute
GLFW now supports polling whether the cursor is hovering over the window content
area with the [GLFW_HOVERED](@ref GLFW_HOVERED_attrib) window attribute. This
attribute corresponds to the [cursor enter/leave](@ref cursor_enter) event.
@subsubsection focusonshow_33 Window hint and attribute for input focus on show
GLFW now has the [GLFW_FOCUS_ON_SHOW](@ref GLFW_DECORATED_hint) window hint and
attribute for controlling whether a window gets input focus when shown. It is
enabled by default. It applies both when creating an visible window with @ref
glfwCreateWindow and when showing it with @ref glfwShowWindow.
This is a workaround for GLFW 3.0 lacking @ref glfwFocusWindow and will be
corrected in the next major version.
For more information see @ref window_hide.
@subsubsection device_userptr_33 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.
For more information see @ref monitor_userptr and @ref joystick_userptr.
@subsubsection macos_nib_33 macOS menu bar from nib file
GLFW will now load a `MainMenu.nib` file if found in the `Contents/Resources`
directory of the application bundle, as a way to replace the GLFW menu bar
without recompiling GLFW. This behavior can be disabled with the
[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint) initialization hint.
@subsubsection glext_33 Support for more context creation extensions
The context hint @ref GLFW_SRGB_CAPABLE now supports OpenGL ES via
`WGL_EXT_colorspace`, the context hint @ref GLFW_CONTEXT_NO_ERROR now supports
`WGL_ARB_create_context_no_error` and `GLX_ARB_create_context_no_error`, the
context hint @ref GLFW_CONTEXT_RELEASE_BEHAVIOR now supports
`EGL_KHR_context_flush_control` and @ref glfwGetProcAddress now supports
`EGL_KHR_get_all_proc_addresses`.
@subsubsection osmesa_33 OSMesa off-screen context creation support
GLFW now supports creating off-screen OpenGL contexts using
[OSMesa](https://www.mesa3d.org/osmesa.html) by setting
[GLFW_CONTEXT_CREATION_API](@ref GLFW_CONTEXT_CREATION_API_hint) to
`GLFW_OSMESA_CONTEXT_API`. Native access function have been added to retrieve
the OSMesa color and depth buffers.
There is also a new null backend that uses OSMesa as its native context
creation API, intended for automated testing. This backend does not provide
input.
@subsection caveats_33 Caveats for version 3.3
@subsubsection joystick_layout_33 Layout of joysticks have changed
The way joystick elements are arranged have changed to match SDL2 in order to
support SDL_GameControllerDB mappings. The layout of joysticks may
change again if required for compatibility with SDL2. If you need a known and
stable layout for game controllers, see if you can switch to @ref gamepad.
Existing code that depends on a specific joystick layout will likely have to be
updated.
@subsubsection wait_events_33 No window required to wait for events
The @ref glfwWaitEvents and @ref glfwWaitEventsTimeout functions no longer need
a window to be created to wait for events. Before version 3.3 these functions
would return immediately if there were no user-created windows. On platforms
where only windows can receive events, an internal helper window is used.
Existing code that depends on the earlier behavior will likely have to be
updated.
@subsubsection gamma_ramp_size_33 Gamma ramp size of 256 may be rejected
The documentation for versions before 3.3 stated that a gamma ramp size of 256
would always be accepted. This was never the case on X11 and could lead to
artifacts on macOS. The @ref glfwSetGamma function has been updated to always
generate a ramp of the correct size.
Existing code that hardcodes a size of 256 should be updated to use the size of
the current ramp of a monitor when setting a new ramp for that monitor.
@subsubsection xinput_deadzone_33 Windows XInput deadzone removed
GLFW no longer applies any deadzone to the input state received from the XInput
API. This was never done for any other platform joystick API so this change
makes the behavior more consistent but you will need to apply your own deadzone
if desired.
@subsubsection x11_clipboard_33 X11 clipboard transfer limits
GLFW now supports reading clipboard text via the `INCR` method, which removes
the limit on how much text can be read with @ref glfwGetClipboardString.
However, writing via this method is not yet supported, so you may not be able to
write a very large string with @ref glfwSetClipboardString even if you read it
from the clipboard earlier.
The exact size limit for writing to the clipboard is negotiated with each
receiving application but is at least several tens of kilobytes. Note that only
the read limit has changed. Any string that could be written before still can
be.
@subsubsection x11_linking_33 X11 extension libraries are loaded dynamically
GLFW now loads all X11 extension libraries at initialization. The only X11
library you need to link against is `libX11`. The header files for the
extension libraries are still required for compilation.
Existing projects and makefiles that link GLFW directly against the extension
libraries should still build correctly but will add these libraries as load-time
dependencies.
@subsubsection cmake_version_33 CMake 3.0 or later is required
The minimum CMake version has been raised from 2.8.12 to 3.0. This is only
a requirement of the GLFW CMake files. The GLFW source files do not depend on
CMake.
@subsection deprecations_33 Deprecations in version 3.3
@subsubsection charmods_callback_33 Character with modifiers callback
The character with modifiers callback set with @ref glfwSetCharModsCallback has
been deprecated and should if possible not be used.
Existing code should still work but further bug fixes will likely not be made.
The callback will be removed in the next major version.
@subsubsection clipboard_window_33 Window parameter to clipboard functions
The window parameter of the clipboard functions @ref glfwGetClipboardString and
@ref glfwSetClipboardString has been deprecated and is no longer used on any
platform. On platforms where the clipboard must be owned by a specific window,
an internal helper window is used.
Existing code should still work unless it depends on a specific window owning
the clipboard. New code may pass `NULL` as the window argument. The parameter
will be removed in a future release.
@subsection removals_33 Removals in 3.3
@subsubsection macos_options_33 macOS specific CMake options and macros
The `GLFW_USE_RETINA`, `GLFW_USE_CHDIR` and `GLFW_USE_MENUBAR` CMake options and
the `_GLFW_USE_RETINA`, `_GLFW_USE_CHDIR` and `_GLFW_USE_MENUBAR` compile-time
macros have been removed.
These options and macros are replaced by the window hint
[GLFW_COCOA_RETINA_FRAMEBUFFER](@ref GLFW_COCOA_RETINA_FRAMEBUFFER_hint)
and the init hints
[GLFW_COCOA_CHDIR_RESOURCES](@ref GLFW_COCOA_CHDIR_RESOURCES_hint) and
[GLFW_COCOA_MENUBAR](@ref GLFW_COCOA_MENUBAR_hint).
Existing projects and makefiles that set these options or define these macros
during compilation of GLFW will still build but it will have no effect and the
default behaviors will be used.
@subsubsection vulkan_sdk_33 LunarG Vulkan SDK dependency
The GLFW test programs that previously depended on the LunarG Vulkan SDK now
instead uses a Vulkan loader generated by
[glad2](https://github.com/Dav1dde/glad). This means the GLFW CMake files no
longer look for the Vulkan SDK.
Existing CMake projects that depended on the Vulkan SDK cache variables from
GLFW will need to call `find_package(Vulkan)` themselves. CMake 3.7 and later
already comes with a
[Vulkan find module](https://cmake.org/cmake/help/latest/module/FindVulkan.html)
similar to the one GLFW previously included.
@subsubsection lib_suffix_33 CMake option LIB_SUFFIX
The `LIB_SUFFIX` CMake option has been removed. GLFW now uses the
GNUInstallDirs CMake package to handle platform specific details like the
library directory suffix and the `LIB_SUFFIX` CMake option has been removed.
Existing projects and makefiles that set the `LIB_SUFFIX` option will use the
suffix chosen by the GNUInstallDirs package and the option will be ignored.
@subsubsection mir_removed_33 Mir support
The experimental Mir support has been completely removed as the Mir project has
implemented support for the Wayland protocol and is recommending that
applications use that instead.
Existing projects and makefiles that select Mir when compiling GLFW will fail.
Use Wayland or X11 instead.
@subsection symbols_33 New symbols in version 3.3
@subsubsection functions_33 New functions in version 3.3
- @ref glfwInitHint
- @ref glfwGetError
- @ref glfwGetMonitorWorkarea
- @ref glfwGetMonitorContentScale
- @ref glfwGetMonitorUserPointer
- @ref glfwSetMonitorUserPointer
- @ref glfwWindowHintString
- @ref glfwGetWindowContentScale
- @ref glfwGetWindowOpacity
- @ref glfwSetWindowOpacity
- @ref glfwRequestWindowAttention
- @ref glfwSetWindowAttrib
- @ref glfwSetWindowMaximizeCallback
- @ref glfwSetWindowContentScaleCallback
- @ref glfwRawMouseMotionSupported
- @ref glfwGetKeyScancode
- @ref glfwGetJoystickHats
- @ref glfwGetJoystickGUID
- @ref glfwGetJoystickUserPointer
- @ref glfwSetJoystickUserPointer
- @ref glfwJoystickIsGamepad
- @ref glfwUpdateGamepadMappings
- @ref glfwGetGamepadName
- @ref glfwGetGamepadState
@subsubsection types_33 New types in version 3.3
- @ref GLFWwindowmaximizefun
- @ref GLFWwindowcontentscalefun
- @ref GLFWgamepadstate
@subsubsection constants_33 New constants in version 3.3
- @ref GLFW_NO_ERROR
- @ref GLFW_JOYSTICK_HAT_BUTTONS
- @ref GLFW_COCOA_CHDIR_RESOURCES
- @ref GLFW_COCOA_MENUBAR
- @ref GLFW_CENTER_CURSOR
- @ref GLFW_TRANSPARENT_FRAMEBUFFER
- @ref GLFW_HOVERED
- @ref GLFW_FOCUS_ON_SHOW
- @ref GLFW_SCALE_TO_MONITOR
- @ref GLFW_COCOA_RETINA_FRAMEBUFFER
- @ref GLFW_COCOA_FRAME_NAME
- @ref GLFW_COCOA_GRAPHICS_SWITCHING
- @ref GLFW_X11_CLASS_NAME
- @ref GLFW_X11_INSTANCE_NAME
- @ref GLFW_OSMESA_CONTEXT_API
- @ref GLFW_HAT_CENTERED
- @ref GLFW_HAT_UP
- @ref GLFW_HAT_RIGHT
- @ref GLFW_HAT_DOWN
- @ref GLFW_HAT_LEFT
- @ref GLFW_HAT_RIGHT_UP
- @ref GLFW_HAT_RIGHT_DOWN
- @ref GLFW_HAT_LEFT_UP
- @ref GLFW_HAT_LEFT_DOWN
- @ref GLFW_MOD_CAPS_LOCK
- @ref GLFW_MOD_NUM_LOCK
- @ref GLFW_LOCK_KEY_MODS
- @ref GLFW_RAW_MOUSE_MOTION
- @ref GLFW_GAMEPAD_BUTTON_A
- @ref GLFW_GAMEPAD_BUTTON_B
- @ref GLFW_GAMEPAD_BUTTON_X
- @ref GLFW_GAMEPAD_BUTTON_Y
- @ref GLFW_GAMEPAD_BUTTON_LEFT_BUMPER
- @ref GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER
- @ref GLFW_GAMEPAD_BUTTON_BACK
- @ref GLFW_GAMEPAD_BUTTON_START
- @ref GLFW_GAMEPAD_BUTTON_GUIDE
- @ref GLFW_GAMEPAD_BUTTON_LEFT_THUMB
- @ref GLFW_GAMEPAD_BUTTON_RIGHT_THUMB
- @ref GLFW_GAMEPAD_BUTTON_DPAD_UP
- @ref GLFW_GAMEPAD_BUTTON_DPAD_RIGHT
- @ref GLFW_GAMEPAD_BUTTON_DPAD_DOWN
- @ref GLFW_GAMEPAD_BUTTON_DPAD_LEFT
- @ref GLFW_GAMEPAD_BUTTON_LAST
- @ref GLFW_GAMEPAD_BUTTON_CROSS
- @ref GLFW_GAMEPAD_BUTTON_CIRCLE
- @ref GLFW_GAMEPAD_BUTTON_SQUARE
- @ref GLFW_GAMEPAD_BUTTON_TRIANGLE
- @ref GLFW_GAMEPAD_AXIS_LEFT_X
- @ref GLFW_GAMEPAD_AXIS_LEFT_Y
- @ref GLFW_GAMEPAD_AXIS_RIGHT_X
- @ref GLFW_GAMEPAD_AXIS_RIGHT_Y
- @ref GLFW_GAMEPAD_AXIS_LEFT_TRIGGER
- @ref GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER
- @ref GLFW_GAMEPAD_AXIS_LAST
@section news_32 Release notes for 3.2
These are the release notes for version 3.2. For a more detailed view including
all fixed bugs see the [version history](https://www.glfw.org/changelog.html).
@subsection features_32 New features in version 3.2
@subsubsection news_32_vulkan Support for Vulkan
GLFW now supports basic integration with Vulkan with @ref glfwVulkanSupported,
@ref glfwGetRequiredInstanceExtensions, @ref glfwGetInstanceProcAddress, @ref
glfwGetPhysicalDevicePresentationSupport and @ref glfwCreateWindowSurface.
Vulkan header inclusion can be selected with
@ref GLFW_INCLUDE_VULKAN.
@subsubsection news_32_setwindowmonitor Window mode switching
GLFW now supports switching between windowed and full screen modes and updating
the monitor and desired resolution and refresh rate of full screen windows with
@ref glfwSetWindowMonitor.
@subsubsection news_32_maximize Window maxmimization support
GLFW now supports window maximization with @ref glfwMaximizeWindow and the
@ref GLFW_MAXIMIZED window hint and attribute.
@subsubsection news_32_focus Window input focus control
GLFW now supports giving windows input focus with @ref glfwFocusWindow.
@subsubsection news_32_sizelimits Window size limit support
GLFW now supports setting both absolute and relative window size limits with
@ref glfwSetWindowSizeLimits and @ref glfwSetWindowAspectRatio.
@subsubsection news_32_keyname Localized key names
GLFW now supports querying the localized name of printable keys with @ref
glfwGetKeyName, either by key token or by scancode.
@subsubsection news_32_waittimeout Wait for events with timeout
GLFW now supports waiting for events for a set amount of time with @ref
glfwWaitEventsTimeout.
@subsubsection news_32_icon Window icon support
GLFW now supports setting the icon of windows with @ref glfwSetWindowIcon.
@subsubsection news_32_timer Raw timer access
GLFW now supports raw timer values with @ref glfwGetTimerValue and @ref
glfwGetTimerFrequency.
@subsubsection news_32_joystick Joystick connection callback
GLFW now supports notifying when a joystick has been connected or disconnected
with @ref glfwSetJoystickCallback.
@subsubsection news_32_noapi Context-less windows
GLFW now supports creating windows without a OpenGL or OpenGL ES context by
setting the [GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_NO_API`.
@subsubsection news_32_contextapi Run-time context creation API selection
GLFW now supports selecting and querying the context creation API at run-time
with the @ref GLFW_CONTEXT_CREATION_API hint and attribute.
@subsubsection news_32_noerror Error-free context creation
GLFW now supports creating and querying OpenGL and OpenGL ES contexts that do
not emit errors with the @ref GLFW_CONTEXT_NO_ERROR hint, provided the machine
supports the `GL_KHR_no_error` extension.
@subsubsection news_32_cmake CMake config-file package support
GLFW now supports being used as a
[config-file package](@ref build_link_cmake_package) from other projects for
easy linking with the library and its dependencies.
@section news_31 Release notes for 3.1
These are the release notes for version 3.1. For a more detailed view including
all fixed bugs see the [version history](https://www.glfw.org/changelog.html).
@subsection features_31 New features in version 3.1
@subsubsection news_31_cursor Custom mouse cursor images
GLFW now supports creating and setting both custom cursor images and standard
cursor shapes. They are created with @ref glfwCreateCursor or @ref
glfwCreateStandardCursor, set with @ref glfwSetCursor and destroyed with @ref
glfwDestroyCursor.
@see @ref cursor_object
@subsubsection news_31_drop Path drop event
GLFW now provides a callback for receiving the paths of files and directories
dropped onto GLFW windows. The callback is set with @ref glfwSetDropCallback.
@see @ref path_drop
@subsubsection news_31_emptyevent Main thread wake-up
GLFW now provides the @ref glfwPostEmptyEvent function for posting an empty
event from another thread to the main thread event queue, causing @ref
glfwWaitEvents to return.
@see @ref events
@subsubsection news_31_framesize Window frame size query
GLFW now supports querying the size, on each side, of the frame around the
content area of a window, with @ref glfwGetWindowFrameSize.
@see [Window size](@ref window_size)
@subsubsection news_31_autoiconify Simultaneous multi-monitor rendering
GLFW now supports disabling auto-iconification of full screen windows with
the [GLFW_AUTO_ICONIFY](@ref GLFW_AUTO_ICONIFY_hint) window hint. This is
intended for people building multi-monitor installations, where you need windows
to stay in full screen despite losing input focus.
@subsubsection news_31_floating Floating windows
GLFW now supports floating windows, also called topmost or always on top, for
easier debugging with the @ref GLFW_FLOATING window hint and attribute.
@subsubsection news_31_focused Initially unfocused windows
GLFW now supports preventing a windowed mode window from gaining input focus on
creation, with the [GLFW_FOCUSED](@ref GLFW_FOCUSED_hint) window hint.
@subsubsection news_31_direct Direct access for window attributes and cursor position
GLFW now queries the window input focus, visibility and iconification attributes
and the cursor position directly instead of returning cached data.
@subsubsection news_31_charmods Character with modifiers callback
GLFW now provides a callback for character events with modifier key bits. The
callback is set with @ref glfwSetCharModsCallback. Unlike the regular character
callback, this will report character events that will not result in a character
being input, for example if the Control key is held down.
@see @ref input_char
@subsubsection news_31_single Single buffered framebuffers
GLFW now supports the creation of single buffered windows, with the @ref
GLFW_DOUBLEBUFFER hint.
@subsubsection news_31_glext Macro for including extension header
GLFW now includes the extension header appropriate for the chosen OpenGL or
OpenGL ES header when @ref GLFW_INCLUDE_GLEXT is defined. GLFW does not provide
these headers. They must be provided by your development environment or your
OpenGL or OpenGL ES SDK.
@subsubsection news_31_release Context release behaviors
GLFW now supports controlling and querying whether the pipeline is flushed when
a context is made non-current, with the @ref GLFW_CONTEXT_RELEASE_BEHAVIOR hint
and attribute, provided the machine supports the `GL_KHR_context_flush_control`
extension.
@subsubsection news_31_wayland (Experimental) Wayland support
GLFW now has an _experimental_ Wayland display protocol backend that can be
selected on Linux with a CMake option.
@subsubsection news_31_mir (Experimental) Mir support
GLFW now has an _experimental_ Mir display server backend that can be selected
on Linux with a CMake option.
@section news_30 Release notes for 3.0
These are the release notes for version 3.0. For a more detailed view including
all fixed bugs see the [version history](https://www.glfw.org/changelog.html).
@subsection features_30 New features in version 3.0
@subsubsection news_30_cmake CMake build system
GLFW now uses the CMake build system instead of the various makefiles and
project files used by earlier versions. CMake is available for all platforms
supported by GLFW, is present in most package systems and can generate
makefiles and/or project files for most popular development environments.
For more information on how to use CMake, see the
[CMake manual](https://cmake.org/cmake/help/documentation.html).
@subsubsection news_30_multiwnd Multi-window support
GLFW now supports the creation of multiple windows, each with their own OpenGL
or OpenGL ES context, and all window functions now take a window handle. Event
callbacks are now per-window and are provided with the handle of the window that
received the event. The @ref glfwMakeContextCurrent function has been added to
select which context is current on a given thread.
@subsubsection news_30_multimon Multi-monitor support
GLFW now explicitly supports multiple monitors. They can be enumerated with
@ref glfwGetMonitors, queried with @ref glfwGetVideoModes, @ref
glfwGetMonitorPos, @ref glfwGetMonitorName and @ref glfwGetMonitorPhysicalSize,
and specified at window creation to make the newly created window full screen on
that specific monitor.
@subsubsection news_30_unicode Unicode support
All string arguments to GLFW functions and all strings returned by GLFW now use
the UTF-8 encoding. This includes the window title, error string, clipboard
text, monitor and joystick names as well as the extension function arguments (as
ASCII is a subset of UTF-8).
@subsubsection news_30_clipboard Clipboard text I/O
GLFW now supports reading and writing plain text to and from the system
clipboard, with the @ref glfwGetClipboardString and @ref glfwSetClipboardString
functions.
@subsubsection news_30_gamma Gamma ramp support
GLFW now supports setting and reading back the gamma ramp of monitors, with the
@ref glfwGetGammaRamp and @ref glfwSetGammaRamp functions. There is also @ref
glfwSetGamma, which generates a ramp from a gamma value and then sets it.
@subsubsection news_30_gles OpenGL ES support
GLFW now supports the creation of OpenGL ES contexts, by setting the
[GLFW_CLIENT_API](@ref GLFW_CLIENT_API_hint) hint to `GLFW_OPENGL_ES_API`, where
creation of such contexts are supported. Note that GLFW _does not implement_
OpenGL ES, so your driver must provide support in a way usable by GLFW. Modern
Nvidia and Intel drivers support creation of OpenGL ES context using the GLX and
WGL APIs, while AMD provides an EGL implementation instead.
@subsubsection news_30_egl (Experimental) EGL support
GLFW now has an experimental EGL context creation back end that can be selected
through CMake options.
@subsubsection news_30_hidpi High-DPI support
GLFW now supports high-DPI monitors on both Windows and macOS, giving windows
full resolution framebuffers where other UI elements are scaled up. To achieve
this, @ref glfwGetFramebufferSize and @ref glfwSetFramebufferSizeCallback have
been added. These work with pixels, while the rest of the GLFW API works with
screen coordinates. This is important as OpenGL uses pixels, not screen
coordinates.
@subsubsection news_30_error Error callback
GLFW now has an error callback, which can provide your application with much
more detailed diagnostics than was previously possible. The callback is passed
an error code and a description string.
@subsubsection news_30_wndptr Per-window user pointer
Each window now has a user-defined pointer, retrieved with @ref
glfwGetWindowUserPointer and set with @ref glfwSetWindowUserPointer, to make it
easier to integrate GLFW into C++ code.
@subsubsection news_30_iconifyfun Window iconification callback
Each window now has a callback for iconification and restoration events,
which is set with @ref glfwSetWindowIconifyCallback.
@subsubsection news_30_wndposfun Window position callback
Each window now has a callback for position events, which is set with @ref
glfwSetWindowPosCallback.
@subsubsection news_30_wndpos Window position query
The position of a window can now be retrieved using @ref glfwGetWindowPos.
@subsubsection news_30_focusfun Window focus callback
Each windows now has a callback for focus events, which is set with @ref
glfwSetWindowFocusCallback.
@subsubsection news_30_enterleave Cursor enter/leave callback
Each window now has a callback for when the mouse cursor enters or leaves its
content area, which is set with @ref glfwSetCursorEnterCallback.
@subsubsection news_30_wndtitle Initial window title
The title of a window is now specified at creation time, as one of the arguments
to @ref glfwCreateWindow.
@subsubsection news_30_hidden Hidden windows
Windows can now be hidden with @ref glfwHideWindow, shown using @ref
glfwShowWindow and created initially hidden with the @ref GLFW_VISIBLE window
hint and attribute. This allows for off-screen rendering in a way compatible
with most drivers, as well as moving a window to a specific position before
showing it.
@subsubsection news_30_undecorated Undecorated windows
Windowed mode windows can now be created without decorations, e.g. things like
a frame, a title bar, with the @ref GLFW_DECORATED window hint and attribute.
This allows for the creation of things like splash screens.
@subsubsection news_30_keymods Modifier key bit masks
[Modifier key bit mask](@ref mods) parameters have been added to the
[mouse button](@ref GLFWmousebuttonfun) and [key](@ref GLFWkeyfun) callbacks.
@subsubsection news_30_scancode Platform-specific scancodes
A scancode parameter has been added to the [key callback](@ref GLFWkeyfun). Keys
that don't have a [key token](@ref keys) still get passed on with the key
parameter set to `GLFW_KEY_UNKNOWN`. These scancodes will vary between machines
and are intended to be used for key bindings.
@subsubsection news_30_jsname Joystick names
The name of a joystick can now be retrieved using @ref glfwGetJoystickName.
@subsubsection news_30_doxygen Doxygen documentation
You are reading it.
*/ */
+15 -9
View File
@@ -4,7 +4,7 @@
@tableofcontents @tableofcontents
This guide takes you through writing a simple application using GLFW 3. The This guide takes you through writing a small application using GLFW 3. The
application will create a window and OpenGL context, render a rotating triangle application will create a window and OpenGL context, render a rotating triangle
and exit when the user closes the window or presses _Escape_. This guide will and exit when the user closes the window or presses _Escape_. This guide will
introduce a few of the most commonly used functions, but there are many more. introduce a few of the most commonly used functions, but there are many more.
@@ -135,9 +135,14 @@ require a minimum OpenGL version by setting the `GLFW_CONTEXT_VERSION_MAJOR` and
`GLFW_CONTEXT_VERSION_MINOR` hints _before_ creation. If the required minimum `GLFW_CONTEXT_VERSION_MINOR` hints _before_ creation. If the required minimum
version is not supported on the machine, context (and window) creation fails. version is not supported on the machine, context (and window) creation fails.
You can select the OpenGL profile by setting the `GLFW_OPENGL_PROFILE` hint.
This program uses the core profile as that is the only profile macOS supports
for OpenGL 3.x and 4.x.
@code @code
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "My Title", NULL, NULL);
if (!window) if (!window)
{ {
@@ -326,19 +331,20 @@ for example, many kinds of editing tools.
@section quick_example Putting it together @section quick_example Putting it together
Now that you know how to initialize GLFW, create a window and poll for Now that you know how to initialize GLFW, create a window and poll for
keyboard input, it's possible to create a simple program. keyboard input, it's possible to create a small program.
This program creates a 640 by 480 windowed mode window and starts a loop that This program creates a 640 by 480 windowed mode window and starts a loop that
clears the screen, renders a triangle and processes events until the user either clears the screen, renders a triangle and processes events until the user either
presses _Escape_ or closes the window. presses _Escape_ or closes the window.
@snippet simple.c code @snippet triangle-opengl.c code
The program above can be found in the The program above can be found in the
[source package](https://www.glfw.org/download.html) as `examples/simple.c` [source package](https://www.glfw.org/download.html) as
and is compiled along with all other examples when you build GLFW. If you `examples/triangle-opengl.c` and is compiled along with all other examples when
built GLFW from the source package then already have this as `simple.exe` on you build GLFW. If you built GLFW from the source package then you already have
Windows, `simple` on Linux or `simple.app` on macOS. this as `triangle-opengl.exe` on Windows, `triangle-opengl` on Linux or
`triangle-opengl.app` on macOS.
This tutorial used only a few of the many functions GLFW provides. There are This tutorial used only a few of the many functions GLFW provides. There are
guides for each of the areas covered by GLFW. Each guide will introduce all the guides for each of the areas covered by GLFW. Each guide will introduce all the
+36 -7
View File
@@ -234,6 +234,13 @@ alpha channel will be used to combine the framebuffer with the background. This
does not affect window decorations. Possible values are `GLFW_TRUE` and does not affect window decorations. Possible values are `GLFW_TRUE` and
`GLFW_FALSE`. `GLFW_FALSE`.
@par
@win32 GLFW sets a color key for the window to work around repainting issues
with a transparent framebuffer. The chosen color value is RGB 255,0,255
(magenta). This will make pixels with that exact color fully transparent
regardless of their alpha values. If this is a problem, make these pixels any
other color before buffer swap.
@anchor GLFW_FOCUS_ON_SHOW_hint @anchor GLFW_FOCUS_ON_SHOW_hint
__GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input __GLFW_FOCUS_ON_SHOW__ specifies whether the window will be given input
focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. focus when @ref glfwShowWindow is called. Possible values are `GLFW_TRUE` and `GLFW_FALSE`.
@@ -383,12 +390,10 @@ Additionally, OpenGL ES 1.x cannot be returned if 2.0 or later was requested,
and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0, and vice versa. This is because OpenGL ES 3.x is backward compatible with 2.0,
but OpenGL ES 2.0 is not backward compatible with 1.x. but OpenGL ES 2.0 is not backward compatible with 1.x.
@note @macos The OS only supports forward-compatible core profile contexts for @note @macos The OS only supports core profile contexts for OpenGL versions 3.2
OpenGL versions 3.2 and later. Before creating an OpenGL context of version and later. Before creating an OpenGL context of version 3.2 or later you must
3.2 or later you must set the set the [GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hint accordingly.
[GLFW_OPENGL_FORWARD_COMPAT](@ref GLFW_OPENGL_FORWARD_COMPAT_hint) and OpenGL 3.0 and 3.1 contexts are not supported at all on macOS.
[GLFW_OPENGL_PROFILE](@ref GLFW_OPENGL_PROFILE_hint) hints accordingly. OpenGL
3.0 and 3.1 contexts are not supported at all on macOS.
@anchor GLFW_OPENGL_FORWARD_COMPAT_hint @anchor GLFW_OPENGL_FORWARD_COMPAT_hint
__GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be __GLFW_OPENGL_FORWARD_COMPAT__ specifies whether the OpenGL context should be
@@ -450,6 +455,14 @@ The no error mode for OpenGL and OpenGL ES is described in detail by the
extension. extension.
@subsubsection window_hints_win32 Windows specific window hints
@anchor GLFW_WIN32_KEYBOARD_MENU_hint
__GLFW_WIN32_KEYBOARD_MENU__ specifies whether to allow access to the window
menu via the Alt+Space and Alt-and-then-Space keyboard shortcuts. This is
ignored on other platforms.
@subsubsection window_hints_osx macOS specific window hints @subsubsection window_hints_osx macOS specific window hints
@anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint @anchor GLFW_COCOA_RETINA_FRAMEBUFFER_hint
@@ -530,6 +543,7 @@ GLFW_CONTEXT_RELEASE_BEHAVIOR | `GLFW_ANY_RELEASE_BEHAVIOR` | `GLFW_ANY_RELEASE_
GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE` GLFW_OPENGL_FORWARD_COMPAT | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
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_WIN32_KEYBOARD_MENU | `GLFW_FALSE` | `GLFW_TRUE` or `GLFW_FALSE`
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_NAME | `""` | A UTF-8 encoded frame autosave name 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`
@@ -1332,6 +1346,21 @@ unknown or the context is an OpenGL ES context. Note that the returned profile
may not match the profile bits of the context flags, as GLFW will try other may not match the profile bits of the context flags, as GLFW will try other
means of detecting the profile when no bits are set. means of detecting the profile when no bits are set.
@anchor GLFW_CONTEXT_RELEASE_BEHAVIOR_attrib
__GLFW_CONTEXT_RELEASE_BEHAVIOR__ indicates the release used by the context.
Possible values are one of `GLFW_ANY_RELEASE_BEHAVIOR`,
`GLFW_RELEASE_BEHAVIOR_FLUSH` or `GLFW_RELEASE_BEHAVIOR_NONE`. If the
behavior is `GLFW_ANY_RELEASE_BEHAVIOR`, the default behavior of the context
creation API will be used. If the behavior is `GLFW_RELEASE_BEHAVIOR_FLUSH`,
the pipeline will be flushed whenever the context is released from being the
current one. If the behavior is `GLFW_RELEASE_BEHAVIOR_NONE`, the pipeline will
not be flushed on release.
@anchor GLFW_CONTEXT_NO_ERROR_attrib
__GLFW_CONTEXT_NO_ERROR__ indicates whether errors are generated by the context.
Possible values are `GLFW_TRUE` and `GLFW_FALSE`. If enabled, situations that
would have generated errors instead cause undefined behavior.
@anchor GLFW_CONTEXT_ROBUSTNESS_attrib @anchor GLFW_CONTEXT_ROBUSTNESS_attrib
__GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the __GLFW_CONTEXT_ROBUSTNESS__ indicates the robustness strategy used by the
context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION` context. This is `GLFW_LOSE_CONTEXT_ON_RESET` or `GLFW_NO_RESET_NOTIFICATION`
@@ -1385,7 +1414,7 @@ glfwSwapBuffers(window);
Sometimes it can be useful to select when the buffer swap will occur. With the Sometimes it can be useful to select when the buffer swap will occur. With the
function @ref glfwSwapInterval it is possible to select the minimum number of function @ref glfwSwapInterval it is possible to select the minimum number of
monitor refreshes the driver wait should from the time @ref glfwSwapBuffers was monitor refreshes the driver should wait from the time @ref glfwSwapBuffers was
called before swapping the buffers: called before swapping the buffers:
@code @code
+15 -4
View File
@@ -23,6 +23,17 @@ elseif (APPLE)
MACOSX_PACKAGE_LOCATION "Resources") MACOSX_PACKAGE_LOCATION "Resources")
endif() endif()
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
set(CMAKE_C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
add_compile_options("$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
endif()
set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h" set(GLAD_GL "${GLFW_SOURCE_DIR}/deps/glad/gl.h"
"${GLFW_SOURCE_DIR}/deps/glad_gl.c") "${GLFW_SOURCE_DIR}/deps/glad_gl.c")
set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h" set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
@@ -36,8 +47,8 @@ add_executable(heightmap WIN32 MACOSX_BUNDLE heightmap.c ${ICON} ${GLAD_GL})
add_executable(offscreen offscreen.c ${ICON} ${GLAD_GL}) add_executable(offscreen offscreen.c ${ICON} ${GLAD_GL})
add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD_GL}) add_executable(particles WIN32 MACOSX_BUNDLE particles.c ${ICON} ${TINYCTHREAD} ${GETOPT} ${GLAD_GL})
add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL}) add_executable(sharing WIN32 MACOSX_BUNDLE sharing.c ${ICON} ${GLAD_GL})
add_executable(simple WIN32 MACOSX_BUNDLE simple.c ${ICON} ${GLAD_GL})
add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL}) add_executable(splitview WIN32 MACOSX_BUNDLE splitview.c ${ICON} ${GLAD_GL})
add_executable(triangle-opengl WIN32 MACOSX_BUNDLE triangle-opengl.c ${ICON} ${GLAD_GL})
add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL})
target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}") target_link_libraries(particles "${CMAKE_THREAD_LIBS_INIT}")
@@ -45,7 +56,7 @@ if (RT_LIBRARY)
target_link_libraries(particles "${RT_LIBRARY}") target_link_libraries(particles "${RT_LIBRARY}")
endif() endif()
set(WINDOWS_BINARIES boing gears heightmap particles sharing simple splitview wave) set(WINDOWS_BINARIES boing gears heightmap particles sharing splitview triangle-opengl wave)
set(CONSOLE_BINARIES offscreen) set(CONSOLE_BINARIES offscreen)
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
@@ -63,14 +74,14 @@ if (APPLE)
set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap") set_target_properties(heightmap PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Heightmap")
set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles") set_target_properties(particles PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Particles")
set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing") set_target_properties(sharing PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Sharing")
set_target_properties(simple PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Simple") set_target_properties(triangle-opengl PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "OpenGL Triangle")
set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView") set_target_properties(splitview PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "SplitView")
set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave") set_target_properties(wave PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Wave")
set_target_properties(${WINDOWS_BINARIES} PROPERTIES set_target_properties(${WINDOWS_BINARIES} PROPERTIES
RESOURCE glfw.icns RESOURCE glfw.icns
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_ICON_FILE glfw.icns MACOSX_BUNDLE_ICON_FILE glfw.icns
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
endif() endif()
+1
View File
@@ -37,6 +37,7 @@
#include <math.h> #include <math.h>
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <linmath.h> #include <linmath.h>
+1
View File
@@ -32,6 +32,7 @@
#include <string.h> #include <string.h>
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
/** /**
+1
View File
@@ -30,6 +30,7 @@
#include <stddef.h> #include <stddef.h>
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
/* Map height updates */ /* Map height updates */
+1
View File
@@ -24,6 +24,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#if USE_NATIVE_OSMESA #if USE_NATIVE_OSMESA
+4 -3
View File
@@ -40,6 +40,7 @@
#include <linmath.h> #include <linmath.h>
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
// Define tokens for GL_EXT_separate_specular_color if not already defined // Define tokens for GL_EXT_separate_specular_color if not already defined
@@ -443,7 +444,7 @@ static void draw_particles(GLFWwindow* window, double t, float dt)
} }
// Set up vertex arrays. We use interleaved arrays, which is easier to // Set up vertex arrays. We use interleaved arrays, which is easier to
// handle (in most situations) and it gives a linear memeory access // handle (in most situations) and it gives a linear memory access
// access pattern (which may give better performance in some // access pattern (which may give better performance in some
// situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords, // situations). GL_T2F_C4UB_V3F means: 2 floats for texture coords,
// 4 ubytes for color and 3 floats for vertex coord (in that order). // 4 ubytes for color and 3 floats for vertex coord (in that order).
@@ -653,7 +654,7 @@ static void draw_fountain(void)
//======================================================================== //========================================================================
// Recursive function for building variable tesselated floor // Recursive function for building variable tessellated floor
//======================================================================== //========================================================================
static void tessellate_floor(float x1, float y1, float x2, float y2, int depth) static void tessellate_floor(float x1, float y1, float x2, float y2, int depth)
@@ -720,7 +721,7 @@ static void draw_floor(void)
glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular); glMaterialfv(GL_FRONT, GL_SPECULAR, floor_specular);
glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess); glMaterialf(GL_FRONT, GL_SHININESS, floor_shininess);
// Draw floor as a bunch of triangle strips (high tesselation // Draw floor as a bunch of triangle strips (high tessellation
// improves lighting) // improves lighting)
glNormal3f(0.f, 0.f, 1.f); glNormal3f(0.f, 0.f, 1.f);
glBegin(GL_QUADS); glBegin(GL_QUADS);
+1
View File
@@ -24,6 +24,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
+2 -1
View File
@@ -3,7 +3,7 @@
// //
// The program uses a "split window" view, rendering four views of the // The program uses a "split window" view, rendering four views of the
// same scene in one window (e.g. uesful for 3D modelling software). This // same scene in one window (e.g. uesful for 3D modelling software). This
// demo uses scissors to separete the four different rendering areas from // demo uses scissors to separate the four different rendering areas from
// each other. // each other.
// //
// (If the code seems a little bit strange here and there, it may be // (If the code seems a little bit strange here and there, it may be
@@ -11,6 +11,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// Simple GLFW example // OpenGL triangle example
// Copyright (c) Camilla Löwy <elmindreda@glfw.org> // Copyright (c) Camilla Löwy <elmindreda@glfw.org>
// //
// This software is provided 'as-is', without any express or implied // This software is provided 'as-is', without any express or implied
@@ -25,30 +25,34 @@
//! [code] //! [code]
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "linmath.h" #include "linmath.h"
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
static const struct typedef struct Vertex
{ {
float x, y; vec2 pos;
float r, g, b; vec3 col;
} vertices[3] = } Vertex;
static const Vertex vertices[3] =
{ {
{ -0.6f, -0.4f, 1.f, 0.f, 0.f }, { { -0.6f, -0.4f }, { 1.f, 0.f, 0.f } },
{ 0.6f, -0.4f, 0.f, 1.f, 0.f }, { { 0.6f, -0.4f }, { 0.f, 1.f, 0.f } },
{ 0.f, 0.6f, 0.f, 0.f, 1.f } { { 0.f, 0.6f }, { 0.f, 0.f, 1.f } }
}; };
static const char* vertex_shader_text = static const char* vertex_shader_text =
"#version 110\n" "#version 330\n"
"uniform mat4 MVP;\n" "uniform mat4 MVP;\n"
"attribute vec3 vCol;\n" "in vec3 vCol;\n"
"attribute vec2 vPos;\n" "in vec2 vPos;\n"
"varying vec3 color;\n" "out vec3 color;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n" " gl_Position = MVP * vec4(vPos, 0.0, 1.0);\n"
@@ -56,11 +60,12 @@ static const char* vertex_shader_text =
"}\n"; "}\n";
static const char* fragment_shader_text = static const char* fragment_shader_text =
"#version 110\n" "#version 330\n"
"varying vec3 color;\n" "in vec3 color;\n"
"out vec4 fragment;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" gl_FragColor = vec4(color, 1.0);\n" " fragment = vec4(color, 1.0);\n"
"}\n"; "}\n";
static void error_callback(int error, const char* description) static void error_callback(int error, const char* description)
@@ -76,19 +81,16 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
int main(void) int main(void)
{ {
GLFWwindow* window;
GLuint vertex_buffer, vertex_shader, fragment_shader, program;
GLint mvp_location, vpos_location, vcol_location;
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
if (!glfwInit()) if (!glfwInit())
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL); GLFWwindow* window = glfwCreateWindow(640, 480, "OpenGL Triangle", NULL, NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();
@@ -103,53 +105,56 @@ int main(void)
// NOTE: OpenGL error checks have been omitted for brevity // NOTE: OpenGL error checks have been omitted for brevity
GLuint vertex_buffer;
glGenBuffers(1, &vertex_buffer); glGenBuffers(1, &vertex_buffer);
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
vertex_shader = glCreateShader(GL_VERTEX_SHADER); const GLuint vertex_shader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL); glShaderSource(vertex_shader, 1, &vertex_shader_text, NULL);
glCompileShader(vertex_shader); glCompileShader(vertex_shader);
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER); const GLuint fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL); glShaderSource(fragment_shader, 1, &fragment_shader_text, NULL);
glCompileShader(fragment_shader); glCompileShader(fragment_shader);
program = glCreateProgram(); const GLuint program = glCreateProgram();
glAttachShader(program, vertex_shader); glAttachShader(program, vertex_shader);
glAttachShader(program, fragment_shader); glAttachShader(program, fragment_shader);
glLinkProgram(program); glLinkProgram(program);
mvp_location = glGetUniformLocation(program, "MVP"); const GLint mvp_location = glGetUniformLocation(program, "MVP");
vpos_location = glGetAttribLocation(program, "vPos"); const GLint vpos_location = glGetAttribLocation(program, "vPos");
vcol_location = glGetAttribLocation(program, "vCol"); const GLint vcol_location = glGetAttribLocation(program, "vCol");
GLuint vertex_array;
glGenVertexArrays(1, &vertex_array);
glBindVertexArray(vertex_array);
glEnableVertexAttribArray(vpos_location); glEnableVertexAttribArray(vpos_location);
glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE, glVertexAttribPointer(vpos_location, 2, GL_FLOAT, GL_FALSE,
sizeof(vertices[0]), (void*) 0); sizeof(Vertex), (void*) offsetof(Vertex, pos));
glEnableVertexAttribArray(vcol_location); glEnableVertexAttribArray(vcol_location);
glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE, glVertexAttribPointer(vcol_location, 3, GL_FLOAT, GL_FALSE,
sizeof(vertices[0]), (void*) (sizeof(float) * 2)); sizeof(Vertex), (void*) offsetof(Vertex, col));
while (!glfwWindowShouldClose(window)) while (!glfwWindowShouldClose(window))
{ {
float ratio;
int width, height; int width, height;
mat4x4 m, p, mvp;
glfwGetFramebufferSize(window, &width, &height); glfwGetFramebufferSize(window, &width, &height);
ratio = width / (float) height; const float ratio = width / (float) height;
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
mat4x4 m, p, mvp;
mat4x4_identity(m); mat4x4_identity(m);
mat4x4_rotate_Z(m, m, (float) glfwGetTime()); mat4x4_rotate_Z(m, m, (float) glfwGetTime());
mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f); mat4x4_ortho(p, -ratio, ratio, -1.f, 1.f, 1.f, -1.f);
mat4x4_mul(mvp, p, m); mat4x4_mul(mvp, p, m);
glUseProgram(program); glUseProgram(program);
glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) mvp); glUniformMatrix4fv(mvp_location, 1, GL_FALSE, (const GLfloat*) &mvp);
glBindVertexArray(vertex_array);
glDrawArrays(GL_TRIANGLES, 0, 3); glDrawArrays(GL_TRIANGLES, 0, 3);
glfwSwapBuffers(window); glfwSwapBuffers(window);
+1
View File
@@ -18,6 +18,7 @@
#include <math.h> #include <math.h>
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <linmath.h> #include <linmath.h>
+626 -190
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
/************************************************************************* /*************************************************************************
* GLFW 3.3 - www.glfw.org * GLFW 3.4 - www.glfw.org
* A library for OpenGL, window and input * A library for OpenGL, window and input
*------------------------------------------------------------------------ *------------------------------------------------------------------------
* Copyright (c) 2002-2006 Marcus Geelnard * Copyright (c) 2002-2006 Marcus Geelnard
+23 -4
View File
@@ -95,15 +95,27 @@ endif()
add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS}) add_library(glfw ${glfw_SOURCES} ${glfw_HEADERS})
set_target_properties(glfw PROPERTIES set_target_properties(glfw PROPERTIES
OUTPUT_NAME ${GLFW_LIB_NAME} OUTPUT_NAME ${GLFW_LIB_NAME}
VERSION ${GLFW_VERSION} VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}
SOVERSION ${GLFW_VERSION_MAJOR} SOVERSION ${GLFW_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
FOLDER "GLFW3") FOLDER "GLFW3")
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
set_target_properties(glfw PROPERTIES C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
target_compile_options(glfw PRIVATE
"$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
endif()
target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H) target_compile_definitions(glfw PRIVATE _GLFW_USE_CONFIG_H)
target_include_directories(glfw PUBLIC target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>" "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>") "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(glfw PRIVATE target_include_directories(glfw PRIVATE
"${GLFW_SOURCE_DIR}/src" "${GLFW_SOURCE_DIR}/src"
"${GLFW_BINARY_DIR}/src" "${GLFW_BINARY_DIR}/src"
@@ -125,6 +137,10 @@ target_compile_options(glfw PRIVATE
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
if (WIN32) if (WIN32)
if (MINGW) if (MINGW)
# Remove the dependency on the shared version of libgcc
# NOTE: MinGW-w64 has the correct default but MinGW needs this
target_link_options(glfw PRIVATE "-static-libgcc")
# Remove the lib prefix on the DLL (but not the import library) # Remove the lib prefix on the DLL (but not the import library)
set_target_properties(glfw PROPERTIES PREFIX "") set_target_properties(glfw PROPERTIES PREFIX "")
@@ -134,18 +150,21 @@ if (BUILD_SHARED_LIBS)
# Add a suffix to the import library to avoid naming conflicts # Add a suffix to the import library to avoid naming conflicts
set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib")
endif() endif()
target_compile_definitions(glfw INTERFACE GLFW_DLL)
elseif (APPLE) elseif (APPLE)
# Add -fno-common to work around a bug in Apple's GCC # Add -fno-common to work around a bug in Apple's GCC
target_compile_options(glfw PRIVATE "-fno-common") target_compile_options(glfw PRIVATE "-fno-common")
set_target_properties(glfw PROPERTIES set_target_properties(glfw PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}") INSTALL_NAME_DIR "${CMAKE_INSTALL_LIBDIR}")
elseif (UNIX) endif()
if (UNIX)
# Hide symbols not explicitly tagged for export from the shared library # Hide symbols not explicitly tagged for export from the shared library
target_compile_options(glfw PRIVATE "-fvisibility=hidden") target_compile_options(glfw PRIVATE "-fvisibility=hidden")
endif() endif()
target_compile_definitions(glfw INTERFACE GLFW_DLL)
target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES}) target_link_libraries(glfw PRIVATE ${glfw_LIBRARIES})
else() else()
target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES}) target_link_libraries(glfw INTERFACE ${glfw_LIBRARIES})
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
#include <sys/param.h> // For MAXPATHLEN #include <sys/param.h> // For MAXPATHLEN
+2 -2
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Cocoa - www.glfw.org // GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -30,7 +30,7 @@
#include <IOKit/hid/IOHIDKeys.h> #include <IOKit/hid/IOHIDKeys.h>
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickNS ns
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyJoystick; }
#define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X" #define _GLFW_PLATFORM_MAPPING_NAME "Mac OS X"
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Cocoa - www.glfw.org // GLFW 3.4 Cocoa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net> // Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+34 -45
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -213,7 +215,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
// Finds and caches the NSScreen corresponding to the specified monitor // Finds and caches the NSScreen corresponding to the specified monitor
// //
GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor) static GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
{ {
if (monitor->ns.screen) if (monitor->ns.screen)
return GLFW_TRUE; return GLFW_TRUE;
@@ -245,18 +247,16 @@ GLFWbool refreshMonitorScreen(_GLFWmonitor* monitor)
// //
void _glfwPollMonitorsNS(void) void _glfwPollMonitorsNS(void)
{ {
uint32_t i, j, displayCount, disconnectedCount; uint32_t displayCount;
CGDirectDisplayID* displays;
_GLFWmonitor** disconnected = NULL;
CGGetOnlineDisplayList(0, NULL, &displayCount); CGGetOnlineDisplayList(0, NULL, &displayCount);
displays = calloc(displayCount, sizeof(CGDirectDisplayID)); CGDirectDisplayID* displays = calloc(displayCount, sizeof(CGDirectDisplayID));
CGGetOnlineDisplayList(displayCount, displays, &displayCount); CGGetOnlineDisplayList(displayCount, displays, &displayCount);
for (i = 0; i < _glfw.monitorCount; i++) for (int i = 0; i < _glfw.monitorCount; i++)
_glfw.monitors[i]->ns.screen = nil; _glfw.monitors[i]->ns.screen = nil;
disconnectedCount = _glfw.monitorCount; _GLFWmonitor** disconnected = NULL;
uint32_t disconnectedCount = _glfw.monitorCount;
if (disconnectedCount) if (disconnectedCount)
{ {
disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*)); disconnected = calloc(_glfw.monitorCount, sizeof(_GLFWmonitor*));
@@ -265,19 +265,17 @@ void _glfwPollMonitorsNS(void)
_glfw.monitorCount * sizeof(_GLFWmonitor*)); _glfw.monitorCount * sizeof(_GLFWmonitor*));
} }
for (i = 0; i < displayCount; i++) for (uint32_t i = 0; i < displayCount; i++)
{ {
_GLFWmonitor* monitor;
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
if (CGDisplayIsAsleep(displays[i])) if (CGDisplayIsAsleep(displays[i]))
continue; continue;
for (j = 0; j < disconnectedCount; j++)
{
// HACK: Compare unit numbers instead of display IDs to work around // HACK: Compare unit numbers instead of display IDs to work around
// display replacement on machines with automatic graphics // display replacement on machines with automatic graphics
// switching // switching
const uint32_t unitNumber = CGDisplayUnitNumber(displays[i]);
for (uint32_t j = 0; j < disconnectedCount; j++)
{
if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber) if (disconnected[j] && disconnected[j]->ns.unitNumber == unitNumber)
{ {
disconnected[j] = NULL; disconnected[j] = NULL;
@@ -290,7 +288,7 @@ void _glfwPollMonitorsNS(void)
if (!name) if (!name)
name = _glfw_strdup("Unknown"); name = _glfw_strdup("Unknown");
monitor = _glfwAllocMonitor(name, size.width, size.height); _GLFWmonitor* monitor = _glfwAllocMonitor(name, size.width, size.height);
monitor->ns.displayID = displays[i]; monitor->ns.displayID = displays[i];
monitor->ns.unitNumber = unitNumber; monitor->ns.unitNumber = unitNumber;
@@ -299,7 +297,7 @@ void _glfwPollMonitorsNS(void)
_glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST); _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
} }
for (i = 0; i < disconnectedCount; i++) for (uint32_t i = 0; i < disconnectedCount; i++)
{ {
if (disconnected[i]) if (disconnected[i])
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
@@ -313,24 +311,21 @@ void _glfwPollMonitorsNS(void)
// //
void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired) void _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{ {
CFArrayRef modes;
CFIndex count, i;
CVDisplayLinkRef link;
CGDisplayModeRef native = NULL;
GLFWvidmode current; GLFWvidmode current;
const GLFWvidmode* best;
best = _glfwChooseVideoMode(monitor, desired);
_glfwPlatformGetVideoMode(monitor, &current); _glfwPlatformGetVideoMode(monitor, &current);
const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
if (_glfwCompareVideoModes(&current, best) == 0) if (_glfwCompareVideoModes(&current, best) == 0)
return; return;
CVDisplayLinkRef link;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
count = CFArrayGetCount(modes); const CFIndex count = CFArrayGetCount(modes);
CGDisplayModeRef native = NULL;
for (i = 0; i < count; i++) for (CFIndex i = 0; i < count; i++)
{ {
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm)) if (!modeIsGood(dm))
@@ -443,26 +438,23 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
{ {
@autoreleasepool { @autoreleasepool {
CFArrayRef modes;
CFIndex found, i, j;
GLFWvidmode* result;
CVDisplayLinkRef link;
*count = 0; *count = 0;
CVDisplayLinkRef link;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL); CFArrayRef modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
found = CFArrayGetCount(modes); const CFIndex found = CFArrayGetCount(modes);
result = calloc(found, sizeof(GLFWvidmode)); GLFWvidmode* result = calloc(found, sizeof(GLFWvidmode));
for (i = 0; i < found; i++) for (CFIndex i = 0; i < found; i++)
{ {
CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); CGDisplayModeRef dm = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
if (!modeIsGood(dm)) if (!modeIsGood(dm))
continue; continue;
const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link); const GLFWvidmode mode = vidmodeFromCGDisplayMode(dm, link);
CFIndex j;
for (j = 0; j < *count; j++) for (j = 0; j < *count; j++)
{ {
@@ -489,14 +481,12 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
{ {
@autoreleasepool { @autoreleasepool {
CGDisplayModeRef displayMode;
CVDisplayLinkRef link; CVDisplayLinkRef link;
CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link); CVDisplayLinkCreateWithCGDisplay(monitor->ns.displayID, &link);
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID); CGDisplayModeRef native = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(displayMode, link); *mode = vidmodeFromCGDisplayMode(native, link);
CGDisplayModeRelease(displayMode); CGDisplayModeRelease(native);
CVDisplayLinkRelease(link); CVDisplayLinkRelease(link);
@@ -507,7 +497,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
@autoreleasepool { @autoreleasepool {
uint32_t i, size = CGDisplayGammaTableCapacity(monitor->ns.displayID); uint32_t size = CGDisplayGammaTableCapacity(monitor->ns.displayID);
CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue)); CGGammaValue* values = calloc(size * 3, sizeof(CGGammaValue));
CGGetDisplayTransferByTable(monitor->ns.displayID, CGGetDisplayTransferByTable(monitor->ns.displayID,
@@ -519,7 +509,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
_glfwAllocGammaArrays(ramp, size); _glfwAllocGammaArrays(ramp, size);
for (i = 0; i < size; i++) for (uint32_t i = 0; i < size; i++)
{ {
ramp->red[i] = (unsigned short) (values[i] * 65535); ramp->red[i] = (unsigned short) (values[i] * 65535);
ramp->green[i] = (unsigned short) (values[i + size] * 65535); ramp->green[i] = (unsigned short) (values[i + size] * 65535);
@@ -536,10 +526,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{ {
@autoreleasepool { @autoreleasepool {
int i;
CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue)); CGGammaValue* values = calloc(ramp->size * 3, sizeof(CGGammaValue));
for (i = 0; i < ramp->size; i++) for (unsigned int i = 0; i < ramp->size; i++)
{ {
values[i] = ramp->red[i] / 65535.f; values[i] = ramp->red[i] / 65535.f;
values[i + ramp->size] = ramp->green[i] / 65535.f; values[i + ramp->size] = ramp->green[i] / 65535.f;
+5 -2
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -41,6 +41,9 @@
typedef void* id; typedef void* id;
#endif #endif
// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101200 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101200
#define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat #define NSBitmapFormatAlphaNonpremultiplied NSAlphaNonpremultipliedBitmapFormat
#define NSEventMaskAny NSAnyEventMask #define NSEventMaskAny NSAnyEventMask
@@ -139,7 +142,7 @@ typedef struct _GLFWlibraryNS
id keyUpMonitor; id keyUpMonitor;
id nibObjects; id nibObjects;
char keyName[64]; char keynames[GLFW_KEY_LAST + 1][17];
short int keycodes[256]; short int keycodes[256];
short int scancodes[GLFW_KEY_LAST + 1]; short int scancodes[GLFW_KEY_LAST + 1];
char* clipboardString; char* clipboardString;
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2016 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+59 -23
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -33,15 +35,14 @@
// //
static NSUInteger getStyleMask(_GLFWwindow* window) static NSUInteger getStyleMask(_GLFWwindow* window)
{ {
NSUInteger styleMask = 0; NSUInteger styleMask = NSWindowStyleMaskMiniaturizable;
if (window->monitor || !window->decorated) if (window->monitor || !window->decorated)
styleMask |= NSWindowStyleMaskBorderless; styleMask |= NSWindowStyleMaskBorderless;
else else
{ {
styleMask |= NSWindowStyleMaskTitled | styleMask |= NSWindowStyleMaskTitled |
NSWindowStyleMaskClosable | NSWindowStyleMaskClosable;
NSWindowStyleMaskMiniaturizable;
if (window->resizable) if (window->resizable)
styleMask |= NSWindowStyleMaskResizable; styleMask |= NSWindowStyleMaskResizable;
@@ -610,10 +611,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)scrollWheel:(NSEvent *)event - (void)scrollWheel:(NSEvent *)event
{ {
double deltaX, deltaY; double deltaX = [event scrollingDeltaX];
double deltaY = [event scrollingDeltaY];
deltaX = [event scrollingDeltaX];
deltaY = [event scrollingDeltaY];
if ([event hasPreciseScrollingDeltas]) if ([event hasPreciseScrollingDeltas])
{ {
@@ -730,9 +729,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
else else
characters = (NSString*) string; characters = (NSString*) string;
NSUInteger i, length = [characters length]; const NSUInteger length = [characters length];
for (NSUInteger i = 0; i < length; i++)
for (i = 0; i < length; i++)
{ {
const unichar codepoint = [characters characterAtIndex:i]; const unichar codepoint = [characters characterAtIndex:i];
if ((codepoint & 0xff00) == 0xf700) if ((codepoint & 0xff00) == 0xf700)
@@ -817,7 +815,7 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
[window->ns.object setLevel:NSMainMenuWindowLevel + 1]; [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
else else
{ {
[window->ns.object center]; [(NSWindow*) window->ns.object center];
_glfw.ns.cascadePoint = _glfw.ns.cascadePoint =
NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint: NSPointToCGPoint([window->ns.object cascadeTopLeftFromPoint:
NSPointFromCGPoint(_glfw.ns.cascadePoint)]); NSPointFromCGPoint(_glfw.ns.cascadePoint)]);
@@ -963,6 +961,9 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
[window->ns.object close]; [window->ns.object close];
window->ns.object = nil; window->ns.object = nil;
// HACK: Allow Cocoa to catch up before returning
_glfwPlatformPollEvents();
} // autoreleasepool } // autoreleasepool
} }
@@ -1033,7 +1034,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
acquireMonitor(window); acquireMonitor(window);
} }
else else
[window->ns.object setContentSize:NSMakeSize(width, height)]; {
NSRect contentRect =
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
contentRect.origin.y += contentRect.size.height - height;
contentRect.size = NSMakeSize(width, height);
[window->ns.object setFrame:[window->ns.object frameRectForContentRect:contentRect]
display:YES];
}
} // autoreleasepool } // autoreleasepool
} }
@@ -1222,7 +1230,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
// HACK: Changing the style mask can cause the first responder to be cleared // HACK: Changing the style mask can cause the first responder to be cleared
[window->ns.object makeFirstResponder:window->ns.view]; [window->ns.object makeFirstResponder:window->ns.view];
if (monitor) if (window->monitor)
{ {
[window->ns.object setLevel:NSMainMenuWindowLevel + 1]; [window->ns.object setLevel:NSMainMenuWindowLevel + 1];
[window->ns.object setHasShadow:NO]; [window->ns.object setHasShadow:NO];
@@ -1504,8 +1512,10 @@ const char* _glfwPlatformGetScancodeName(int scancode)
{ {
@autoreleasepool { @autoreleasepool {
const int key = _glfw.ns.keycodes[scancode];
UInt32 deadKeyState = 0; UInt32 deadKeyState = 0;
UniChar characters[8]; UniChar characters[4];
UniCharCount characterCount = 0; UniCharCount characterCount = 0;
if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes], if (UCKeyTranslate([(NSData*) _glfw.ns.unicodeData bytes],
@@ -1530,12 +1540,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
characterCount, characterCount,
kCFAllocatorNull); kCFAllocatorNull);
CFStringGetCString(string, CFStringGetCString(string,
_glfw.ns.keyName, _glfw.ns.keynames[key],
sizeof(_glfw.ns.keyName), sizeof(_glfw.ns.keynames[key]),
kCFStringEncodingUTF8); kCFStringEncodingUTF8);
CFRelease(string); CFRelease(string);
return _glfw.ns.keyName; return _glfw.ns.keynames[key];
} // autoreleasepool } // autoreleasepool
} }
@@ -1593,23 +1603,49 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
@autoreleasepool { @autoreleasepool {
SEL cursorSelector = NULL;
// HACK: Try to use a private message
if (shape == GLFW_RESIZE_EW_CURSOR)
cursorSelector = @selector(_windowResizeEastWestCursor);
else if (shape == GLFW_RESIZE_NS_CURSOR)
cursorSelector = @selector(_windowResizeNorthSouthCursor);
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
cursorSelector = @selector(_windowResizeNorthWestSouthEastCursor);
else if (shape == GLFW_RESIZE_NESW_CURSOR)
cursorSelector = @selector(_windowResizeNorthEastSouthWestCursor);
if (cursorSelector && [NSCursor respondsToSelector:cursorSelector])
{
id object = [NSCursor performSelector:cursorSelector];
if ([object isKindOfClass:[NSCursor class]])
cursor->ns.object = object;
}
if (!cursor->ns.object)
{
if (shape == GLFW_ARROW_CURSOR) if (shape == GLFW_ARROW_CURSOR)
cursor->ns.object = [NSCursor arrowCursor]; cursor->ns.object = [NSCursor arrowCursor];
else if (shape == GLFW_IBEAM_CURSOR) else if (shape == GLFW_IBEAM_CURSOR)
cursor->ns.object = [NSCursor IBeamCursor]; cursor->ns.object = [NSCursor IBeamCursor];
else if (shape == GLFW_CROSSHAIR_CURSOR) else if (shape == GLFW_CROSSHAIR_CURSOR)
cursor->ns.object = [NSCursor crosshairCursor]; cursor->ns.object = [NSCursor crosshairCursor];
else if (shape == GLFW_HAND_CURSOR) else if (shape == GLFW_POINTING_HAND_CURSOR)
cursor->ns.object = [NSCursor pointingHandCursor]; cursor->ns.object = [NSCursor pointingHandCursor];
else if (shape == GLFW_HRESIZE_CURSOR) else if (shape == GLFW_RESIZE_EW_CURSOR)
cursor->ns.object = [NSCursor resizeLeftRightCursor]; cursor->ns.object = [NSCursor resizeLeftRightCursor];
else if (shape == GLFW_VRESIZE_CURSOR) else if (shape == GLFW_RESIZE_NS_CURSOR)
cursor->ns.object = [NSCursor resizeUpDownCursor]; cursor->ns.object = [NSCursor resizeUpDownCursor];
else if (shape == GLFW_RESIZE_ALL_CURSOR)
cursor->ns.object = [NSCursor closedHandCursor];
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
cursor->ns.object = [NSCursor operationNotAllowedCursor];
}
if (!cursor->ns.object) if (!cursor->ns.object)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_CURSOR_UNAVAILABLE,
"Cocoa: Failed to retrieve standard cursor"); "Cocoa: Standard cursor shape unavailable");
return GLFW_FALSE; return GLFW_FALSE;
} }
+43 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -655,6 +657,26 @@ GLFWAPI void glfwSwapBuffers(GLFWwindow* handle)
window->context.swapBuffers(window); window->context.swapBuffers(window);
} }
GLFWAPI void glfwSwapBuffersWithDamage(GLFWwindow* handle, GLFWrect* rects, int n_rects)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT();
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
"Cannot swap buffers of a window that has no OpenGL or OpenGL ES context");
return;
}
if (window->context.swapBuffersWithDamage)
window->context.swapBuffersWithDamage(window, rects, n_rects);
else
window->context.swapBuffers(window);
}
GLFWAPI void glfwSwapInterval(int interval) GLFWAPI void glfwSwapInterval(int interval)
{ {
_GLFWwindow* window; _GLFWwindow* window;
@@ -672,6 +694,26 @@ GLFWAPI void glfwSwapInterval(int interval)
window->context.swapInterval(interval); window->context.swapInterval(interval);
} }
GLFWAPI int glfwGetBufferAge(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (window->context.client == GLFW_NO_API)
{
_glfwInputError(GLFW_NO_WINDOW_CONTEXT,
"Cannot get buffer age of a window that has no OpenGL or OpenGL ES context");
return 0;
}
if (window->context.getBufferAge)
return window->context.getBufferAge(window);
return 0;
}
GLFWAPI int glfwExtensionSupported(const char* extension) GLFWAPI int glfwExtensionSupported(const char* extension)
{ {
_GLFWwindow* window; _GLFWwindow* window;
+49 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 EGL - www.glfw.org // GLFW 3.4 EGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -230,11 +232,46 @@ static void swapBuffersEGL(_GLFWwindow* window)
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface); eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
} }
static void swapBuffersWithDamageEGL(_GLFWwindow* window, GLFWrect* rects, int n_rects)
{
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: The context must be current on the calling thread when swapping buffers");
return;
}
if (eglSwapBuffersWithDamageKHR)
eglSwapBuffersWithDamageKHR(_glfw.egl.display,
window->context.egl.surface,
(EGLint*)rects, (EGLint)n_rects);
else
eglSwapBuffers(_glfw.egl.display, window->context.egl.surface);
}
static void swapIntervalEGL(int interval) static void swapIntervalEGL(int interval)
{ {
eglSwapInterval(_glfw.egl.display, interval); eglSwapInterval(_glfw.egl.display, interval);
} }
static int getBufferAgeEGL(_GLFWwindow* window)
{
EGLint buffer_age;
if (window != _glfwPlatformGetTls(&_glfw.contextSlot))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: The context must be current on the calling thread when swapping buffers");
return 0;
}
if (!eglQuerySurface(_glfw.egl.display, window->context.egl.surface,
EGL_BUFFER_AGE_EXT, &buffer_age))
return 0;
return buffer_age;
}
static int extensionSupportedEGL(const char* extension) static int extensionSupportedEGL(const char* extension)
{ {
const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS); const char* extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
@@ -365,6 +402,8 @@ GLFWbool _glfwInitEGL(void)
_glfw_dlsym(_glfw.egl.handle, "eglSwapInterval"); _glfw_dlsym(_glfw.egl.handle, "eglSwapInterval");
_glfw.egl.QueryString = (PFN_eglQueryString) _glfw.egl.QueryString = (PFN_eglQueryString)
_glfw_dlsym(_glfw.egl.handle, "eglQueryString"); _glfw_dlsym(_glfw.egl.handle, "eglQueryString");
_glfw.egl.QuerySurface = (PFN_eglQuerySurface)
_glfw_dlsym(_glfw.egl.handle, "eglQuerySurface");
_glfw.egl.GetProcAddress = (PFN_eglGetProcAddress) _glfw.egl.GetProcAddress = (PFN_eglGetProcAddress)
_glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress"); _glfw_dlsym(_glfw.egl.handle, "eglGetProcAddress");
@@ -383,6 +422,7 @@ GLFWbool _glfwInitEGL(void)
!_glfw.egl.SwapBuffers || !_glfw.egl.SwapBuffers ||
!_glfw.egl.SwapInterval || !_glfw.egl.SwapInterval ||
!_glfw.egl.QueryString || !_glfw.egl.QueryString ||
!_glfw.egl.QuerySurface ||
!_glfw.egl.GetProcAddress) !_glfw.egl.GetProcAddress)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@@ -423,6 +463,12 @@ GLFWbool _glfwInitEGL(void)
extensionSupportedEGL("EGL_KHR_get_all_proc_addresses"); extensionSupportedEGL("EGL_KHR_get_all_proc_addresses");
_glfw.egl.KHR_context_flush_control = _glfw.egl.KHR_context_flush_control =
extensionSupportedEGL("EGL_KHR_context_flush_control"); extensionSupportedEGL("EGL_KHR_context_flush_control");
_glfw.egl.KHR_swap_buffers_with_damage =
extensionSupportedEGL("EGL_KHR_swap_buffers_with_damage");
if (_glfw.egl.KHR_swap_buffers_with_damage)
_glfw.egl.SwapBuffersWithDamageKHR = (PFN_eglSwapBuffersWithDamageKHR)
_glfw.egl.GetProcAddress("eglSwapBuffersWithDamageKHR");
return GLFW_TRUE; return GLFW_TRUE;
} }
@@ -692,7 +738,9 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
window->context.makeCurrent = makeContextCurrentEGL; window->context.makeCurrent = makeContextCurrentEGL;
window->context.swapBuffers = swapBuffersEGL; window->context.swapBuffers = swapBuffersEGL;
window->context.swapBuffersWithDamage = swapBuffersWithDamageEGL;
window->context.swapInterval = swapIntervalEGL; window->context.swapInterval = swapIntervalEGL;
window->context.getBufferAge = getBufferAgeEGL;
window->context.extensionSupported = extensionSupportedEGL; window->context.extensionSupported = extensionSupportedEGL;
window->context.getProcAddress = getProcAddressEGL; window->context.getProcAddress = getProcAddressEGL;
window->context.destroy = destroyContextEGL; window->context.destroy = destroyContextEGL;
+10 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 EGL - www.glfw.org // GLFW 3.4 EGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -107,6 +107,8 @@ typedef struct wl_egl_window* EGLNativeWindowType;
#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0
#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098
#define EGL_BUFFER_AGE_EXT 0x313D
typedef int EGLint; typedef int EGLint;
typedef unsigned int EGLBoolean; typedef unsigned int EGLBoolean;
typedef unsigned int EGLenum; typedef unsigned int EGLenum;
@@ -131,7 +133,9 @@ typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLS
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglQuerySurface)(EGLDisplay,EGLSurface,EGLint,EGLint*);
typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*); typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffersWithDamageKHR)(EGLDisplay,EGLSurface,EGLint*,EGLint);
#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
#define eglGetConfigs _glfw.egl.GetConfigs #define eglGetConfigs _glfw.egl.GetConfigs
#define eglGetDisplay _glfw.egl.GetDisplay #define eglGetDisplay _glfw.egl.GetDisplay
@@ -147,7 +151,9 @@ typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
#define eglSwapBuffers _glfw.egl.SwapBuffers #define eglSwapBuffers _glfw.egl.SwapBuffers
#define eglSwapInterval _glfw.egl.SwapInterval #define eglSwapInterval _glfw.egl.SwapInterval
#define eglQueryString _glfw.egl.QueryString #define eglQueryString _glfw.egl.QueryString
#define eglQuerySurface _glfw.egl.QuerySurface
#define eglGetProcAddress _glfw.egl.GetProcAddress #define eglGetProcAddress _glfw.egl.GetProcAddress
#define eglSwapBuffersWithDamageKHR _glfw.egl.SwapBuffersWithDamageKHR
#define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl #define _GLFW_EGL_CONTEXT_STATE _GLFWcontextEGL egl
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl #define _GLFW_EGL_LIBRARY_CONTEXT_STATE _GLFWlibraryEGL egl
@@ -178,6 +184,7 @@ typedef struct _GLFWlibraryEGL
GLFWbool KHR_gl_colorspace; GLFWbool KHR_gl_colorspace;
GLFWbool KHR_get_all_proc_addresses; GLFWbool KHR_get_all_proc_addresses;
GLFWbool KHR_context_flush_control; GLFWbool KHR_context_flush_control;
GLFWbool KHR_swap_buffers_with_damage;
void* handle; void* handle;
@@ -196,7 +203,9 @@ typedef struct _GLFWlibraryEGL
PFN_eglSwapBuffers SwapBuffers; PFN_eglSwapBuffers SwapBuffers;
PFN_eglSwapInterval SwapInterval; PFN_eglSwapInterval SwapInterval;
PFN_eglQueryString QueryString; PFN_eglQueryString QueryString;
PFN_eglQuerySurface QuerySurface;
PFN_eglGetProcAddress GetProcAddress; PFN_eglGetProcAddress GetProcAddress;
PFN_eglSwapBuffersWithDamageKHR SwapBuffersWithDamageKHR;
} _GLFWlibraryEGL; } _GLFWlibraryEGL;
+1 -1
View File
@@ -5,7 +5,7 @@ libdir=@CMAKE_INSTALL_FULL_LIBDIR@
Name: GLFW Name: GLFW
Description: A multi-platform library for OpenGL, window and input Description: A multi-platform library for OpenGL, window and input
Version: @GLFW_VERSION_FULL@ Version: @GLFW_VERSION@
URL: https://www.glfw.org/ URL: https://www.glfw.org/
Requires.private: @GLFW_PKG_DEPS@ Requires.private: @GLFW_PKG_DEPS@
Libs: -L${libdir} -l@GLFW_LIB_NAME@ Libs: -L${libdir} -l@GLFW_LIB_NAME@
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2010-2016 Camilla Löwy <elmindreda@glfw.org>
// //
+3 -3
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 GLX - www.glfw.org // GLFW 3.4 GLX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -226,8 +228,6 @@ static GLFWglproc getProcAddressGLX(const char* procname)
return _glfw_dlsym(_glfw.glx.handle, procname); return _glfw_dlsym(_glfw.glx.handle, procname);
} }
// Destroy the OpenGL context
//
static void destroyContextGLX(_GLFWwindow* window) static void destroyContextGLX(_GLFWwindow* window)
{ {
if (window->context.glx.window) if (window->context.glx.window)
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 GLX - www.glfw.org // GLFW 3.4 GLX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
+5 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
#include "mappings.h" #include "mappings.h"
@@ -187,6 +189,8 @@ void _glfwInputError(int code, const char* format, ...)
strcpy(description, "The requested format is unavailable"); strcpy(description, "The requested format is unavailable");
else if (code == GLFW_NO_WINDOW_CONTEXT) else if (code == GLFW_NO_WINDOW_CONTEXT)
strcpy(description, "The specified window has no context"); strcpy(description, "The specified window has no context");
else if (code == GLFW_CURSOR_UNAVAILABLE)
strcpy(description, "The specified cursor shape is unavailable");
else else
strcpy(description, "ERROR: UNKNOWN GLFW ERROR"); strcpy(description, "ERROR: UNKNOWN GLFW ERROR");
} }
+10 -4
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -755,9 +757,13 @@ GLFWAPI GLFWcursor* glfwCreateStandardCursor(int shape)
if (shape != GLFW_ARROW_CURSOR && if (shape != GLFW_ARROW_CURSOR &&
shape != GLFW_IBEAM_CURSOR && shape != GLFW_IBEAM_CURSOR &&
shape != GLFW_CROSSHAIR_CURSOR && shape != GLFW_CROSSHAIR_CURSOR &&
shape != GLFW_HAND_CURSOR && shape != GLFW_POINTING_HAND_CURSOR &&
shape != GLFW_HRESIZE_CURSOR && shape != GLFW_RESIZE_EW_CURSOR &&
shape != GLFW_VRESIZE_CURSOR) shape != GLFW_RESIZE_NS_CURSOR &&
shape != GLFW_RESIZE_NWSE_CURSOR &&
shape != GLFW_RESIZE_NESW_CURSOR &&
shape != GLFW_RESIZE_ALL_CURSOR &&
shape != GLFW_NOT_ALLOWED_CURSOR)
{ {
_glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape); _glfwInputError(GLFW_INVALID_ENUM, "Invalid standard cursor 0x%08X", shape);
return NULL; return NULL;
+8 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -78,7 +78,9 @@ typedef struct _GLFWmutex _GLFWmutex;
typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*); typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*);
typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*); typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*);
typedef void (* _GLFWswapbufferswithdamagefun)(_GLFWwindow*,GLFWrect*,int);
typedef void (* _GLFWswapintervalfun)(int); typedef void (* _GLFWswapintervalfun)(int);
typedef int (* _GLFWgetbufferagefun)(_GLFWwindow*);
typedef int (* _GLFWextensionsupportedfun)(const char*); typedef int (* _GLFWextensionsupportedfun)(const char*);
typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*); typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*);
typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*);
@@ -274,6 +276,9 @@ struct _GLFWwndconfig
char className[256]; char className[256];
char instanceName[256]; char instanceName[256];
} x11; } x11;
struct {
GLFWbool keymenu;
} win32;
}; };
// Context configuration // Context configuration
@@ -347,7 +352,9 @@ struct _GLFWcontext
_GLFWmakecontextcurrentfun makeCurrent; _GLFWmakecontextcurrentfun makeCurrent;
_GLFWswapbuffersfun swapBuffers; _GLFWswapbuffersfun swapBuffers;
_GLFWswapbufferswithdamagefun swapBuffersWithDamage;
_GLFWswapintervalfun swapInterval; _GLFWswapintervalfun swapInterval;
_GLFWgetbufferagefun getBufferAge;
_GLFWextensionsupportedfun extensionSupported; _GLFWextensionsupportedfun extensionSupported;
_GLFWgetprocaddressfun getProcAddress; _GLFWgetprocaddressfun getProcAddress;
_GLFWdestroycontextfun destroy; _GLFWdestroycontextfun destroy;
+27 -28
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Linux - www.glfw.org // GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -104,9 +106,7 @@ static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
// //
static void pollAbsState(_GLFWjoystick* js) static void pollAbsState(_GLFWjoystick* js)
{ {
int code; for (int code = 0; code < ABS_CNT; code++)
for (code = 0; code < ABS_CNT; code++)
{ {
if (js->linjs.absMap[code] < 0) if (js->linjs.absMap[code] < 0)
continue; continue;
@@ -126,18 +126,7 @@ static void pollAbsState(_GLFWjoystick* js)
// //
static GLFWbool openJoystickDevice(const char* path) static GLFWbool openJoystickDevice(const char* path)
{ {
int jid, code; for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
char name[256] = "";
char guid[33] = "";
char evBits[(EV_CNT + 7) / 8] = {0};
char keyBits[(KEY_CNT + 7) / 8] = {0};
char absBits[(ABS_CNT + 7) / 8] = {0};
int axisCount = 0, buttonCount = 0, hatCount = 0;
struct input_id id;
_GLFWjoystickLinux linjs = {0};
_GLFWjoystick* js = NULL;
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{ {
if (!_glfw.joysticks[jid].present) if (!_glfw.joysticks[jid].present)
continue; continue;
@@ -145,10 +134,16 @@ static GLFWbool openJoystickDevice(const char* path)
return GLFW_FALSE; return GLFW_FALSE;
} }
_GLFWjoystickLinux linjs = {0};
linjs.fd = open(path, O_RDONLY | O_NONBLOCK); linjs.fd = open(path, O_RDONLY | O_NONBLOCK);
if (linjs.fd == -1) if (linjs.fd == -1)
return GLFW_FALSE; return GLFW_FALSE;
char evBits[(EV_CNT + 7) / 8] = {0};
char keyBits[(KEY_CNT + 7) / 8] = {0};
char absBits[(ABS_CNT + 7) / 8] = {0};
struct input_id id;
if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 || if (ioctl(linjs.fd, EVIOCGBIT(0, sizeof(evBits)), evBits) < 0 ||
ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 || ioctl(linjs.fd, EVIOCGBIT(EV_KEY, sizeof(keyBits)), keyBits) < 0 ||
ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 || ioctl(linjs.fd, EVIOCGBIT(EV_ABS, sizeof(absBits)), absBits) < 0 ||
@@ -168,9 +163,13 @@ static GLFWbool openJoystickDevice(const char* path)
return GLFW_FALSE; return GLFW_FALSE;
} }
char name[256] = "";
if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0) if (ioctl(linjs.fd, EVIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name)); strncpy(name, "Unknown", sizeof(name));
char guid[33] = "";
// Generate a joystick GUID that matches the SDL 2.0.5+ one // Generate a joystick GUID that matches the SDL 2.0.5+ one
if (id.vendor && id.product && id.version) if (id.vendor && id.product && id.version)
{ {
@@ -189,7 +188,9 @@ static GLFWbool openJoystickDevice(const char* path)
name[8], name[9], name[10]); name[8], name[9], name[10]);
} }
for (code = BTN_MISC; code < KEY_CNT; code++) int axisCount = 0, buttonCount = 0, hatCount = 0;
for (int code = BTN_MISC; code < KEY_CNT; code++)
{ {
if (!isBitSet(code, keyBits)) if (!isBitSet(code, keyBits))
continue; continue;
@@ -198,7 +199,7 @@ static GLFWbool openJoystickDevice(const char* path)
buttonCount++; buttonCount++;
} }
for (code = 0; code < ABS_CNT; code++) for (int code = 0; code < ABS_CNT; code++)
{ {
linjs.absMap[code] = -1; linjs.absMap[code] = -1;
if (!isBitSet(code, absBits)) if (!isBitSet(code, absBits))
@@ -221,7 +222,8 @@ static GLFWbool openJoystickDevice(const char* path)
} }
} }
js = _glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount); _GLFWjoystick* js =
_glfwAllocJoystick(name, guid, axisCount, buttonCount, hatCount);
if (!js) if (!js)
{ {
close(linjs.fd); close(linjs.fd);
@@ -266,8 +268,6 @@ static int compareJoysticks(const void* fp, const void* sp)
// //
GLFWbool _glfwInitJoysticksLinux(void) GLFWbool _glfwInitJoysticksLinux(void)
{ {
DIR* dir;
int count = 0;
const char* dirname = "/dev/input"; const char* dirname = "/dev/input";
_glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC); _glfw.linjs.inotify = inotify_init1(IN_NONBLOCK | IN_CLOEXEC);
@@ -289,7 +289,9 @@ GLFWbool _glfwInitJoysticksLinux(void)
return GLFW_FALSE; return GLFW_FALSE;
} }
dir = opendir(dirname); int count = 0;
DIR* dir = opendir(dirname);
if (dir) if (dir)
{ {
struct dirent* entry; struct dirent* entry;
@@ -344,12 +346,11 @@ void _glfwTerminateJoysticksLinux(void)
void _glfwDetectJoystickConnectionLinux(void) void _glfwDetectJoystickConnectionLinux(void)
{ {
ssize_t offset = 0;
char buffer[16384];
if (_glfw.linjs.inotify <= 0) if (_glfw.linjs.inotify <= 0)
return; return;
ssize_t offset = 0;
char buffer[16384];
const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer)); const ssize_t size = read(_glfw.linjs.inotify, buffer, sizeof(buffer));
while (size > offset) while (size > offset)
@@ -369,9 +370,7 @@ void _glfwDetectJoystickConnectionLinux(void)
openJoystickDevice(path); openJoystickDevice(path);
else if (e->mask & IN_DELETE) else if (e->mask & IN_DELETE)
{ {
int jid; for (int jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
for (jid = 0; jid <= GLFW_JOYSTICK_LAST; jid++)
{ {
if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0) if (strcmp(_glfw.joysticks[jid].linjs.path, path) == 0)
{ {
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Linux - www.glfw.org // GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
+1 -3
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -84,7 +84,6 @@ const char* _glfwDefaultMappings[] =
"030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
"030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
"78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,", "78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,platform:Windows,",
"03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,platform:Windows,",
"03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,", "03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,platform:Windows,",
"030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
"03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,", "03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,platform:Windows,",
@@ -207,7 +206,6 @@ const char* _glfwDefaultMappings[] =
"030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", "030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
"03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,", "03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,platform:Mac OS X,",
"03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,", "03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,platform:Mac OS X,",
"03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,platform:Mac OS X,",
"03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,", "03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,",
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Mac OS X,",
"030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,", "030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Mac OS X,",
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
// //
+7 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -54,6 +56,10 @@ static int compareVideoModes(const void* fp, const void* sp)
if (farea != sarea) if (farea != sarea)
return farea - sarea; return farea - sarea;
// Then sort on width
if (fm->width != sm->width)
return fm->width - sm->width;
// Lastly sort on refresh rate // Lastly sort on refresh rate
return fm->refreshRate - sm->refreshRate; return fm->refreshRate - sm->refreshRate;
} }
+4 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -24,6 +24,9 @@
// //
//======================================================================== //========================================================================
// NOTE: Many Cocoa enum values have been renamed and we need to build across
// SDK versions where one is unavailable or the other deprecated
// We use the newer names in code and these macros to handle compatibility
#if MAC_OS_X_VERSION_MAX_ALLOWED < 101400 #if MAC_OS_X_VERSION_MAX_ALLOWED < 101400
#define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval #define NSOpenGLContextParameterSwapInterval NSOpenGLCPSwapInterval
#define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity #define NSOpenGLContextParameterSurfaceOpacity NSOpenGLCPSurfaceOpacity
+5 -12
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 macOS - www.glfw.org // GLFW 3.4 macOS - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2009-2019 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -117,8 +119,6 @@ static GLFWglproc getProcAddressNSGL(const char* procname)
return symbol; return symbol;
} }
// Destroy the OpenGL context
//
static void destroyContextNSGL(_GLFWwindow* window) static void destroyContextNSGL(_GLFWwindow* window)
{ {
@autoreleasepool { @autoreleasepool {
@@ -194,13 +194,6 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
"NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above"); "NSGL: The targeted version of macOS does not support OpenGL 3.0 or 3.1 but may support 3.2 and above");
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!ctxconfig->forward || ctxconfig->profile != GLFW_OPENGL_CORE_PROFILE)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"NSGL: The targeted version of macOS only supports forward-compatible core profile contexts for OpenGL 3.2 and above");
return GLFW_FALSE;
}
} }
// Context robustness modes (GL_KHR_robustness) are not yet supported by // Context robustness modes (GL_KHR_robustness) are not yet supported by
@@ -339,7 +332,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
return GLFW_FALSE; return GLFW_FALSE;
} }
NSOpenGLContext* share = NULL; NSOpenGLContext* share = nil;
if (ctxconfig->share) if (ctxconfig->share)
share = ctxconfig->share->context.nsgl.object; share = ctxconfig->share->context.nsgl.object;
@@ -412,7 +405,7 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow* handle)
if (window->context.client == GLFW_NO_API) if (window->context.client == GLFW_NO_API)
{ {
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
return NULL; return nil;
} }
return window->context.nsgl.object; return window->context.nsgl.object;
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+3 -3
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -24,8 +24,8 @@
// //
//======================================================================== //========================================================================
#define _GLFW_PLATFORM_JOYSTICK_STATE int nulljs #define _GLFW_PLATFORM_JOYSTICK_STATE struct { int dummyJoystick; }
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int nulljs #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
#define _GLFW_PLATFORM_MAPPING_NAME "" #define _GLFW_PLATFORM_MAPPING_NAME ""
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+8 -8
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -29,13 +29,13 @@
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNull null
#define _GLFW_PLATFORM_CONTEXT_STATE #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
#define _GLFW_PLATFORM_MONITOR_STATE #define _GLFW_PLATFORM_MONITOR_STATE struct { int dummyMonitor; }
#define _GLFW_PLATFORM_CURSOR_STATE #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; }
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE struct { int dummyLibraryWindow; }
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
#define _GLFW_EGL_CONTEXT_STATE #define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; }
#define _GLFW_EGL_LIBRARY_CONTEXT_STATE #define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; }
#include "osmesa_context.h" #include "osmesa_context.h"
#include "posix_time.h" #include "posix_time.h"
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 OSMesa - www.glfw.org // GLFW 3.4 OSMesa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 OSMesa - www.glfw.org // GLFW 3.4 OSMesa - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2016 Google Inc. // Copyright (c) 2016 Google Inc.
// Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2016-2017 Camilla Löwy <elmindreda@glfw.org>
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 POSIX - www.glfw.org // GLFW 3.4 POSIX - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
+9 -10
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 WGL - www.glfw.org // GLFW 3.4 WGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -75,7 +77,7 @@ static int choosePixelFormat(_GLFWwindow* window,
{ {
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB; const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc, if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &nativeCount)) 1, 0, 1, &attrib, &nativeCount))
{ {
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR, _glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
@@ -139,7 +141,7 @@ static int choosePixelFormat(_GLFWwindow* window,
{ {
// Get pixel format attributes through "modern" extension // Get pixel format attributes through "modern" extension
if (!_glfw.wgl.GetPixelFormatAttribivARB(window->context.wgl.dc, if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
pixelFormat, 0, pixelFormat, 0,
attribCount, attribCount,
attribs, values)) attribs, values))
@@ -360,7 +362,7 @@ static void swapIntervalWGL(int interval)
} }
if (_glfw.wgl.EXT_swap_control) if (_glfw.wgl.EXT_swap_control)
_glfw.wgl.SwapIntervalEXT(interval); wglSwapIntervalEXT(interval);
} }
static int extensionSupportedWGL(const char* extension) static int extensionSupportedWGL(const char* extension)
@@ -368,9 +370,9 @@ static int extensionSupportedWGL(const char* extension)
const char* extensions = NULL; const char* extensions = NULL;
if (_glfw.wgl.GetExtensionsStringARB) if (_glfw.wgl.GetExtensionsStringARB)
extensions = _glfw.wgl.GetExtensionsStringARB(wglGetCurrentDC()); extensions = wglGetExtensionsStringARB(wglGetCurrentDC());
else if (_glfw.wgl.GetExtensionsStringEXT) else if (_glfw.wgl.GetExtensionsStringEXT)
extensions = _glfw.wgl.GetExtensionsStringEXT(); extensions = wglGetExtensionsStringEXT();
if (!extensions) if (!extensions)
return GLFW_FALSE; return GLFW_FALSE;
@@ -387,8 +389,6 @@ static GLFWglproc getProcAddressWGL(const char* procname)
return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname); return (GLFWglproc) GetProcAddress(_glfw.wgl.instance, procname);
} }
// Destroy the OpenGL context
//
static void destroyContextWGL(_GLFWwindow* window) static void destroyContextWGL(_GLFWwindow* window)
{ {
if (window->context.wgl.handle) if (window->context.wgl.handle)
@@ -693,8 +693,7 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
setAttrib(0, 0); setAttrib(0, 0);
window->context.wgl.handle = window->context.wgl.handle =
_glfw.wgl.CreateContextAttribsARB(window->context.wgl.dc, wglCreateContextAttribsARB(window->context.wgl.dc, share, attribs);
share, attribs);
if (!window->context.wgl.handle) if (!window->context.wgl.handle)
{ {
const DWORD error = GetLastError(); const DWORD error = GetLastError();
+8 -3
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 WGL - www.glfw.org // GLFW 3.4 WGL - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
@@ -76,12 +76,19 @@
#define ERROR_INVALID_PROFILE_ARB 0x2096 #define ERROR_INVALID_PROFILE_ARB 0x2096
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
// WGL extension pointer typedefs
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int); typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC)(int);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC,int,int,UINT,const int*,int*);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC)(void);
typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC); typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC);
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*); typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC,HGLRC,const int*);
#define wglSwapIntervalEXT _glfw.wgl.SwapIntervalEXT
#define wglGetPixelFormatAttribivARB _glfw.wgl.GetPixelFormatAttribivARB
#define wglGetExtensionsStringEXT _glfw.wgl.GetExtensionsStringEXT
#define wglGetExtensionsStringARB _glfw.wgl.GetExtensionsStringARB
#define wglCreateContextAttribsARB _glfw.wgl.CreateContextAttribsARB
// opengl32.dll function pointer typedefs
typedef HGLRC (WINAPI * PFN_wglCreateContext)(HDC); 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);
@@ -89,8 +96,6 @@ typedef HDC (WINAPI * PFN_wglGetCurrentDC)(void);
typedef HGLRC (WINAPI * PFN_wglGetCurrentContext)(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);
// opengl32.dll function pointer typedefs
#define wglCreateContext _glfw.wgl.CreateContext #define wglCreateContext _glfw.wgl.CreateContext
#define wglDeleteContext _glfw.wgl.DeleteContext #define wglDeleteContext _glfw.wgl.DeleteContext
#define wglGetProcAddress _glfw.wgl.GetProcAddress #define wglGetProcAddress _glfw.wgl.GetProcAddress
+5 -3
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -523,7 +525,7 @@ BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
// latter lies unless the user knew to embedd a non-default manifest // latter lies unless the user knew to embed a non-default manifest
// announcing support for Windows 10 via supportedOS GUID // announcing support for Windows 10 via supportedOS GUID
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
} }
@@ -538,7 +540,7 @@ BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_MINORVERSION, VER_GREATER_EQUAL);
cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL); cond = VerSetConditionMask(cond, VER_BUILDNUMBER, VER_GREATER_EQUAL);
// HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the // HACK: Use RtlVerifyVersionInfo instead of VerifyVersionInfoW as the
// latter lies unless the user knew to embedd a non-default manifest // latter lies unless the user knew to embed a non-default manifest
// announcing support for Windows 10 via supportedOS GUID // announcing support for Windows 10 via supportedOS GUID
return RtlVerifyVersionInfo(&osvi, mask, cond) == 0; return RtlVerifyVersionInfo(&osvi, mask, cond) == 0;
} }
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
+2 -2
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
// //
@@ -25,7 +25,7 @@
//======================================================================== //========================================================================
#define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32 #define _GLFW_PLATFORM_JOYSTICK_STATE _GLFWjoystickWin32 win32
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE int dummy #define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE struct { int dummyLibraryJoystick; }
#define _GLFW_PLATFORM_MAPPING_NAME "Windows" #define _GLFW_PLATFORM_MAPPING_NAME "Windows"
+11 -9
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -475,7 +477,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
HDC dc; HDC dc;
WORD values[768]; WORD values[3][256];
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
GetDeviceGammaRamp(dc, values); GetDeviceGammaRamp(dc, values);
@@ -483,9 +485,9 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
_glfwAllocGammaArrays(ramp, 256); _glfwAllocGammaArrays(ramp, 256);
memcpy(ramp->red, values + 0, 256 * sizeof(unsigned short)); memcpy(ramp->red, values[0], sizeof(values[0]));
memcpy(ramp->green, values + 256, 256 * sizeof(unsigned short)); memcpy(ramp->green, values[1], sizeof(values[1]));
memcpy(ramp->blue, values + 512, 256 * sizeof(unsigned short)); memcpy(ramp->blue, values[2], sizeof(values[2]));
return GLFW_TRUE; return GLFW_TRUE;
} }
@@ -493,7 +495,7 @@ GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp) void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
{ {
HDC dc; HDC dc;
WORD values[768]; WORD values[3][256];
if (ramp->size != 256) if (ramp->size != 256)
{ {
@@ -502,9 +504,9 @@ void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp)
return; return;
} }
memcpy(values + 0, ramp->red, 256 * sizeof(unsigned short)); memcpy(values[0], ramp->red, sizeof(values[0]));
memcpy(values + 256, ramp->green, 256 * sizeof(unsigned short)); memcpy(values[1], ramp->green, sizeof(values[1]));
memcpy(values + 512, ramp->blue, 256 * sizeof(unsigned short)); memcpy(values[2], ramp->blue, sizeof(values[2]));
dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL); dc = CreateDCW(L"DISPLAY", monitor->win32.adapterName, NULL, NULL);
SetDeviceGammaRamp(dc, values); SetDeviceGammaRamp(dc, values);
+2 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -315,6 +315,7 @@ typedef struct _GLFWwindowWin32
// Whether to enable framebuffer transparency on DWM // Whether to enable framebuffer transparency on DWM
GLFWbool transparent; GLFWbool transparent;
GLFWbool scaleToMonitor; GLFWbool scaleToMonitor;
GLFWbool keymenu;
// The last received cursor position, regardless of source // The last received cursor position, regardless of source
int lastCursorPosX, lastCursorPosY; int lastCursorPosX, lastCursorPosY;
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
+65 -38
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Win32 - www.glfw.org // GLFW 3.4 Win32 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -409,7 +411,7 @@ static void updateFramebufferTransparency(const _GLFWwindow* window)
// issue. When set to black, something is making the hit test // issue. When set to black, something is making the hit test
// not resize with the window frame. // not resize with the window frame.
SetLayeredWindowAttributes(window->win32.handle, SetLayeredWindowAttributes(window->win32.handle,
RGB(0, 193, 48), 255, LWA_COLORKEY); RGB(255, 0, 255), 255, LWA_COLORKEY);
} }
DeleteObject(region); DeleteObject(region);
@@ -479,7 +481,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
DWORD time; DWORD time;
// Right side keys have the extended key bit set // Right side keys have the extended key bit set
if (lParam & 0x01000000) if (HIWORD(lParam) & KF_EXTENDED)
return GLFW_KEY_RIGHT_CONTROL; return GLFW_KEY_RIGHT_CONTROL;
// HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence // HACK: Alt Gr sends Left Ctrl and then Right Alt in close sequence
@@ -495,7 +497,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam)
next.message == WM_SYSKEYUP) next.message == WM_SYSKEYUP)
{ {
if (next.wParam == VK_MENU && if (next.wParam == VK_MENU &&
(next.lParam & 0x01000000) && (HIWORD(next.lParam) & KF_EXTENDED) &&
next.time == time) next.time == time)
{ {
// Next message is Right Alt down so discard this // Next message is Right Alt down so discard this
@@ -629,13 +631,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// clicking a caption button // clicking a caption button
if (HIWORD(lParam) == WM_LBUTTONDOWN) if (HIWORD(lParam) == WM_LBUTTONDOWN)
{ {
if (LOWORD(lParam) == HTCLOSE || if (LOWORD(lParam) != HTCLIENT)
LOWORD(lParam) == HTMINBUTTON ||
LOWORD(lParam) == HTMAXBUTTON)
{
window->win32.frameAction = GLFW_TRUE; window->win32.frameAction = GLFW_TRUE;
} }
}
break; break;
} }
@@ -701,7 +699,12 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// User trying to access application menu using ALT? // User trying to access application menu using ALT?
case SC_KEYMENU: case SC_KEYMENU:
{
if (!window->win32.keymenu)
return 0; return 0;
break;
}
} }
break; break;
} }
@@ -733,6 +736,10 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
} }
_glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain); _glfwInputChar(window, (unsigned int) wParam, getKeyMods(), plain);
if (uMsg == WM_SYSCHAR && window->win32.keymenu)
break;
return 0; return 0;
} }
@@ -742,8 +749,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_SYSKEYUP: case WM_SYSKEYUP:
{ {
const int key = translateKey(wParam, lParam); const int key = translateKey(wParam, lParam);
const int scancode = (lParam >> 16) & 0x1ff; const int scancode = (HIWORD(lParam) & 0x1ff);
const int action = ((lParam >> 31) & 1) ? GLFW_RELEASE : GLFW_PRESS; const int action = (HIWORD(lParam) & KF_UP) ? GLFW_RELEASE : GLFW_PRESS;
const int mods = getKeyMods(); const int mods = getKeyMods();
if (key == _GLFW_KEY_INVALID) if (key == _GLFW_KEY_INVALID)
@@ -830,7 +837,19 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
const int x = GET_X_LPARAM(lParam); const int x = GET_X_LPARAM(lParam);
const int y = GET_Y_LPARAM(lParam); const int y = GET_Y_LPARAM(lParam);
// Disabled cursor motion input is provided by WM_INPUT if (!window->win32.cursorTracked)
{
TRACKMOUSEEVENT tme;
ZeroMemory(&tme, sizeof(tme));
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->win32.handle;
TrackMouseEvent(&tme);
window->win32.cursorTracked = GLFW_TRUE;
_glfwInputCursorEnter(window, GLFW_TRUE);
}
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
{ {
const int dx = x - window->win32.lastCursorPosX; const int dx = x - window->win32.lastCursorPosX;
@@ -851,19 +870,6 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
window->win32.lastCursorPosX = x; window->win32.lastCursorPosX = x;
window->win32.lastCursorPosY = y; window->win32.lastCursorPosY = y;
if (!window->win32.cursorTracked)
{
TRACKMOUSEEVENT tme;
ZeroMemory(&tme, sizeof(tme));
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->win32.handle;
TrackMouseEvent(&tme);
window->win32.cursorTracked = GLFW_TRUE;
_glfwInputCursorEnter(window, GLFW_TRUE);
}
return 0; return 0;
} }
@@ -942,6 +948,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_ENTERSIZEMOVE: case WM_ENTERSIZEMOVE:
case WM_ENTERMENULOOP: case WM_ENTERMENULOOP:
{ {
if (window->win32.frameAction)
break;
// HACK: Enable the cursor while the user is moving or // HACK: Enable the cursor while the user is moving or
// resizing the window or using the window menu // resizing the window or using the window menu
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
@@ -953,6 +962,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_EXITSIZEMOVE: case WM_EXITSIZEMOVE:
case WM_EXITMENULOOP: case WM_EXITMENULOOP:
{ {
if (window->win32.frameAction)
break;
// HACK: Disable the cursor once the user is done moving or // HACK: Disable the cursor once the user is done moving or
// resizing the window or using the menu // resizing the window or using the menu
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
@@ -1225,6 +1237,7 @@ static int createNativeWindow(_GLFWwindow* window,
xpos = CW_USEDEFAULT; xpos = CW_USEDEFAULT;
ypos = CW_USEDEFAULT; ypos = CW_USEDEFAULT;
window->win32.maximized = wndconfig->maximized;
if (wndconfig->maximized) if (wndconfig->maximized)
style |= WS_MAXIMIZE; style |= WS_MAXIMIZE;
@@ -1271,13 +1284,15 @@ static int createNativeWindow(_GLFWwindow* window,
} }
window->win32.scaleToMonitor = wndconfig->scaleToMonitor; window->win32.scaleToMonitor = wndconfig->scaleToMonitor;
window->win32.keymenu = wndconfig->win32.keymenu;
// Adjust window size to account for DPI scaling of the window frame and // Adjust window rect to account for DPI scaling of the window frame and
// optionally DPI scaling of the content area // (if enabled) DPI scaling of the content area
// This cannot be done until we know what monitor it was placed on // This cannot be done until we know what monitor the window was placed on
if (!window->monitor) if (!window->monitor)
{ {
RECT rect = { 0, 0, wndconfig->width, wndconfig->height }; RECT rect = { 0, 0, wndconfig->width, wndconfig->height };
WINDOWPLACEMENT wp = { sizeof(wp) };
if (wndconfig->scaleToMonitor) if (wndconfig->scaleToMonitor)
{ {
@@ -1298,10 +1313,11 @@ static int createNativeWindow(_GLFWwindow* window,
else else
AdjustWindowRectEx(&rect, style, FALSE, exStyle); AdjustWindowRectEx(&rect, style, FALSE, exStyle);
SetWindowPos(window->win32.handle, NULL, // Only update the restored window rect as the window may be maximized
rect.left, rect.top, GetWindowPlacement(window->win32.handle, &wp);
rect.right - rect.left, rect.bottom - rect.top, wp.rcNormalPosition = rect;
SWP_NOACTIVATE | SWP_NOZORDER); wp.showCmd = SW_HIDE;
SetWindowPlacement(window->win32.handle, &wp);
} }
DragAcceptFiles(window->win32.handle, TRUE); DragAcceptFiles(window->win32.handle, TRUE);
@@ -1722,7 +1738,7 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
_glfwInputWindowMonitor(window, monitor); _glfwInputWindowMonitor(window, monitor);
if (monitor) if (window->monitor)
{ {
MONITORINFO mi = { sizeof(mi) }; MONITORINFO mi = { sizeof(mi) };
UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS; UINT flags = SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOCOPYBITS;
@@ -1928,8 +1944,8 @@ void _glfwPlatformPollEvents(void)
window = GetPropW(handle, L"GLFW"); window = GetPropW(handle, L"GLFW");
if (window) if (window)
{ {
const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1; const GLFWbool lshift = (GetAsyncKeyState(VK_LSHIFT) & 0x8000) != 0;
const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1; const GLFWbool rshift = (GetAsyncKeyState(VK_RSHIFT) & 0x8000) != 0;
if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS) if (!lshift && window->keys[GLFW_KEY_LEFT_SHIFT] == GLFW_PRESS)
{ {
@@ -2052,14 +2068,25 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
id = OCR_IBEAM; id = OCR_IBEAM;
else if (shape == GLFW_CROSSHAIR_CURSOR) else if (shape == GLFW_CROSSHAIR_CURSOR)
id = OCR_CROSS; id = OCR_CROSS;
else if (shape == GLFW_HAND_CURSOR) else if (shape == GLFW_POINTING_HAND_CURSOR)
id = OCR_HAND; id = OCR_HAND;
else if (shape == GLFW_HRESIZE_CURSOR) else if (shape == GLFW_RESIZE_EW_CURSOR)
id = OCR_SIZEWE; id = OCR_SIZEWE;
else if (shape == GLFW_VRESIZE_CURSOR) else if (shape == GLFW_RESIZE_NS_CURSOR)
id = OCR_SIZENS; id = OCR_SIZENS;
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
id = OCR_SIZENWSE;
else if (shape == GLFW_RESIZE_NESW_CURSOR)
id = OCR_SIZENESW;
else if (shape == GLFW_RESIZE_ALL_CURSOR)
id = OCR_SIZEALL;
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
id = OCR_NO;
else else
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Unknown standard cursor");
return GLFW_FALSE; return GLFW_FALSE;
}
cursor->win32.handle = LoadImageW(NULL, cursor->win32.handle = LoadImageW(NULL,
MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0, MAKEINTRESOURCEW(id), IMAGE_CURSOR, 0, 0,
+6 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 - www.glfw.org // GLFW 3.4 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -25,6 +25,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h" #include "internal.h"
@@ -361,6 +363,9 @@ 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_WIN32_KEYBOARD_MENU:
_glfw.hints.window.win32.keymenu = 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;
+35 -42
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Wayland - www.glfw.org // GLFW 3.4 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -167,6 +169,7 @@ static void setCursor(_GLFWwindow* window, const char* name)
wl_surface_damage(surface, 0, 0, wl_surface_damage(surface, 0, 0,
image->width, image->height); image->width, image->height);
wl_surface_commit(surface); wl_surface_commit(surface);
_glfw.wl.cursorPreviousName = name;
} }
static void pointerHandleMotion(void* data, static void pointerHandleMotion(void* data,
@@ -176,48 +179,46 @@ static void pointerHandleMotion(void* data,
wl_fixed_t sy) wl_fixed_t sy)
{ {
_GLFWwindow* window = _glfw.wl.pointerFocus; _GLFWwindow* window = _glfw.wl.pointerFocus;
const char* cursorName; const char* cursorName = NULL;
double x, y;
if (!window) if (!window)
return; return;
if (window->cursorMode == GLFW_CURSOR_DISABLED) if (window->cursorMode == GLFW_CURSOR_DISABLED)
return; return;
else x = wl_fixed_to_double(sx);
{ y = wl_fixed_to_double(sy);
window->wl.cursorPosX = wl_fixed_to_double(sx);
window->wl.cursorPosY = wl_fixed_to_double(sy);
}
switch (window->wl.decorations.focus) switch (window->wl.decorations.focus)
{ {
case mainWindow: case mainWindow:
_glfwInputCursorPos(window, window->wl.cursorPosX = x;
wl_fixed_to_double(sx), window->wl.cursorPosY = y;
wl_fixed_to_double(sy)); _glfwInputCursorPos(window, x, y);
return; return;
case topDecoration: case topDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (y < _GLFW_DECORATION_WIDTH)
cursorName = "n-resize"; cursorName = "n-resize";
else else
cursorName = "left_ptr"; cursorName = "left_ptr";
break; break;
case leftDecoration: case leftDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (y < _GLFW_DECORATION_WIDTH)
cursorName = "nw-resize"; cursorName = "nw-resize";
else else
cursorName = "w-resize"; cursorName = "w-resize";
break; break;
case rightDecoration: case rightDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (y < _GLFW_DECORATION_WIDTH)
cursorName = "ne-resize"; cursorName = "ne-resize";
else else
cursorName = "e-resize"; cursorName = "e-resize";
break; break;
case bottomDecoration: case bottomDecoration:
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) if (x < _GLFW_DECORATION_WIDTH)
cursorName = "sw-resize"; cursorName = "sw-resize";
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) else if (x > window->wl.width + _GLFW_DECORATION_WIDTH)
cursorName = "se-resize"; cursorName = "se-resize";
else else
cursorName = "s-resize"; cursorName = "s-resize";
@@ -225,6 +226,7 @@ static void pointerHandleMotion(void* data,
default: default:
assert(0); assert(0);
} }
if (_glfw.wl.cursorPreviousName != cursorName)
setCursor(window, cursorName); setCursor(window, cursorName);
} }
@@ -237,9 +239,7 @@ static void pointerHandleButton(void* data,
{ {
_GLFWwindow* window = _glfw.wl.pointerFocus; _GLFWwindow* window = _glfw.wl.pointerFocus;
int glfwButton; int glfwButton;
uint32_t edges = XDG_TOPLEVEL_RESIZE_EDGE_NONE;
// Both xdg-shell and wl_shell use the same values.
uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE;
if (!window) if (!window)
return; return;
@@ -251,46 +251,39 @@ static void pointerHandleButton(void* data,
break; break;
case topDecoration: case topDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
edges = WL_SHELL_SURFACE_RESIZE_TOP; edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP;
else else
{ {
if (window->wl.xdg.toplevel)
xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial); xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
else
wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
} }
break; break;
case leftDecoration: case leftDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT; edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT;
else else
edges = WL_SHELL_SURFACE_RESIZE_LEFT; edges = XDG_TOPLEVEL_RESIZE_EDGE_LEFT;
break; break;
case rightDecoration: case rightDecoration:
if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH) if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT; edges = XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT;
else else
edges = WL_SHELL_SURFACE_RESIZE_RIGHT; edges = XDG_TOPLEVEL_RESIZE_EDGE_RIGHT;
break; break;
case bottomDecoration: case bottomDecoration:
if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH) if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT; edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT;
else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH) else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT; edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT;
else else
edges = WL_SHELL_SURFACE_RESIZE_BOTTOM; edges = XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM;
break; break;
default: default:
assert(0); assert(0);
} }
if (edges != WL_SHELL_SURFACE_RESIZE_NONE) if (edges != XDG_TOPLEVEL_RESIZE_EDGE_NONE)
{ {
if (window->wl.xdg.toplevel)
xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat, xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
serial, edges); serial, edges);
else
wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
serial, edges);
} }
} }
else if (button == BTN_RIGHT) else if (button == BTN_RIGHT)
@@ -790,7 +783,7 @@ static void registryHandleGlobal(void* data,
{ {
if (strcmp(interface, "wl_compositor") == 0) if (strcmp(interface, "wl_compositor") == 0)
{ {
_glfw.wl.compositorVersion = min(3, version); _glfw.wl.compositorVersion = min(4, version);
_glfw.wl.compositor = _glfw.wl.compositor =
wl_registry_bind(registry, name, &wl_compositor_interface, wl_registry_bind(registry, name, &wl_compositor_interface,
_glfw.wl.compositorVersion); _glfw.wl.compositorVersion);
@@ -805,11 +798,6 @@ static void registryHandleGlobal(void* data,
_glfw.wl.shm = _glfw.wl.shm =
wl_registry_bind(registry, name, &wl_shm_interface, 1); wl_registry_bind(registry, name, &wl_shm_interface, 1);
} }
else if (strcmp(interface, "wl_shell") == 0)
{
_glfw.wl.shell =
wl_registry_bind(registry, name, &wl_shell_interface, 1);
}
else if (strcmp(interface, "wl_output") == 0) else if (strcmp(interface, "wl_output") == 0)
{ {
_glfwAddOutputWayland(name, version); _glfwAddOutputWayland(name, version);
@@ -1164,6 +1152,13 @@ int _glfwPlatformInit(void)
if (_glfw.wl.seatVersion >= 4) if (_glfw.wl.seatVersion >= 4)
_glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
if (!_glfw.wl.wmBase)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to find xdg-shell in your compositor");
return GLFW_FALSE;
}
if (_glfw.wl.pointer && _glfw.wl.shm) if (_glfw.wl.pointer && _glfw.wl.shm)
{ {
cursorTheme = getenv("XCURSOR_THEME"); cursorTheme = getenv("XCURSOR_THEME");
@@ -1257,8 +1252,6 @@ void _glfwPlatformTerminate(void)
wl_compositor_destroy(_glfw.wl.compositor); wl_compositor_destroy(_glfw.wl.compositor);
if (_glfw.wl.shm) if (_glfw.wl.shm)
wl_shm_destroy(_glfw.wl.shm); wl_shm_destroy(_glfw.wl.shm);
if (_glfw.wl.shell)
wl_shell_destroy(_glfw.wl.shell);
if (_glfw.wl.viewporter) if (_glfw.wl.viewporter)
wp_viewporter_destroy(_glfw.wl.viewporter); wp_viewporter_destroy(_glfw.wl.viewporter);
if (_glfw.wl.decorationManager) if (_glfw.wl.decorationManager)
+4 -2
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Wayland - www.glfw.org // GLFW 3.4 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -198,7 +200,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp) GLFWbool _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Gamma ramp access it not available"); "Wayland: Gamma ramp access is not available");
return GLFW_FALSE; return GLFW_FALSE;
} }
+5 -6
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Wayland - www.glfw.org // GLFW 3.4 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@@ -75,8 +75,8 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
#define _GLFW_PLATFORM_CONTEXT_STATE #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
struct wl_cursor_image { struct wl_cursor_image {
uint32_t width; uint32_t width;
@@ -180,7 +180,6 @@ typedef struct _GLFWwindowWayland
GLFWbool transparent; GLFWbool transparent;
struct wl_surface* surface; struct wl_surface* surface;
struct wl_egl_window* native; struct wl_egl_window* native;
struct wl_shell_surface* shellSurface;
struct wl_callback* callback; struct wl_callback* callback;
struct { struct {
@@ -227,7 +226,6 @@ typedef struct _GLFWlibraryWayland
struct wl_registry* registry; struct wl_registry* registry;
struct wl_compositor* compositor; struct wl_compositor* compositor;
struct wl_subcompositor* subcompositor; struct wl_subcompositor* subcompositor;
struct wl_shell* shell;
struct wl_shm* shm; struct wl_shm* shm;
struct wl_seat* seat; struct wl_seat* seat;
struct wl_pointer* pointer; struct wl_pointer* pointer;
@@ -249,6 +247,7 @@ typedef struct _GLFWlibraryWayland
struct wl_cursor_theme* cursorTheme; struct wl_cursor_theme* cursorTheme;
struct wl_cursor_theme* cursorThemeHiDPI; struct wl_cursor_theme* cursorThemeHiDPI;
struct wl_surface* cursorSurface; struct wl_surface* cursorSurface;
const char* cursorPreviousName;
int cursorTimerfd; int cursorTimerfd;
uint32_t serial; uint32_t serial;
@@ -332,7 +331,7 @@ typedef struct _GLFWlibraryWayland
typedef struct _GLFWmonitorWayland typedef struct _GLFWmonitorWayland
{ {
struct wl_output* output; struct wl_output* output;
int name; uint32_t name;
int currentMode; int currentMode;
int x; int x;
+76 -214
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Wayland - www.glfw.org // GLFW 3.4 Wayland - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
@@ -23,6 +23,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#define _GNU_SOURCE #define _GNU_SOURCE
@@ -39,72 +41,6 @@
#include <poll.h> #include <poll.h>
static void shellSurfaceHandlePing(void* data,
struct wl_shell_surface* shellSurface,
uint32_t serial)
{
wl_shell_surface_pong(shellSurface, serial);
}
static void shellSurfaceHandleConfigure(void* data,
struct wl_shell_surface* shellSurface,
uint32_t edges,
int32_t width,
int32_t height)
{
_GLFWwindow* window = data;
float aspectRatio;
float targetRatio;
if (!window->monitor)
{
if (_glfw.wl.viewporter && window->decorated)
{
width -= _GLFW_DECORATION_HORIZONTAL;
height -= _GLFW_DECORATION_VERTICAL;
}
if (width < 1)
width = 1;
if (height < 1)
height = 1;
if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
{
aspectRatio = (float)width / (float)height;
targetRatio = (float)window->numer / (float)window->denom;
if (aspectRatio < targetRatio)
height = width / targetRatio;
else if (aspectRatio > targetRatio)
width = height * targetRatio;
}
if (window->minwidth != GLFW_DONT_CARE && width < window->minwidth)
width = window->minwidth;
else if (window->maxwidth != GLFW_DONT_CARE && width > window->maxwidth)
width = window->maxwidth;
if (window->minheight != GLFW_DONT_CARE && height < window->minheight)
height = window->minheight;
else if (window->maxheight != GLFW_DONT_CARE && height > window->maxheight)
height = window->maxheight;
}
_glfwInputWindowSize(window, width, height);
_glfwPlatformSetWindowSize(window, width, height);
_glfwInputWindowDamage(window);
}
static void shellSurfaceHandlePopupDone(void* data,
struct wl_shell_surface* shellSurface)
{
}
static const struct wl_shell_surface_listener shellSurfaceListener = {
shellSurfaceHandlePing,
shellSurfaceHandleConfigure,
shellSurfaceHandlePopupDone
};
static int createTmpfileCloexec(char* tmpname) static int createTmpfileCloexec(char* tmpname)
{ {
int fd; int fd;
@@ -132,7 +68,7 @@ static int createTmpfileCloexec(char* tmpname)
* SCM_RIGHTS methods. * SCM_RIGHTS methods.
* *
* posix_fallocate() is used to guarantee that disk space is available * posix_fallocate() is used to guarantee that disk space is available
* for the file at the given size. If disk space is insufficent, errno * for the file at the given size. If disk space is insufficient, errno
* is set to ENOSPC. If posix_fallocate() is not supported, program may * is set to ENOSPC. If posix_fallocate() is not supported, program may
* receive SIGBUS on accessing mmap()'ed file contents instead. * receive SIGBUS on accessing mmap()'ed file contents instead.
*/ */
@@ -529,66 +465,11 @@ static void setFullscreen(_GLFWwindow* window, _GLFWmonitor* monitor,
window->wl.xdg.toplevel, window->wl.xdg.toplevel,
monitor->wl.output); monitor->wl.output);
} }
else if (window->wl.shellSurface)
{
wl_shell_surface_set_fullscreen(
window->wl.shellSurface,
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
refreshRate * 1000, // Convert Hz to mHz.
monitor->wl.output);
}
setIdleInhibitor(window, GLFW_TRUE); setIdleInhibitor(window, GLFW_TRUE);
if (!window->wl.decorations.serverSide) if (!window->wl.decorations.serverSide)
destroyDecorations(window); destroyDecorations(window);
} }
static GLFWbool createShellSurface(_GLFWwindow* window)
{
if (!_glfw.wl.shell)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: wl_shell protocol not available");
return GLFW_FALSE;
}
window->wl.shellSurface = wl_shell_get_shell_surface(_glfw.wl.shell,
window->wl.surface);
if (!window->wl.shellSurface)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Shell surface creation failed");
return GLFW_FALSE;
}
wl_shell_surface_add_listener(window->wl.shellSurface,
&shellSurfaceListener,
window);
if (window->wl.title)
wl_shell_surface_set_title(window->wl.shellSurface, window->wl.title);
if (window->monitor)
{
setFullscreen(window, window->monitor, 0);
}
else if (window->wl.maximized)
{
wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
setIdleInhibitor(window, GLFW_FALSE);
createDecorations(window);
}
else
{
wl_shell_surface_set_toplevel(window->wl.shellSurface);
setIdleInhibitor(window, GLFW_FALSE);
createDecorations(window);
}
wl_surface_commit(window->wl.surface);
return GLFW_TRUE;
}
static void xdgToplevelHandleConfigure(void* data, static void xdgToplevelHandleConfigure(void* data,
struct xdg_toplevel* toplevel, struct xdg_toplevel* toplevel,
int32_t width, int32_t width,
@@ -889,28 +770,6 @@ static void handleEvents(int timeout)
} }
} }
// Translates a GLFW standard cursor to a theme cursor name
//
static char *translateCursorShape(int shape)
{
switch (shape)
{
case GLFW_ARROW_CURSOR:
return "left_ptr";
case GLFW_IBEAM_CURSOR:
return "xterm";
case GLFW_CROSSHAIR_CURSOR:
return "crosshair";
case GLFW_HAND_CURSOR:
return "grabbing";
case GLFW_HRESIZE_CURSOR:
return "sb_h_double_arrow";
case GLFW_VRESIZE_CURSOR:
return "sb_v_double_arrow";
}
return NULL;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW platform API ////// ////// GLFW platform API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@@ -948,17 +807,9 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
window->wl.title = _glfw_strdup(wndconfig->title); window->wl.title = _glfw_strdup(wndconfig->title);
if (wndconfig->visible) if (wndconfig->visible)
{
if (_glfw.wl.wmBase)
{ {
if (!createXdgSurface(window)) if (!createXdgSurface(window))
return GLFW_FALSE; return GLFW_FALSE;
}
else
{
if (!createShellSurface(window))
return GLFW_FALSE;
}
window->wl.visible = GLFW_TRUE; window->wl.visible = GLFW_TRUE;
} }
@@ -966,7 +817,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
{ {
window->wl.xdg.surface = NULL; window->wl.xdg.surface = NULL;
window->wl.xdg.toplevel = NULL; window->wl.xdg.toplevel = NULL;
window->wl.shellSurface = NULL;
window->wl.visible = GLFW_FALSE; window->wl.visible = GLFW_FALSE;
} }
@@ -1008,9 +858,6 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->wl.native) if (window->wl.native)
wl_egl_window_destroy(window->wl.native); wl_egl_window_destroy(window->wl.native);
if (window->wl.shellSurface)
wl_shell_surface_destroy(window->wl.shellSurface);
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
xdg_toplevel_destroy(window->wl.xdg.toplevel); xdg_toplevel_destroy(window->wl.xdg.toplevel);
@@ -1031,8 +878,6 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
window->wl.title = _glfw_strdup(title); window->wl.title = _glfw_strdup(title);
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
xdg_toplevel_set_title(window->wl.xdg.toplevel, title); xdg_toplevel_set_title(window->wl.xdg.toplevel, title);
else if (window->wl.shellSurface)
wl_shell_surface_set_title(window->wl.shellSurface, title);
} }
void _glfwPlatformSetWindowIcon(_GLFWwindow* window, void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
@@ -1077,8 +922,6 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
int minwidth, int minheight, int minwidth, int minheight,
int maxwidth, int maxheight) int maxwidth, int maxheight)
{
if (_glfw.wl.wmBase)
{ {
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
{ {
@@ -1091,18 +934,12 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
wl_surface_commit(window->wl.surface); wl_surface_commit(window->wl.surface);
} }
} }
else
{
// TODO: find out how to trigger a resize.
// The actual limits are checked in the wl_shell_surface::configure handler.
}
}
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window,
int numer, int denom) int numer, int denom)
{ {
// TODO: find out how to trigger a resize. // TODO: find out how to trigger a resize.
// The actual limits are checked in the wl_shell_surface::configure handler. // The actual limits are checked in the xdg_toplevel::configure handler.
} }
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, void _glfwPlatformGetFramebufferSize(_GLFWwindow* window,
@@ -1140,18 +977,10 @@ void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
} }
void _glfwPlatformIconifyWindow(_GLFWwindow* window) void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (_glfw.wl.wmBase)
{ {
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
xdg_toplevel_set_minimized(window->wl.xdg.toplevel); xdg_toplevel_set_minimized(window->wl.xdg.toplevel);
} }
else
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Iconify window not supported on wl_shell");
}
}
void _glfwPlatformRestoreWindow(_GLFWwindow* window) void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{ {
@@ -1162,12 +991,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
if (window->wl.maximized) if (window->wl.maximized)
xdg_toplevel_unset_maximized(window->wl.xdg.toplevel); xdg_toplevel_unset_maximized(window->wl.xdg.toplevel);
// There is no way to unset minimized, or even to know if we are // There is no way to unset minimized, or even to know if we are
// minimized, so there is nothing to do here. // minimized, so there is nothing to do in this case.
}
else if (window->wl.shellSurface)
{
if (window->monitor || window->wl.maximized)
wl_shell_surface_set_toplevel(window->wl.shellSurface);
} }
_glfwInputWindowMonitor(window, NULL); _glfwInputWindowMonitor(window, NULL);
window->wl.maximized = GLFW_FALSE; window->wl.maximized = GLFW_FALSE;
@@ -1179,11 +1003,6 @@ void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
{ {
xdg_toplevel_set_maximized(window->wl.xdg.toplevel); xdg_toplevel_set_maximized(window->wl.xdg.toplevel);
} }
else if (window->wl.shellSurface)
{
// Let the compositor select the best output.
wl_shell_surface_set_maximized(window->wl.shellSurface, NULL);
}
window->wl.maximized = GLFW_TRUE; window->wl.maximized = GLFW_TRUE;
} }
@@ -1191,10 +1010,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
{ {
if (!window->wl.visible) if (!window->wl.visible)
{ {
if (_glfw.wl.wmBase)
createXdgSurface(window); createXdgSurface(window);
else if (!window->wl.shellSurface)
createShellSurface(window);
window->wl.visible = GLFW_TRUE; window->wl.visible = GLFW_TRUE;
} }
} }
@@ -1208,11 +1024,6 @@ void _glfwPlatformHideWindow(_GLFWwindow* window)
window->wl.xdg.toplevel = NULL; window->wl.xdg.toplevel = NULL;
window->wl.xdg.surface = NULL; window->wl.xdg.surface = NULL;
} }
else if (window->wl.shellSurface)
{
wl_shell_surface_destroy(window->wl.shellSurface);
window->wl.shellSurface = NULL;
}
window->wl.visible = GLFW_FALSE; window->wl.visible = GLFW_FALSE;
} }
@@ -1243,8 +1054,6 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
{ {
if (window->wl.xdg.toplevel) if (window->wl.xdg.toplevel)
xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel); xdg_toplevel_unset_fullscreen(window->wl.xdg.toplevel);
else if (window->wl.shellSurface)
wl_shell_surface_set_toplevel(window->wl.shellSurface);
setIdleInhibitor(window, GLFW_FALSE); setIdleInhibitor(window, GLFW_FALSE);
if (!_glfw.wl.decorationManager) if (!_glfw.wl.decorationManager)
createDecorations(window); createDecorations(window);
@@ -1259,8 +1068,8 @@ int _glfwPlatformWindowFocused(_GLFWwindow* window)
int _glfwPlatformWindowIconified(_GLFWwindow* window) int _glfwPlatformWindowIconified(_GLFWwindow* window)
{ {
// wl_shell doesn't have any iconified concept, and xdg-shell doesnt give // xdg-shell doesnt give any way to request whether a surface is
// any way to request whether a surface is iconified. // iconified.
return GLFW_FALSE; return GLFW_FALSE;
} }
@@ -1402,26 +1211,79 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
struct wl_cursor* standardCursor; const char* name = NULL;
standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, // Try the XDG names first
translateCursorShape(shape)); if (shape == GLFW_ARROW_CURSOR)
if (!standardCursor) name = "default";
{ else if (shape == GLFW_IBEAM_CURSOR)
_glfwInputError(GLFW_PLATFORM_ERROR, name = "text";
"Wayland: Standard cursor \"%s\" not found", else if (shape == GLFW_CROSSHAIR_CURSOR)
translateCursorShape(shape)); name = "crosshair";
return GLFW_FALSE; else if (shape == GLFW_POINTING_HAND_CURSOR)
} name = "pointer";
else if (shape == GLFW_RESIZE_EW_CURSOR)
name = "ew-resize";
else if (shape == GLFW_RESIZE_NS_CURSOR)
name = "ns-resize";
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
name = "nwse-resize";
else if (shape == GLFW_RESIZE_NESW_CURSOR)
name = "nesw-resize";
else if (shape == GLFW_RESIZE_ALL_CURSOR)
name = "all-scroll";
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
name = "not-allowed";
cursor->wl.cursor = standardCursor; cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
cursor->wl.currentImage = 0;
if (_glfw.wl.cursorThemeHiDPI) if (_glfw.wl.cursorThemeHiDPI)
{ {
standardCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, cursor->wl.cursorHiDPI =
translateCursorShape(shape)); wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
cursor->wl.cursorHiDPI = standardCursor; }
if (!cursor->wl.cursor)
{
// Fall back to the core X11 names
if (shape == GLFW_ARROW_CURSOR)
name = "left_ptr";
else if (shape == GLFW_IBEAM_CURSOR)
name = "xterm";
else if (shape == GLFW_CROSSHAIR_CURSOR)
name = "crosshair";
else if (shape == GLFW_POINTING_HAND_CURSOR)
name = "hand2";
else if (shape == GLFW_RESIZE_EW_CURSOR)
name = "sb_h_double_arrow";
else if (shape == GLFW_RESIZE_NS_CURSOR)
name = "sb_v_double_arrow";
else if (shape == GLFW_RESIZE_ALL_CURSOR)
name = "fleur";
else
{
_glfwInputError(GLFW_CURSOR_UNAVAILABLE,
"Wayland: Standard cursor shape unavailable");
return GLFW_FALSE;
}
cursor->wl.cursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, name);
if (!cursor->wl.cursor)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Wayland: Failed to create standard cursor \"%s\"",
name);
return GLFW_FALSE;
}
if (_glfw.wl.cursorThemeHiDPI)
{
if (!cursor->wl.cursorHiDPI)
{
cursor->wl.cursorHiDPI =
wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, name);
}
}
} }
return GLFW_TRUE; return GLFW_TRUE;
+51 -39
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 X11 - www.glfw.org // GLFW 3.4 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -52,7 +54,7 @@ static int translateKeyCode(int scancode)
// Note: This way we always force "NumLock = ON", which is intentional // Note: This way we always force "NumLock = ON", which is intentional
// since the returned key code should correspond to a physical // since the returned key code should correspond to a physical
// location. // location.
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 1); keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 1);
switch (keySym) switch (keySym)
{ {
case XK_KP_0: return GLFW_KEY_KP_0; case XK_KP_0: return GLFW_KEY_KP_0;
@@ -74,7 +76,7 @@ static int translateKeyCode(int scancode)
// Now try primary keysym for function keys (non-printable keys) // Now try primary keysym for function keys (non-printable keys)
// These should not depend on the current keyboard layout // These should not depend on the current keyboard layout
keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); keySym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, _glfw.x11.xkb.group, 0);
} }
else else
{ {
@@ -329,14 +331,13 @@ static void createKeyTables(void)
// //
static GLFWbool hasUsableInputMethodStyle(void) static GLFWbool hasUsableInputMethodStyle(void)
{ {
unsigned int i;
GLFWbool found = GLFW_FALSE; GLFWbool found = GLFW_FALSE;
XIMStyles* styles = NULL; XIMStyles* styles = NULL;
if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL) if (XGetIMValues(_glfw.x11.im, XNQueryInputStyle, &styles, NULL) != NULL)
return GLFW_FALSE; return GLFW_FALSE;
for (i = 0; i < styles->count_styles; i++) for (unsigned int i = 0; i < styles->count_styles; i++)
{ {
if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing)) if (styles->supported_styles[i] == (XIMPreeditNothing | XIMStatusNothing))
{ {
@@ -355,10 +356,9 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
unsigned long atomCount, unsigned long atomCount,
const char* atomName) const char* atomName)
{ {
unsigned long i;
const Atom atom = XInternAtom(_glfw.x11.display, atomName, False); const Atom atom = XInternAtom(_glfw.x11.display, atomName, False);
for (i = 0; i < atomCount; i++) for (unsigned int i = 0; i < atomCount; i++)
{ {
if (supportedAtoms[i] == atom) if (supportedAtoms[i] == atom)
return atom; return atom;
@@ -371,18 +371,11 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
// //
static void detectEWMH(void) static void detectEWMH(void)
{ {
// First we read the _NET_SUPPORTING_WM_CHECK property on the root window
Window* windowFromRoot = NULL; Window* windowFromRoot = NULL;
Window* windowFromChild = NULL;
// First we need a couple of atoms
const Atom supportingWmCheck =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
const Atom wmSupported =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
if (!_glfwGetWindowPropertyX11(_glfw.x11.root, if (!_glfwGetWindowPropertyX11(_glfw.x11.root,
supportingWmCheck, _glfw.x11.NET_SUPPORTING_WM_CHECK,
XA_WINDOW, XA_WINDOW,
(unsigned char**) &windowFromRoot)) (unsigned char**) &windowFromRoot))
{ {
@@ -391,10 +384,12 @@ static void detectEWMH(void)
_glfwGrabErrorHandlerX11(); _glfwGrabErrorHandlerX11();
// It should be the ID of a child window (of the root) // If it exists, it should be the XID of a top-level window
// Then we look for the same property on the child window // Then we look for the same property on that window
Window* windowFromChild = NULL;
if (!_glfwGetWindowPropertyX11(*windowFromRoot, if (!_glfwGetWindowPropertyX11(*windowFromRoot,
supportingWmCheck, _glfw.x11.NET_SUPPORTING_WM_CHECK,
XA_WINDOW, XA_WINDOW,
(unsigned char**) &windowFromChild)) (unsigned char**) &windowFromChild))
{ {
@@ -404,7 +399,8 @@ static void detectEWMH(void)
_glfwReleaseErrorHandlerX11(); _glfwReleaseErrorHandlerX11();
// It should be the ID of that same child window // If the property exists, it should contain the XID of the window
if (*windowFromRoot != *windowFromChild) if (*windowFromRoot != *windowFromChild)
{ {
XFree(windowFromRoot); XFree(windowFromRoot);
@@ -415,19 +411,20 @@ static void detectEWMH(void)
XFree(windowFromRoot); XFree(windowFromRoot);
XFree(windowFromChild); XFree(windowFromChild);
// We are now fairly sure that an EWMH-compliant window manager is running // We are now fairly sure that an EWMH-compliant WM is currently running
// We can now start querying the WM about what features it supports by
// looking in the _NET_SUPPORTED property on the root window
// It should contain a list of supported EWMH protocol and state atoms
Atom* supportedAtoms; Atom* supportedAtoms = NULL;
unsigned long atomCount; const unsigned long atomCount =
_glfwGetWindowPropertyX11(_glfw.x11.root,
// Now we need to check the _NET_SUPPORTED property of the root window _glfw.x11.NET_SUPPORTED,
// It should be a list of supported WM protocol and state atoms
atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root,
wmSupported,
XA_ATOM, XA_ATOM,
(unsigned char**) &supportedAtoms); (unsigned char**) &supportedAtoms);
// See which of the atoms we support that are supported by the WM // See which of the atoms we support that are supported by the WM
_glfw.x11.NET_WM_STATE = _glfw.x11.NET_WM_STATE =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE"); getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
_glfw.x11.NET_WM_STATE_ABOVE = _glfw.x11.NET_WM_STATE_ABOVE =
@@ -618,6 +615,12 @@ static GLFWbool initExtensions(void)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy"); _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageDestroy");
_glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor) _glfw.x11.xcursor.ImageLoadCursor = (PFN_XcursorImageLoadCursor)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor"); _glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorImageLoadCursor");
_glfw.x11.xcursor.GetTheme = (PFN_XcursorGetTheme)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetTheme");
_glfw.x11.xcursor.GetDefaultSize = (PFN_XcursorGetDefaultSize)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorGetDefaultSize");
_glfw.x11.xcursor.LibraryLoadImage = (PFN_XcursorLibraryLoadImage)
_glfw_dlsym(_glfw.x11.xcursor.handle, "XcursorLibraryLoadImage");
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
@@ -662,6 +665,14 @@ static GLFWbool initExtensions(void)
if (supported) if (supported)
_glfw.x11.xkb.detectable = GLFW_TRUE; _glfw.x11.xkb.detectable = GLFW_TRUE;
} }
_glfw.x11.xkb.group = 0;
XkbStateRec state;
if (XkbGetState(_glfw.x11.display, XkbUseCoreKbd, &state) == Success)
{
XkbSelectEventDetails(_glfw.x11.display, XkbUseCoreKbd, XkbStateNotify, XkbAllStateComponentsMask, XkbGroupStateMask);
_glfw.x11.xkb.group = (unsigned int)state.group;
}
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
@@ -707,9 +718,6 @@ static GLFWbool initExtensions(void)
// the keyboard mapping. // the keyboard mapping.
createKeyTables(); createKeyTables();
// Detect whether an EWMH-conformant window manager is running
detectEWMH();
// String format atoms // String format atoms
_glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False); _glfw.x11.NULL_ = XInternAtom(_glfw.x11.display, "NULL", False);
_glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False); _glfw.x11.UTF8_STRING = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
@@ -753,6 +761,10 @@ static GLFWbool initExtensions(void)
XInternAtom(_glfw.x11.display, "WM_STATE", False); XInternAtom(_glfw.x11.display, "WM_STATE", False);
_glfw.x11.WM_DELETE_WINDOW = _glfw.x11.WM_DELETE_WINDOW =
XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False); XInternAtom(_glfw.x11.display, "WM_DELETE_WINDOW", False);
_glfw.x11.NET_SUPPORTED =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", False);
_glfw.x11.NET_SUPPORTING_WM_CHECK =
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", False);
_glfw.x11.NET_WM_ICON = _glfw.x11.NET_WM_ICON =
XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False); XInternAtom(_glfw.x11.display, "_NET_WM_ICON", False);
_glfw.x11.NET_WM_PING = _glfw.x11.NET_WM_PING =
@@ -777,6 +789,9 @@ static GLFWbool initExtensions(void)
_glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False); _glfw.x11.NET_WM_CM_Sx = XInternAtom(_glfw.x11.display, name, False);
} }
// Detect whether an EWMH-conformant window manager is running
detectEWMH();
return GLFW_TRUE; return GLFW_TRUE;
} }
@@ -784,13 +799,10 @@ static GLFWbool initExtensions(void)
// //
static void getSystemContentScale(float* xscale, float* yscale) static void getSystemContentScale(float* xscale, float* yscale)
{ {
// NOTE: Fall back to the display-wide DPI instead of RandR monitor DPI if // Start by assuming the default X11 DPI
// Xft.dpi retrieval below fails as we don't currently have an exact // NOTE: Some desktop environments (KDE) may remove the Xft.dpi field when it
// policy for which monitor a window is considered to "be on" // would be set to 96, so assume that is the case if we cannot find it
float xdpi = DisplayWidth(_glfw.x11.display, _glfw.x11.screen) * float xdpi = 96.f, ydpi = 96.f;
25.4f / DisplayWidthMM(_glfw.x11.display, _glfw.x11.screen);
float ydpi = DisplayHeight(_glfw.x11.display, _glfw.x11.screen) *
25.4f / DisplayHeightMM(_glfw.x11.display, _glfw.x11.screen);
// NOTE: Basing the scale on Xft.dpi where available should provide the most // NOTE: Basing the scale on Xft.dpi where available should provide the most
// consistent user experience (matches Qt, Gtk, etc), although not // consistent user experience (matches Qt, Gtk, etc), although not
+45 -53
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 X11 - www.glfw.org // GLFW 3.4 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -54,9 +56,7 @@ static int calculateRefreshRate(const XRRModeInfo* mi)
// //
static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id) static const XRRModeInfo* getModeInfo(const XRRScreenResources* sr, RRMode id)
{ {
int i; for (int i = 0; i < sr->nmode; i++)
for (i = 0; i < sr->nmode; i++)
{ {
if (sr->modes[i].id == id) if (sr->modes[i].id == id)
return sr->modes + i; return sr->modes + i;
@@ -102,7 +102,7 @@ void _glfwPollMonitorsX11(void)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
int i, j, disconnectedCount, screenCount = 0; int disconnectedCount, screenCount = 0;
_GLFWmonitor** disconnected = NULL; _GLFWmonitor** disconnected = NULL;
XineramaScreenInfo* screens = NULL; XineramaScreenInfo* screens = NULL;
XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, XRRScreenResources* sr = XRRGetScreenResourcesCurrent(_glfw.x11.display,
@@ -122,14 +122,11 @@ void _glfwPollMonitorsX11(void)
_glfw.monitorCount * sizeof(_GLFWmonitor*)); _glfw.monitorCount * sizeof(_GLFWmonitor*));
} }
for (i = 0; i < sr->noutput; i++) for (int i = 0; i < sr->noutput; i++)
{ {
int type, widthMM, heightMM; int j, type, widthMM, heightMM;
XRROutputInfo* oi;
XRRCrtcInfo* ci;
_GLFWmonitor* monitor;
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]); XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
if (oi->connection != RR_Connected || oi->crtc == None) if (oi->connection != RR_Connected || oi->crtc == None)
{ {
XRRFreeOutputInfo(oi); XRRFreeOutputInfo(oi);
@@ -152,7 +149,7 @@ void _glfwPollMonitorsX11(void)
continue; continue;
} }
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270) if (ci->rotation == RR_Rotate_90 || ci->rotation == RR_Rotate_270)
{ {
widthMM = oi->mm_height; widthMM = oi->mm_height;
@@ -164,7 +161,17 @@ void _glfwPollMonitorsX11(void)
heightMM = oi->mm_height; heightMM = oi->mm_height;
} }
monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM); if (widthMM <= 0 || heightMM <= 0)
{
// HACK: If RandR does not provide a physical size, assume the
// X11 default 96 DPI and calcuate from the CRTC viewport
// NOTE: These members are affected by rotation, unlike the mode
// info and output info members
widthMM = (int) (ci->width * 25.4f / 96.f);
heightMM = (int) (ci->height * 25.4f / 96.f);
}
_GLFWmonitor* monitor = _glfwAllocMonitor(oi->name, widthMM, heightMM);
monitor->x11.output = sr->outputs[i]; monitor->x11.output = sr->outputs[i];
monitor->x11.crtc = oi->crtc; monitor->x11.crtc = oi->crtc;
@@ -196,7 +203,7 @@ void _glfwPollMonitorsX11(void)
if (screens) if (screens)
XFree(screens); XFree(screens);
for (i = 0; i < disconnectedCount; i++) for (int i = 0; i < disconnectedCount; i++)
{ {
if (disconnected[i]) if (disconnected[i])
_glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0); _glfwInputMonitor(disconnected[i], GLFW_DISCONNECTED, 0);
@@ -221,24 +228,20 @@ void _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr;
XRRCrtcInfo* ci;
XRROutputInfo* oi;
GLFWvidmode current; GLFWvidmode current;
const GLFWvidmode* best;
RRMode native = None; RRMode native = None;
int i;
best = _glfwChooseVideoMode(monitor, desired); const GLFWvidmode* best = _glfwChooseVideoMode(monitor, desired);
_glfwPlatformGetVideoMode(monitor, &current); _glfwPlatformGetVideoMode(monitor, &current);
if (_glfwCompareVideoModes(&current, best) == 0) if (_glfwCompareVideoModes(&current, best) == 0)
return; return;
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRScreenResources* sr =
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output); XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
for (i = 0; i < oi->nmode; i++) for (int i = 0; i < oi->nmode; i++)
{ {
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
if (!modeIsGood(mi)) if (!modeIsGood(mi))
@@ -279,14 +282,12 @@ void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr;
XRRCrtcInfo* ci;
if (monitor->x11.oldMode == None) if (monitor->x11.oldMode == None)
return; return;
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root); XRRScreenResources* sr =
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc); XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRRSetCrtcConfig(_glfw.x11.display, XRRSetCrtcConfig(_glfw.x11.display,
sr, monitor->x11.crtc, sr, monitor->x11.crtc,
@@ -317,11 +318,9 @@ void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr; XRRScreenResources* sr =
XRRCrtcInfo* ci; XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
if (xpos) if (xpos)
*xpos = ci->x; *xpos = ci->x;
@@ -348,11 +347,9 @@ void _glfwPlatformGetMonitorWorkarea(_GLFWmonitor* monitor, int* xpos, int* ypos
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr; XRRScreenResources* sr =
XRRCrtcInfo* ci; XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
areaX = ci->x; areaX = ci->x;
areaY = ci->y; areaY = ci->y;
@@ -444,24 +441,21 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count)
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
int i, j; XRRScreenResources* sr =
XRRScreenResources* sr; XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci; XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
XRROutputInfo* oi; XRROutputInfo* oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
oi = XRRGetOutputInfo(_glfw.x11.display, sr, monitor->x11.output);
result = calloc(oi->nmode, sizeof(GLFWvidmode)); result = calloc(oi->nmode, sizeof(GLFWvidmode));
for (i = 0; i < oi->nmode; i++) for (int i = 0; i < oi->nmode; i++)
{ {
const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]); const XRRModeInfo* mi = getModeInfo(sr, oi->modes[i]);
if (!modeIsGood(mi)) if (!modeIsGood(mi))
continue; continue;
const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci); const GLFWvidmode mode = vidmodeFromModeInfo(mi, ci);
int j;
for (j = 0; j < *count; j++) for (j = 0; j < *count; j++)
{ {
@@ -495,11 +489,9 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{ {
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken) if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
{ {
XRRScreenResources* sr; XRRScreenResources* sr =
XRRCrtcInfo* ci; XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
XRRCrtcInfo* ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
sr = XRRGetScreenResourcesCurrent(_glfw.x11.display, _glfw.x11.root);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.crtc);
*mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci); *mode = vidmodeFromModeInfo(getModeInfo(sr, ci->mode), ci);
+14 -2
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 X11 - www.glfw.org // GLFW 3.4 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -85,9 +85,15 @@ typedef int (* PFN_XRRUpdateConfiguration)(XEvent*);
typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int); typedef XcursorImage* (* PFN_XcursorImageCreate)(int,int);
typedef void (* PFN_XcursorImageDestroy)(XcursorImage*); typedef void (* PFN_XcursorImageDestroy)(XcursorImage*);
typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*); typedef Cursor (* PFN_XcursorImageLoadCursor)(Display*,const XcursorImage*);
typedef char* (* PFN_XcursorGetTheme)(Display*);
typedef int (* PFN_XcursorGetDefaultSize)(Display*);
typedef XcursorImage* (* PFN_XcursorLibraryLoadImage)(const char*,const char*,int);
#define XcursorImageCreate _glfw.x11.xcursor.ImageCreate #define XcursorImageCreate _glfw.x11.xcursor.ImageCreate
#define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy #define XcursorImageDestroy _glfw.x11.xcursor.ImageDestroy
#define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor #define XcursorImageLoadCursor _glfw.x11.xcursor.ImageLoadCursor
#define XcursorGetTheme _glfw.x11.xcursor.GetTheme
#define XcursorGetDefaultSize _glfw.x11.xcursor.GetDefaultSize
#define XcursorLibraryLoadImage _glfw.x11.xcursor.LibraryLoadImage
typedef Bool (* PFN_XineramaIsActive)(Display*); typedef Bool (* PFN_XineramaIsActive)(Display*);
typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*); typedef Bool (* PFN_XineramaQueryExtension)(Display*,int*,int*);
@@ -228,7 +234,7 @@ typedef struct _GLFWlibraryX11
// Clipboard string (while the selection is owned) // Clipboard string (while the selection is owned)
char* clipboardString; char* clipboardString;
// Key name string // Key name string
char keyName[5]; char keynames[GLFW_KEY_LAST + 1][5];
// X11 keycode to GLFW key LUT // X11 keycode to GLFW key LUT
short int keycodes[256]; short int keycodes[256];
// GLFW key to X11 keycode LUT // GLFW key to X11 keycode LUT
@@ -239,6 +245,8 @@ typedef struct _GLFWlibraryX11
_GLFWwindow* disabledCursorWindow; _GLFWwindow* disabledCursorWindow;
// Window manager atoms // Window manager atoms
Atom NET_SUPPORTED;
Atom NET_SUPPORTING_WM_CHECK;
Atom WM_PROTOCOLS; Atom WM_PROTOCOLS;
Atom WM_STATE; Atom WM_STATE;
Atom WM_DELETE_WINDOW; Atom WM_DELETE_WINDOW;
@@ -328,6 +336,7 @@ typedef struct _GLFWlibraryX11
int errorBase; int errorBase;
int major; int major;
int minor; int minor;
unsigned int group;
} xkb; } xkb;
struct { struct {
@@ -349,6 +358,9 @@ typedef struct _GLFWlibraryX11
PFN_XcursorImageCreate ImageCreate; PFN_XcursorImageCreate ImageCreate;
PFN_XcursorImageDestroy ImageDestroy; PFN_XcursorImageDestroy ImageDestroy;
PFN_XcursorImageLoadCursor ImageLoadCursor; PFN_XcursorImageLoadCursor ImageLoadCursor;
PFN_XcursorGetTheme GetTheme;
PFN_XcursorGetDefaultSize GetDefaultSize;
PFN_XcursorLibraryLoadImage LibraryLoadImage;
} xcursor; } xcursor;
struct { struct {
+93 -54
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 X11 - www.glfw.org // GLFW 3.4 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2019 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
@@ -48,6 +50,10 @@
#define Button6 6 #define Button6 6
#define Button7 7 #define Button7 7
// Motif WM hints flags
#define MWM_HINTS_DECORATIONS 2
#define MWM_DECOR_ALL 1
#define _GLFW_XDND_VERSION 5 #define _GLFW_XDND_VERSION 5
@@ -213,10 +219,7 @@ static int translateKey(int scancode)
static void sendEventToWM(_GLFWwindow* window, Atom type, static void sendEventToWM(_GLFWwindow* window, Atom type,
long a, long b, long c, long d, long e) long a, long b, long c, long d, long e)
{ {
XEvent event; XEvent event = { ClientMessage };
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->x11.handle; event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = type; event.xclient.message_type = type;
@@ -944,11 +947,8 @@ static void handleSelectionRequest(XEvent* event)
{ {
const XSelectionRequestEvent* request = &event->xselectionrequest; const XSelectionRequestEvent* request = &event->xselectionrequest;
XEvent reply; XEvent reply = { SelectionNotify };
memset(&reply, 0, sizeof(reply));
reply.xselection.property = writeTargetToProperty(request); reply.xselection.property = writeTargetToProperty(request);
reply.xselection.type = SelectionNotify;
reply.xselection.display = request->display; reply.xselection.display = request->display;
reply.xselection.requestor = request->requestor; reply.xselection.requestor = request->requestor;
reply.xselection.selection = request->selection; reply.xselection.selection = request->selection;
@@ -960,7 +960,6 @@ static void handleSelectionRequest(XEvent* event)
static const char* getSelectionString(Atom selection) static const char* getSelectionString(Atom selection)
{ {
size_t i;
char** selectionString = NULL; char** selectionString = NULL;
const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING }; const Atom targets[] = { _glfw.x11.UTF8_STRING, XA_STRING };
const size_t targetCount = sizeof(targets) / sizeof(targets[0]); const size_t targetCount = sizeof(targets) / sizeof(targets[0]);
@@ -981,7 +980,7 @@ static const char* getSelectionString(Atom selection)
free(*selectionString); free(*selectionString);
*selectionString = NULL; *selectionString = NULL;
for (i = 0; i < targetCount; i++) for (size_t i = 0; i < targetCount; i++)
{ {
char* data; char* data;
Atom actualType; Atom actualType;
@@ -1165,7 +1164,6 @@ static void releaseMonitor(_GLFWwindow* window)
// //
static void processEvent(XEvent *event) static void processEvent(XEvent *event)
{ {
_GLFWwindow* window = NULL;
int keycode = 0; int keycode = 0;
Bool filtered = False; Bool filtered = False;
@@ -1186,6 +1184,18 @@ static void processEvent(XEvent *event)
} }
} }
if (_glfw.x11.xkb.available)
{
if (event->type == _glfw.x11.xkb.eventBase + XkbEventCode)
{
if (((XkbEvent*) event)->any.xkb_type == XkbStateNotify &&
(((XkbEvent*) event)->state.changed & XkbGroupStateMask))
{
_glfw.x11.xkb.group = ((XkbEvent*) event)->state.group;
}
}
}
if (event->type == GenericEvent) if (event->type == GenericEvent)
{ {
if (_glfw.x11.xi.available) if (_glfw.x11.xi.available)
@@ -1235,6 +1245,7 @@ static void processEvent(XEvent *event)
return; return;
} }
_GLFWwindow* window = NULL;
if (XFindContext(_glfw.x11.display, if (XFindContext(_glfw.x11.display,
event->xany.window, event->xany.window,
_glfw.x11.context, _glfw.x11.context,
@@ -1646,10 +1657,7 @@ static void processEvent(XEvent *event)
} }
else if (_glfw.x11.xdnd.version >= 2) else if (_glfw.x11.xdnd.version >= 2)
{ {
XEvent reply; XEvent reply = { ClientMessage };
memset(&reply, 0, sizeof(reply));
reply.type = ClientMessage;
reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.window = _glfw.x11.xdnd.source;
reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.message_type = _glfw.x11.XdndFinished;
reply.xclient.format = 32; reply.xclient.format = 32;
@@ -1682,10 +1690,7 @@ static void processEvent(XEvent *event)
_glfwInputCursorPos(window, xpos, ypos); _glfwInputCursorPos(window, xpos, ypos);
XEvent reply; XEvent reply = { ClientMessage };
memset(&reply, 0, sizeof(reply));
reply.type = ClientMessage;
reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.window = _glfw.x11.xdnd.source;
reply.xclient.message_type = _glfw.x11.XdndStatus; reply.xclient.message_type = _glfw.x11.XdndStatus;
reply.xclient.format = 32; reply.xclient.format = 32;
@@ -1738,10 +1743,7 @@ static void processEvent(XEvent *event)
if (_glfw.x11.xdnd.version >= 2) if (_glfw.x11.xdnd.version >= 2)
{ {
XEvent reply; XEvent reply = { ClientMessage };
memset(&reply, 0, sizeof(reply));
reply.type = ClientMessage;
reply.xclient.window = _glfw.x11.xdnd.source; reply.xclient.window = _glfw.x11.xdnd.source;
reply.xclient.message_type = _glfw.x11.XdndFinished; reply.xclient.message_type = _glfw.x11.XdndFinished;
reply.xclient.format = 32; reply.xclient.format = 32;
@@ -1760,9 +1762,6 @@ static void processEvent(XEvent *event)
case FocusIn: case FocusIn:
{ {
if (window->cursorMode == GLFW_CURSOR_DISABLED)
disableCursor(window);
if (event->xfocus.mode == NotifyGrab || if (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab) event->xfocus.mode == NotifyUngrab)
{ {
@@ -1771,6 +1770,9 @@ static void processEvent(XEvent *event)
return; return;
} }
if (window->cursorMode == GLFW_CURSOR_DISABLED)
disableCursor(window);
if (window->x11.ic) if (window->x11.ic)
XSetICFocus(window->x11.ic); XSetICFocus(window->x11.ic);
@@ -1780,9 +1782,6 @@ static void processEvent(XEvent *event)
case FocusOut: case FocusOut:
{ {
if (window->cursorMode == GLFW_CURSOR_DISABLED)
enableCursor(window);
if (event->xfocus.mode == NotifyGrab || if (event->xfocus.mode == NotifyGrab ||
event->xfocus.mode == NotifyUngrab) event->xfocus.mode == NotifyUngrab)
{ {
@@ -1791,6 +1790,9 @@ static void processEvent(XEvent *event)
return; return;
} }
if (window->cursorMode == GLFW_CURSOR_DISABLED)
enableCursor(window);
if (window->x11.ic) if (window->x11.ic)
XUnsetICFocus(window->x11.ic); XUnsetICFocus(window->x11.ic);
@@ -2537,14 +2539,6 @@ void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
} }
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
{
if (enabled)
{
XDeleteProperty(_glfw.x11.display,
window->x11.handle,
_glfw.x11.MOTIF_WM_HINTS);
}
else
{ {
struct struct
{ {
@@ -2553,10 +2547,10 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
unsigned long decorations; unsigned long decorations;
long input_mode; long input_mode;
unsigned long status; unsigned long status;
} hints; } hints = {0};
hints.flags = 2; // Set decorations hints.flags = MWM_HINTS_DECORATIONS;
hints.decorations = 0; // No decorations hints.decorations = enabled ? MWM_DECOR_ALL : 0;
XChangeProperty(_glfw.x11.display, window->x11.handle, XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.MOTIF_WM_HINTS, _glfw.x11.MOTIF_WM_HINTS,
@@ -2565,7 +2559,6 @@ void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
(unsigned char*) &hints, (unsigned char*) &hints,
sizeof(hints) / sizeof(long)); sizeof(hints) / sizeof(long));
} }
}
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled) void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
{ {
@@ -2737,10 +2730,7 @@ void _glfwPlatformWaitEventsTimeout(double timeout)
void _glfwPlatformPostEmptyEvent(void) void _glfwPlatformPostEmptyEvent(void)
{ {
XEvent event; XEvent event = { ClientMessage };
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = _glfw.x11.helperWindowHandle; event.xclient.window = _glfw.x11.helperWindowHandle;
event.xclient.format = 32; // Data is 32-bit longs event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfw.x11.NULL_; event.xclient.message_type = _glfw.x11.NULL_;
@@ -2797,7 +2787,9 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (!_glfw.x11.xkb.available) if (!_glfw.x11.xkb.available)
return NULL; return NULL;
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display, scancode, 0, 0); const int key = _glfw.x11.keycodes[scancode];
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
scancode, _glfw.x11.xkb.group, 0);
if (keysym == NoSymbol) if (keysym == NoSymbol)
return NULL; return NULL;
@@ -2805,12 +2797,12 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (ch == -1) if (ch == -1)
return NULL; return NULL;
const size_t count = encodeUTF8(_glfw.x11.keyName, (unsigned int) ch); const size_t count = encodeUTF8(_glfw.x11.keynames[key], (unsigned int) ch);
if (count == 0) if (count == 0)
return NULL; return NULL;
_glfw.x11.keyName[count] = '\0'; _glfw.x11.keynames[key][count] = '\0';
return _glfw.x11.keyName; return _glfw.x11.keynames[key];
} }
int _glfwPlatformGetKeyScancode(int key) int _glfwPlatformGetKeyScancode(int key)
@@ -2831,7 +2823,47 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape) int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
{ {
int native = 0; if (_glfw.x11.xcursor.handle)
{
char* theme = XcursorGetTheme(_glfw.x11.display);
if (theme)
{
const int size = XcursorGetDefaultSize(_glfw.x11.display);
const char* name = NULL;
if (shape == GLFW_ARROW_CURSOR)
name = "default";
else if (shape == GLFW_IBEAM_CURSOR)
name = "text";
else if (shape == GLFW_CROSSHAIR_CURSOR)
name = "crosshair";
else if (shape == GLFW_POINTING_HAND_CURSOR)
name = "pointer";
else if (shape == GLFW_RESIZE_EW_CURSOR)
name = "ew-resize";
else if (shape == GLFW_RESIZE_NS_CURSOR)
name = "ns-resize";
else if (shape == GLFW_RESIZE_NWSE_CURSOR)
name = "nwse-resize";
else if (shape == GLFW_RESIZE_NESW_CURSOR)
name = "nesw-resize";
else if (shape == GLFW_RESIZE_ALL_CURSOR)
name = "all-scroll";
else if (shape == GLFW_NOT_ALLOWED_CURSOR)
name = "not-allowed";
XcursorImage* image = XcursorLibraryLoadImage(name, theme, size);
if (image)
{
cursor->x11.handle = XcursorImageLoadCursor(_glfw.x11.display, image);
XcursorImageDestroy(image);
}
}
}
if (!cursor->x11.handle)
{
unsigned int native = 0;
if (shape == GLFW_ARROW_CURSOR) if (shape == GLFW_ARROW_CURSOR)
native = XC_left_ptr; native = XC_left_ptr;
@@ -2839,14 +2871,20 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
native = XC_xterm; native = XC_xterm;
else if (shape == GLFW_CROSSHAIR_CURSOR) else if (shape == GLFW_CROSSHAIR_CURSOR)
native = XC_crosshair; native = XC_crosshair;
else if (shape == GLFW_HAND_CURSOR) else if (shape == GLFW_POINTING_HAND_CURSOR)
native = XC_hand2; native = XC_hand2;
else if (shape == GLFW_HRESIZE_CURSOR) else if (shape == GLFW_RESIZE_EW_CURSOR)
native = XC_sb_h_double_arrow; native = XC_sb_h_double_arrow;
else if (shape == GLFW_VRESIZE_CURSOR) else if (shape == GLFW_RESIZE_NS_CURSOR)
native = XC_sb_v_double_arrow; native = XC_sb_v_double_arrow;
else if (shape == GLFW_RESIZE_ALL_CURSOR)
native = XC_fleur;
else else
{
_glfwInputError(GLFW_CURSOR_UNAVAILABLE,
"X11: Standard cursor shape unavailable");
return GLFW_FALSE; return GLFW_FALSE;
}
cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native); cursor->x11.handle = XCreateFontCursor(_glfw.x11.display, native);
if (!cursor->x11.handle) if (!cursor->x11.handle)
@@ -2855,6 +2893,7 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
"X11: Failed to create standard cursor"); "X11: Failed to create standard cursor");
return GLFW_FALSE; return GLFW_FALSE;
} }
}
return GLFW_TRUE; return GLFW_TRUE;
} }
+3 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 X11 - www.glfw.org // GLFW 3.4 X11 - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard // Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org> // Copyright (c) 2006-2017 Camilla Löwy <elmindreda@glfw.org>
@@ -24,6 +24,8 @@
// distribution. // distribution.
// //
//======================================================================== //========================================================================
// It is fine to use C99 in this file because it will not be built with VS
//========================================================================
#include "internal.h" #include "internal.h"
+1 -1
View File
@@ -1,5 +1,5 @@
//======================================================================== //========================================================================
// GLFW 3.3 Linux - www.glfw.org // GLFW 3.4 Linux - www.glfw.org
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com> // Copyright (c) 2014 Jonas Ådahl <jadahl@gmail.com>
// //
+15 -4
View File
@@ -20,6 +20,17 @@ set(GETOPT "${GLFW_SOURCE_DIR}/deps/getopt.h"
set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h" set(TINYCTHREAD "${GLFW_SOURCE_DIR}/deps/tinycthread.h"
"${GLFW_SOURCE_DIR}/deps/tinycthread.c") "${GLFW_SOURCE_DIR}/deps/tinycthread.c")
if (${CMAKE_VERSION} VERSION_EQUAL "3.1.0" OR
${CMAKE_VERSION} VERSION_GREATER "3.1.0")
set(CMAKE_C_STANDARD 99)
else()
# Remove this fallback when removing support for CMake version less than 3.1
add_compile_options("$<$<C_COMPILER_ID:AppleClang>:-std=c99>"
"$<$<C_COMPILER_ID:Clang>:-std=c99>"
"$<$<C_COMPILER_ID:GNU>:-std=c99>")
endif()
add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL}) add_executable(clipboard clipboard.c ${GETOPT} ${GLAD_GL})
add_executable(events events.c ${GETOPT} ${GLAD_GL}) add_executable(events events.c ${GETOPT} ${GLAD_GL})
add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL}) add_executable(msaa msaa.c ${GETOPT} ${GLAD_GL})
@@ -39,7 +50,7 @@ add_executable(tearing WIN32 MACOSX_BUNDLE tearing.c ${GLAD_GL})
add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL}) add_executable(threads WIN32 MACOSX_BUNDLE threads.c ${TINYCTHREAD} ${GLAD_GL})
add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL}) add_executable(timeout WIN32 MACOSX_BUNDLE timeout.c ${GLAD_GL})
add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL}) add_executable(title WIN32 MACOSX_BUNDLE title.c ${GLAD_GL})
add_executable(vulkan WIN32 vulkan.c ${ICON} ${GLAD_VULKAN}) add_executable(triangle-vulkan WIN32 triangle-vulkan.c ${ICON} ${GLAD_VULKAN})
add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${GETOPT} ${GLAD_GL})
target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}") target_link_libraries(empty "${CMAKE_THREAD_LIBS_INIT}")
@@ -50,7 +61,7 @@ if (RT_LIBRARY)
endif() endif()
set(WINDOWS_BINARIES empty gamma icon inputlag joysticks opacity tearing set(WINDOWS_BINARIES empty gamma icon inputlag joysticks opacity tearing
threads timeout title vulkan windows) threads timeout title triangle-vulkan windows)
set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen set(CONSOLE_BINARIES clipboard events msaa glfwinfo iconify monitors reopen
cursor) cursor)
@@ -73,12 +84,12 @@ if (APPLE)
set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads") set_target_properties(threads PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Threads")
set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout") set_target_properties(timeout PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Timeout")
set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title") set_target_properties(title PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Title")
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan") set_target_properties(triangle-vulkan PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Vulkan Triangle")
set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows") set_target_properties(windows PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "Windows")
set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES set_target_properties(${WINDOWS_BINARIES} ${CONSOLE_BINARIES} PROPERTIES
MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION_FULL} MACOSX_BUNDLE_LONG_VERSION_STRING ${GLFW_VERSION}
MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in") MACOSX_BUNDLE_INFO_PLIST "${GLFW_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")
endif() endif()
+1
View File
@@ -28,6 +28,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
+21 -25
View File
@@ -31,6 +31,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#if defined(_MSC_VER) #if defined(_MSC_VER)
@@ -68,7 +69,7 @@ static int swap_interval = 1;
static int wait_events = GLFW_TRUE; static int wait_events = GLFW_TRUE;
static int animate_cursor = GLFW_FALSE; static int animate_cursor = GLFW_FALSE;
static int track_cursor = GLFW_FALSE; static int track_cursor = GLFW_FALSE;
static GLFWcursor* standard_cursors[6]; static GLFWcursor* standard_cursors[10];
static GLFWcursor* tracking_cursor = NULL; static GLFWcursor* tracking_cursor = NULL;
static void error_callback(int error, const char* description) static void error_callback(int error, const char* description)
@@ -270,28 +271,24 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
break; break;
case GLFW_KEY_1: case GLFW_KEY_1:
glfwSetCursor(window, standard_cursors[0]);
break;
case GLFW_KEY_2: case GLFW_KEY_2:
glfwSetCursor(window, standard_cursors[1]);
break;
case GLFW_KEY_3: case GLFW_KEY_3:
glfwSetCursor(window, standard_cursors[2]);
break;
case GLFW_KEY_4: case GLFW_KEY_4:
glfwSetCursor(window, standard_cursors[3]);
break;
case GLFW_KEY_5: case GLFW_KEY_5:
glfwSetCursor(window, standard_cursors[4]);
break;
case GLFW_KEY_6: case GLFW_KEY_6:
glfwSetCursor(window, standard_cursors[5]); case GLFW_KEY_7:
case GLFW_KEY_8:
case GLFW_KEY_9:
{
int index = key - GLFW_KEY_1;
if (mods & GLFW_MOD_SHIFT)
index += 9;
if (index < sizeof(standard_cursors) / sizeof(standard_cursors[0]))
glfwSetCursor(window, standard_cursors[index]);
break; break;
}
case GLFW_KEY_F11: case GLFW_KEY_F11:
case GLFW_KEY_ENTER: case GLFW_KEY_ENTER:
@@ -357,17 +354,16 @@ int main(void)
GLFW_ARROW_CURSOR, GLFW_ARROW_CURSOR,
GLFW_IBEAM_CURSOR, GLFW_IBEAM_CURSOR,
GLFW_CROSSHAIR_CURSOR, GLFW_CROSSHAIR_CURSOR,
GLFW_HAND_CURSOR, GLFW_POINTING_HAND_CURSOR,
GLFW_HRESIZE_CURSOR, GLFW_RESIZE_EW_CURSOR,
GLFW_VRESIZE_CURSOR GLFW_RESIZE_NS_CURSOR,
GLFW_RESIZE_NWSE_CURSOR,
GLFW_RESIZE_NESW_CURSOR,
GLFW_RESIZE_ALL_CURSOR,
GLFW_NOT_ALLOWED_CURSOR
}; };
standard_cursors[i] = glfwCreateStandardCursor(shapes[i]); standard_cursors[i] = glfwCreateStandardCursor(shapes[i]);
if (!standard_cursors[i])
{
glfwTerminate();
exit(EXIT_FAILURE);
}
} }
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
+1
View File
@@ -30,6 +30,7 @@
#include "tinycthread.h" #include "tinycthread.h"
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <math.h> #include <math.h>
+50 -14
View File
@@ -32,6 +32,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
@@ -174,7 +175,7 @@ static const char* get_key_name(int key)
case GLFW_KEY_KP_8: return "KEYPAD 8"; case GLFW_KEY_KP_8: return "KEYPAD 8";
case GLFW_KEY_KP_9: return "KEYPAD 9"; case GLFW_KEY_KP_9: return "KEYPAD 9";
case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE"; case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY"; case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTIPLY";
case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT"; case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
case GLFW_KEY_KP_ADD: return "KEYPAD ADD"; case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
@@ -252,17 +253,32 @@ static const char* get_mods_name(int mods)
return name; return name;
} }
static const char* get_character_string(int codepoint) static size_t encode_utf8(char* s, unsigned int ch)
{ {
// This assumes UTF-8, which is stupid size_t count = 0;
static char result[6 + 1];
int length = wctomb(result, codepoint); if (ch < 0x80)
if (length == -1) s[count++] = (char) ch;
length = 0; else if (ch < 0x800)
{
s[count++] = (ch >> 6) | 0xc0;
s[count++] = (ch & 0x3f) | 0x80;
}
else if (ch < 0x10000)
{
s[count++] = (ch >> 12) | 0xe0;
s[count++] = ((ch >> 6) & 0x3f) | 0x80;
s[count++] = (ch & 0x3f) | 0x80;
}
else if (ch < 0x110000)
{
s[count++] = (ch >> 18) | 0xf0;
s[count++] = ((ch >> 12) & 0x3f) | 0x80;
s[count++] = ((ch >> 6) & 0x3f) | 0x80;
s[count++] = (ch & 0x3f) | 0x80;
}
result[length] = '\0'; return count;
return result;
} }
static void error_callback(int error, const char* description) static void error_callback(int error, const char* description)
@@ -304,6 +320,12 @@ static void window_close_callback(GLFWwindow* window)
printf("%08x to %i at %0.3f: Window close\n", printf("%08x to %i at %0.3f: Window close\n",
counter++, slot->number, glfwGetTime()); counter++, slot->number, glfwGetTime());
if (!slot->closeable)
{
printf("(( closing is disabled, press %s to re-enable )\n",
glfwGetKeyName(GLFW_KEY_C, 0));
}
glfwSetWindowShouldClose(window, slot->closeable); glfwSetWindowShouldClose(window, slot->closeable);
} }
@@ -424,12 +446,14 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
static void char_callback(GLFWwindow* window, unsigned int codepoint) static void char_callback(GLFWwindow* window, unsigned int codepoint)
{ {
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
char string[5] = "";
encode_utf8(string, codepoint);
printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n", printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
counter++, slot->number, glfwGetTime(), codepoint, counter++, slot->number, glfwGetTime(), codepoint, string);
get_character_string(codepoint));
} }
static void drop_callback(GLFWwindow* window, int count, const char** paths) static void drop_callback(GLFWwindow* window, int count, const char* paths[])
{ {
int i; int i;
Slot* slot = glfwGetWindowUserPointer(window); Slot* slot = glfwGetWindowUserPointer(window);
@@ -485,6 +509,20 @@ static void joystick_callback(int jid, int event)
axisCount, axisCount,
buttonCount, buttonCount,
hatCount); hatCount);
if (glfwJoystickIsGamepad(jid))
{
printf(" Joystick %i (%s) has a gamepad mapping (%s)\n",
jid,
glfwGetJoystickGUID(jid),
glfwGetGamepadName(jid));
}
else
{
printf(" Joystick %i (%s) has no gamepad mapping\n",
jid,
glfwGetJoystickGUID(jid));
}
} }
else else
{ {
@@ -499,8 +537,6 @@ int main(int argc, char** argv)
GLFWmonitor* monitor = NULL; GLFWmonitor* monitor = NULL;
int ch, i, width, height, count = 1; int ch, i, width, height, count = 1;
setlocale(LC_ALL, "");
glfwSetErrorCallback(error_callback); glfwSetErrorCallback(error_callback);
if (!glfwInit()) if (!glfwInit())
+2
View File
@@ -29,6 +29,7 @@
//======================================================================== //========================================================================
#include <glad/gl.h> #include <glad/gl.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#define NK_IMPLEMENTATION #define NK_IMPLEMENTATION
@@ -100,6 +101,7 @@ int main(int argc, char** argv)
monitor = glfwGetPrimaryMonitor(); monitor = glfwGetPrimaryMonitor();
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE); glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
glfwWindowHint(GLFW_WIN32_KEYBOARD_MENU, GLFW_TRUE);
window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL); window = glfwCreateWindow(800, 400, "Gamma Test", NULL, NULL);
if (!window) if (!window)
+80 -114
View File
@@ -25,11 +25,13 @@
#include <glad/gl.h> #include <glad/gl.h>
#include <glad/vulkan.h> #include <glad/vulkan.h>
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdbool.h>
#include "getopt.h" #include "getopt.h"
@@ -175,22 +177,19 @@ static const char* get_strategy_name_glfw(int strategy)
static void list_context_extensions(int client, int major, int minor) static void list_context_extensions(int client, int major, int minor)
{ {
int i;
GLint count;
const GLubyte* extensions;
printf("%s context extensions:\n", get_api_name(client)); printf("%s context extensions:\n", get_api_name(client));
if (client == GLFW_OPENGL_API && major > 2) if (client == GLFW_OPENGL_API && major > 2)
{ {
GLint count;
glGetIntegerv(GL_NUM_EXTENSIONS, &count); glGetIntegerv(GL_NUM_EXTENSIONS, &count);
for (i = 0; i < count; i++) for (int i = 0; i < count; i++)
printf(" %s\n", (const char*) glGetStringi(GL_EXTENSIONS, i)); printf(" %s\n", (const char*) glGetStringi(GL_EXTENSIONS, i));
} }
else else
{ {
extensions = glGetString(GL_EXTENSIONS); const GLubyte* extensions = glGetString(GL_EXTENSIONS);
while (*extensions != '\0') while (*extensions != '\0')
{ {
putchar(' '); putchar(' ');
@@ -211,49 +210,31 @@ static void list_context_extensions(int client, int major, int minor)
static void list_vulkan_instance_extensions(void) static void list_vulkan_instance_extensions(void)
{ {
uint32_t i, ep_count = 0;
VkExtensionProperties* ep;
printf("Vulkan instance extensions:\n"); printf("Vulkan instance extensions:\n");
if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL) != VK_SUCCESS) uint32_t ep_count;
return; vkEnumerateInstanceExtensionProperties(NULL, &ep_count, NULL);
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep);
ep = calloc(ep_count, sizeof(VkExtensionProperties)); for (uint32_t i = 0; i < ep_count; i++)
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
if (vkEnumerateInstanceExtensionProperties(NULL, &ep_count, ep) != VK_SUCCESS)
{
free(ep);
return;
}
for (i = 0; i < ep_count; i++)
printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion);
free(ep); free(ep);
} }
static void list_vulkan_instance_layers(void) static void list_vulkan_instance_layers(void)
{ {
uint32_t i, lp_count = 0;
VkLayerProperties* lp;
printf("Vulkan instance layers:\n"); printf("Vulkan instance layers:\n");
if (vkEnumerateInstanceLayerProperties(&lp_count, NULL) != VK_SUCCESS) uint32_t lp_count;
return; vkEnumerateInstanceLayerProperties(&lp_count, NULL);
VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties));
vkEnumerateInstanceLayerProperties(&lp_count, lp);
lp = calloc(lp_count, sizeof(VkLayerProperties)); for (uint32_t i = 0; i < lp_count; i++)
if (vkEnumerateInstanceLayerProperties(&lp_count, lp) != VK_SUCCESS)
{ {
free(lp); printf(" %s (spec version %u) \"%s\"\n",
return;
}
for (i = 0; i < lp_count; i++)
{
printf(" %s (v%u) \"%s\"\n",
lp[i].layerName, lp[i].layerName,
lp[i].specVersion >> 22, lp[i].specVersion >> 22,
lp[i].description); lp[i].description);
@@ -264,49 +245,31 @@ static void list_vulkan_instance_layers(void)
static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device) static void list_vulkan_device_extensions(VkInstance instance, VkPhysicalDevice device)
{ {
uint32_t i, ep_count;
VkExtensionProperties* ep;
printf("Vulkan device extensions:\n"); printf("Vulkan device extensions:\n");
if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL) != VK_SUCCESS) uint32_t ep_count;
return; vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, NULL);
VkExtensionProperties* ep = calloc(ep_count, sizeof(VkExtensionProperties));
vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep);
ep = calloc(ep_count, sizeof(VkExtensionProperties)); for (uint32_t i = 0; i < ep_count; i++)
printf(" %s (spec version %u)\n", ep[i].extensionName, ep[i].specVersion);
if (vkEnumerateDeviceExtensionProperties(device, NULL, &ep_count, ep) != VK_SUCCESS)
{
free(ep);
return;
}
for (i = 0; i < ep_count; i++)
printf(" %s (v%u)\n", ep[i].extensionName, ep[i].specVersion);
free(ep); free(ep);
} }
static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device) static void list_vulkan_device_layers(VkInstance instance, VkPhysicalDevice device)
{ {
uint32_t i, lp_count;
VkLayerProperties* lp;
printf("Vulkan device layers:\n"); printf("Vulkan device layers:\n");
if (vkEnumerateDeviceLayerProperties(device, &lp_count, NULL) != VK_SUCCESS) uint32_t lp_count;
return; vkEnumerateDeviceLayerProperties(device, &lp_count, NULL);
VkLayerProperties* lp = calloc(lp_count, sizeof(VkLayerProperties));
vkEnumerateDeviceLayerProperties(device, &lp_count, lp);
lp = calloc(lp_count, sizeof(VkLayerProperties)); for (uint32_t i = 0; i < lp_count; i++)
if (vkEnumerateDeviceLayerProperties(device, &lp_count, lp) != VK_SUCCESS)
{ {
free(lp); printf(" %s (spec version %u) \"%s\"\n",
return;
}
for (i = 0; i < lp_count; i++)
{
printf(" %s (v%u) \"%s\"\n",
lp[i].layerName, lp[i].layerName,
lp[i].specVersion >> 22, lp[i].specVersion >> 22,
lp[i].description); lp[i].description);
@@ -352,13 +315,11 @@ static GLADapiproc glad_vulkan_callback(const char* name, void* user)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
int ch, client, major, minor, revision, profile; int ch;
GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits; bool list_extensions = false, list_layers = false;
int list_extensions = GLFW_FALSE, list_layers = GLFW_FALSE;
GLenum error;
GLFWwindow* window;
enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG, FORWARD, HELP, EXTENSIONS, LAYERS, enum { CLIENT, CONTEXT, BEHAVIOR, DEBUG_CONTEXT, FORWARD, HELP,
EXTENSIONS, LAYERS,
MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION, MAJOR, MINOR, PROFILE, ROBUSTNESS, VERSION,
REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS, REDBITS, GREENBITS, BLUEBITS, ALPHABITS, DEPTHBITS, STENCILBITS,
ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS, ACCUMREDBITS, ACCUMGREENBITS, ACCUMBLUEBITS, ACCUMALPHABITS,
@@ -369,7 +330,7 @@ int main(int argc, char** argv)
{ "behavior", 1, NULL, BEHAVIOR }, { "behavior", 1, NULL, BEHAVIOR },
{ "client-api", 1, NULL, CLIENT }, { "client-api", 1, NULL, CLIENT },
{ "context-api", 1, NULL, CONTEXT }, { "context-api", 1, NULL, CONTEXT },
{ "debug", 0, NULL, DEBUG }, { "debug", 0, NULL, DEBUG_CONTEXT },
{ "forward", 0, NULL, FORWARD }, { "forward", 0, NULL, FORWARD },
{ "help", 0, NULL, HELP }, { "help", 0, NULL, HELP },
{ "list-extensions", 0, NULL, EXTENSIONS }, { "list-extensions", 0, NULL, EXTENSIONS },
@@ -460,7 +421,7 @@ int main(int argc, char** argv)
} }
break; break;
case 'd': case 'd':
case DEBUG: case DEBUG_CONTEXT:
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
break; break;
case 'f': case 'f':
@@ -623,7 +584,7 @@ int main(int argc, char** argv)
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE); glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
window = glfwCreateWindow(200, 200, "Version", NULL, NULL); GLFWwindow* window = glfwCreateWindow(200, 200, "Version", NULL, NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();
@@ -633,17 +594,17 @@ int main(int argc, char** argv)
glfwMakeContextCurrent(window); glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress); gladLoadGL(glfwGetProcAddress);
error = glGetError(); const GLenum error = glGetError();
if (error != GL_NO_ERROR) if (error != GL_NO_ERROR)
printf("*** OpenGL error after make current: 0x%08x ***\n", error); printf("*** OpenGL error after make current: 0x%08x ***\n", error);
// Report client API version // Report client API version
client = glfwGetWindowAttrib(window, GLFW_CLIENT_API); const int client = glfwGetWindowAttrib(window, GLFW_CLIENT_API);
major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR); const int major = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MAJOR);
minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR); const int minor = glfwGetWindowAttrib(window, GLFW_CONTEXT_VERSION_MINOR);
revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION); const int revision = glfwGetWindowAttrib(window, GLFW_CONTEXT_REVISION);
profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE); const int profile = glfwGetWindowAttrib(window, GLFW_OPENGL_PROFILE);
printf("%s context version string: \"%s\"\n", printf("%s context version string: \"%s\"\n",
get_api_name(client), get_api_name(client),
@@ -735,6 +696,8 @@ int main(int argc, char** argv)
printf("%s framebuffer:\n", get_api_name(client)); printf("%s framebuffer:\n", get_api_name(client));
GLint redbits, greenbits, bluebits, alphabits, depthbits, stencilbits;
if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE) if (client == GLFW_OPENGL_API && profile == GLFW_OPENGL_CORE_PROFILE)
{ {
glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
@@ -809,21 +772,28 @@ int main(int argc, char** argv)
if (glfwVulkanSupported()) if (glfwVulkanSupported())
{ {
uint32_t i, re_count, pd_count;
const char** re;
VkApplicationInfo ai = {0};
VkInstanceCreateInfo ici = {0};
VkInstance instance;
VkPhysicalDevice* pd;
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL); gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, NULL);
re = glfwGetRequiredInstanceExtensions(&re_count); uint32_t loader_version = VK_API_VERSION_1_0;
if (vkEnumerateInstanceVersion)
{
uint32_t version;
if (vkEnumerateInstanceVersion(&version) == VK_SUCCESS)
loader_version = version;
}
printf("Vulkan loader API version: %i.%i\n",
VK_VERSION_MAJOR(loader_version),
VK_VERSION_MINOR(loader_version));
uint32_t re_count;
const char** re = glfwGetRequiredInstanceExtensions(&re_count);
printf("Vulkan required instance extensions:"); printf("Vulkan required instance extensions:");
if (re) if (re)
{ {
for (i = 0; i < re_count; i++) for (uint32_t i = 0; i < re_count; i++)
printf(" %s", re[i]); printf(" %s", re[i]);
putchar('\n'); putchar('\n');
} }
@@ -836,18 +806,24 @@ int main(int argc, char** argv)
if (list_layers) if (list_layers)
list_vulkan_instance_layers(); list_vulkan_instance_layers();
ai.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; VkApplicationInfo ai = { VK_STRUCTURE_TYPE_APPLICATION_INFO };
ai.pApplicationName = "glfwinfo"; ai.pApplicationName = "glfwinfo";
ai.applicationVersion = GLFW_VERSION_MAJOR; ai.applicationVersion = VK_MAKE_VERSION(GLFW_VERSION_MAJOR,
ai.pEngineName = "GLFW"; GLFW_VERSION_MINOR,
ai.engineVersion = GLFW_VERSION_MAJOR; GLFW_VERSION_REVISION);
if (loader_version >= VK_API_VERSION_1_1)
ai.apiVersion = VK_API_VERSION_1_1;
else
ai.apiVersion = VK_API_VERSION_1_0; ai.apiVersion = VK_API_VERSION_1_0;
ici.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; VkInstanceCreateInfo ici = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
ici.pApplicationInfo = &ai; ici.pApplicationInfo = &ai;
ici.enabledExtensionCount = re_count; ici.enabledExtensionCount = re_count;
ici.ppEnabledExtensionNames = re; ici.ppEnabledExtensionNames = re;
VkInstance instance = VK_NULL_HANDLE;
if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS) if (vkCreateInstance(&ici, NULL, &instance) != VK_SUCCESS)
{ {
glfwTerminate(); glfwTerminate();
@@ -856,32 +832,22 @@ int main(int argc, char** argv)
gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance); gladLoadVulkanUserPtr(NULL, glad_vulkan_callback, instance);
if (vkEnumeratePhysicalDevices(instance, &pd_count, NULL) != VK_SUCCESS) uint32_t pd_count;
{ vkEnumeratePhysicalDevices(instance, &pd_count, NULL);
vkDestroyInstance(instance, NULL); VkPhysicalDevice* pd = calloc(pd_count, sizeof(VkPhysicalDevice));
glfwTerminate(); vkEnumeratePhysicalDevices(instance, &pd_count, pd);
exit(EXIT_FAILURE);
}
pd = calloc(pd_count, sizeof(VkPhysicalDevice)); for (uint32_t i = 0; i < pd_count; i++)
if (vkEnumeratePhysicalDevices(instance, &pd_count, pd) != VK_SUCCESS)
{
free(pd);
vkDestroyInstance(instance, NULL);
glfwTerminate();
exit(EXIT_FAILURE);
}
for (i = 0; i < pd_count; i++)
{ {
VkPhysicalDeviceProperties pdp; VkPhysicalDeviceProperties pdp;
vkGetPhysicalDeviceProperties(pd[i], &pdp); vkGetPhysicalDeviceProperties(pd[i], &pdp);
printf("Vulkan %s device: \"%s\"\n", printf("Vulkan %s device: \"%s\" (API version %i.%i)\n",
get_device_type_name(pdp.deviceType), get_device_type_name(pdp.deviceType),
pdp.deviceName); pdp.deviceName,
VK_VERSION_MAJOR(pdp.apiVersion),
VK_VERSION_MINOR(pdp.apiVersion));
if (list_extensions) if (list_extensions)
list_vulkan_device_extensions(instance, pd[i]); list_vulkan_device_extensions(instance, pd[i]);

Some files were not shown because too many files have changed in this diff Show More