Commit Graph

16 Commits

Author SHA1 Message Date
Camilla Löwy
bb951b4b71 Use C99 fminf and fmaxf 2024-02-12 22:50:25 +01:00
Camilla Löwy
8e6c8d7eff Remove reminders to use C89 for some source files
This is part of removing support for VS versions older than VS 2013.
See #2465 for details and feedback.

Related to #2465
2024-01-15 20:17:18 +01:00
Camilla Löwy
56a4cb0a3a Add runtime platform selection
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 #1655
Closes #1958
2021-10-13 21:47:11 +02:00
Camilla Löwy
22b586b3d8 Add pluggable heap allocator
This adds the glfwInitAllocator function for specifying a custom memory
allocator to use instead of the C runtime library.

The allocator is a struct of type GLFWallocator with fields
corresponding to malloc, realloc and free, while the internal API
corresponds to calloc, realloc and free.

Heap allocation calls are filtered before reaching the user-provided
functions, so deallocation of NULL and allocations of zero bytes are not
passed on, reallocating NULL is transformed into an allocation and
reallocating to size zero is transformed into deallocation.

The clearing of a new block to zero is performed by the internal
calloc-like function.

Closes #544.
Fixes #1628.
Closes #1947.
2021-08-25 21:00:10 +02:00
Camilla Löwy
cd0dc76c7c Null: Fix out parameters not being set
It turns out platform functions are sometimes called directly instead of
going through the public wrapper.
2020-08-19 19:31:55 +02:00
Camilla Löwy
6c031af245 Null: Fix typos in workarea retrieval 2020-07-13 19:43:13 +02:00
Camilla Löwy
e0c77f71f9 Null: Make platform more conformant
This makes the null platform behave more like an actual stub.  More
queryable state is tracked and there is even a fake monitor with one
whole fake video mode.
2020-06-02 22:40:09 +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
a337c56848 Start 3.4 2019-04-16 23:08:39 +02:00
Camilla Löwy
ab118b2529 Fix copyright years (somewhat) 2019-04-15 20:50:00 +02:00
Camilla Löwy
0118743333 Formatting
Related to #1322.
2019-03-05 16:58:45 +01:00
Felipe Ferreira da Silva
be295ccbea Add glfwGetMonitorWorkarea
This function retrieves the work area rectangle of the specified
monitor.

Related to #920.
Closes #989.
2019-03-05 16:10:59 +01:00
Camilla Löwy
52c7a4fc7f Fix glfwGetGammaRamp error handling
This makes glfwGetGammaRamp return NULL on platform error as specified.

Related to #1387.
2018-12-26 15:00:39 +01:00
Emmanuel Gil Peyrot
8d98a6e37d Add a FreeMonitor platform API
This fixes the leak of a wl_output object everytime a monitor is freed.
2018-03-01 08:31:54 +01:00
Camilla Löwy
16bf872117 Add content scale queries
This adds glfwGetWindowContentScale and glfwGetMonitorContentScale for
querying the recommended drawing scale factor for DPI-aware rendering.

Parts of this patch are based on code by @ferreiradaselva.

Fixes #235.
Fixes #439.
Fixes #677.
Fixes #845.
Fixes #898.
2017-10-26 17:26:36 +02:00
Camilla Löwy
53f46d32e2 Make OSMesa backend an almost proper null backend
It still depends on POSIX time and TLS.
2017-02-28 21:57:43 +01:00