The conversion of window icon image data involves unsigned char color
values being promoted to int and then shifted to the left by 24. For
32-bit ints this is just far enough to trigger undefined behavior.
It worked by accident because of how current compilers translate this
piece of code.
This was caught by @slimsag while working on [Zig bindings for GLFW][1],
and diagnosed together with @Andoryuuta, as described [in an
article][2]. Zig has UBSan enabled by default, which caught this
undefined behavior.
[1]: https://github.com/hexops/mach-glfw
[2]: https://devlog.hexops.com/2021/perfecting-glfw-for-zig-and-finding-undefined-behavior#finding-lurking-undefined-behavior-in-6-year-old-glfw-code
Thanks to Maato, martinhath, dcousens, drfuchs and Validark for helping
to refine the solution.
This commit message was rewritten by @elmindreda to hopefully reflect
the conclusions of the pull request thread.
Related to hexops/mach#20
Closes#1986
This docstring previously indicated that GLFW_CONTEXT_REVISION was
a window hint and attribute, but in fact it is only a window attribute
(there is no code which uses this constant in any other context.)
We noticed this in https://github.com/hexops/mach/pull/71/files#r749741814Closes#1992
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Add GLFW_FORMAT_UNAVAILABLE to the list of possible errors in the
reference documentation for glfwGetClipboardString.
Slightly edited by @elmindreda.
Closes#1998
Looking into the definition of kIOMainPortDefault, the following
description can be found:
When specifying a main port to IOKit functions, the NULL argument
indicates "use the default". This is a synonym for NULL, if you'd
rather use a named constant.
Thus, we do not have to utilize an external symbol for the identifier
of the default main IOKit port, but MACH_PORT_NULL suffice. This
simplifies compatibility between macOS versions as the symbol was
renamed with macOS 12.0.
Fixes#1985Closes#1994
This removes the GLFW_VULKAN_STATIC CMake option and the
_GLFW_VULKAN_STATIC configuration macro and replaces them with the
glfwInitVulkanLoader function, allowing a single library binary to
provide both behaviors.
This is based on the design from PR #1374 by @pmuetschard.
Closes#1374Closes#1890
This removes the global struct member for
vkEnumerateInstanceExtensionProperties, which is only used in the same
function that fetches the function from the loader.
The pattern is now more in line with how other single uses of Vulkan
functions are structures, such as window surface creation.
C does not allow conversions between data pointers and function
pointers.
Yes, the name of the macro is reserved. That's something for a future
commit to fix.
Fixes#1703
This hack breaks when switching a window to fullscreen, if the OpenGL
ICD detects this and switches its swapchain to exclusive mode.
This limits the hack to Windows Vista and 7. This hack was added
because of vsync jitter under DWM on Windows 7 and I have been unable
to reproduce it on any later version.
Is this change causing any problems on any version of Windows? Please
open an issue!
Fixes#1072
The GLFW_INCLUDE_GLCOREARB branch was left out when GLFW_INCLUDE_GLEXT
was originally added, for reasons that are lost to history. The current
versions of these headers seem to co-exist just fine.
Issue reported on IRC.
This more or less restores the original custom layout where the TOC is
on the right side, with a CSS workaround added for portrait orientation.
The indentation of sub-lists in the TOC has been decreased.
The sizes of HTML headings and the "h0" div generated for each Doxygen
page have been adjusted to look better together now that they can meet.
A few headings have been shortened to fit better in the narrower TOC.
This was especially bad in the window guide, where the TOC ended up
having "Window related hints" and "Windows specific window hints" close
to one another.
This commit only fixes headings. There are likely issues in the actual
text as well.
This adds compile-time support for multiple platforms and runtime
detection of them. Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.
The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time. These
functions are the same for any backend on a given OS, including the Null
backend.
The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names. There is no longer any option for the Null backend as it
is now always enabled.
Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.
Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding. Calls to these are now routed through
the _glfw.platform struct member. These changes makes up most of this
commit.
For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server. The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.
Closes#1655Closes#1958
The performance counter API is guaranteed to succeed on Windows XP and
later so there is no need for a fallback.
This removes our last dependency on winmm.
These headers come from when GLFW only supported a single context
creation API at a time, chosen at compile-time.
Since EGL and OSMesa are now always enabled and the platform-specific
APIs are tied to their specific window system, there is no reason to
keep these declarations separate from the internal.h and *_platform.h
header files.
This is done in preparation for runtime platform selection, to make sure
every platform can build with EGL enabled.
It may be possible to add support for things like the ANGLE null
platform later.
The native access functions for context handles did not verify that the
context had been created with the same API the function was for.
This makes these functions emit GLFW_NO_WINDOW_CONTEXT on API mismatch.