Commit graph

620 commits

Author SHA1 Message Date
Stephen Gutekanst
84382ee1fc glfw: update system SDKs for macOS 11 cross compilation
Fixes hexops/mach#108

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-29 21:24:22 -07:00
Stephen Gutekanst
116e79a49f glfw: CI: re-enable x86_64-macos -> aarch64-macos cross compilation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-29 21:24:22 -07:00
Stephen Gutekanst
a544741a50 glfw: do not pin SDK version when using custom dev SDK path
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-29 21:24:22 -07:00
InKryption
58e2632a4e glfw: Fix pointer cast
The GLFW implementation takes a constant pointer to a `VkAllocationCallbacks` struct; casting it to a mutable pointer equivalent here doesn't break anything, but does prevent passing a valid const pointer, which is often what one should prefer to do.
As well, the `@alignOf` builtin takes the alignment expected of the type directly, so `@alignOf(*T)` returns the alignment of `*T`, not `T`, so that has also been corrected.
2021-11-29 12:52:46 -07:00
Stephen Gutekanst
7465bb6e93 glfw: make system_sdk pin versions, auto-update
Prior to this change, an older commit of Mach or mach-glfw would use the latest
version of the native system SDKs, which would sometimes be incompatible. Better
is to ensure that we actually pin the revision we're using, so a given revision
of mach or mach-glfw is using a specific revision of the native SDKs.

Similarly, we previously had no mechanism for updating SDKs: it was either cloned,
or it wasn't. This introduces a simple `git fetch` prior to hard-resetting the SDK
to the target pinned revision - effectively giving us automatic updates for anyone
using an older revision.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-28 18:43:58 -07:00
Stephen Gutekanst
ea3b28efc7 glfw: rename system_sdk.Options.linux_x86_64_sdk for consistency
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-28 18:43:58 -07:00
Stephen Gutekanst
6910608980 glfw: correct Apple SDK license prompt
Prior to this the Apple SDK license agreement prompt would appear for 11.3 but
not 12.0 by accident. This fixes the issue.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-28 18:43:58 -07:00
Stephen Gutekanst
1e00183dd8 glfw: CI: disable x86_64-macos -> aarch64-macos cross compilation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-27 00:15:15 -07:00
Stephen Gutekanst
041cd7be2b glfw: update CI to latest Zig master version
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-27 00:15:15 -07:00
Stephen Gutekanst
cea8fd0dd3 Revert "glfw: patch GLFW sources to workaround a bug where Zig and Mach C headers conflict"
This reverts commit 7d47233d7a5a97241ad16a148c153831ce5d555d.

See hexops/mach#102
2021-11-27 00:15:15 -07:00
Stephen Gutekanst
95515eaf7c glfw: update system_sdk to match latest Zig master macOS version targeting
The latest Zig master supports specifying a specific macOS version for libc, via
the target triple (ziglang/zig#10215):

* x86_64-macos.10 (Catalina)
* x86_64-macos.11 (Big Sur)
* x86_64-macos.12 (Monterey)
* aarch64-macos.11 (Big Sur)
* aarch64-macos.12 (Monterey)

Mach's `system_sdk.zig` can now download the relevant XCode framework stubs
for Big Sur (11) and Monterey (12). Although we don't have an SDK for Catalina (10)
currently, we use the Big Sur (11) SDK in that case and it generally works fine.
By default, Zig targets the N-3 version (e.g. `x86_64-macos` defaults to `x86_64-macos.10`).

Targeting the minimum supported version is useful for compatability, it guarantees the produced
binary will run on any later macOS version. Targeting the newer version can be useful if you
wish to use newer APIs not available in previous versions.

Fixes hexops/mach#102

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-27 00:15:15 -07:00
Stephen Gutekanst
01ad3b836c glfw: support building with latest Zig master
This removes a linker hack which was preventing building with the latest
Zig master version. Of particular note, anyone wishing to use this library
will need to ensure they are up to date with latest master.

The binary releases available at https://ziglang.org/download/ (1783+eec825c and
beyond) are sufficient (really, anything released after today.)

Fixes hexops/mach#103

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-26 22:29:58 -07:00
InKryption
fcdc184167 glfw: un-hardcode constant
Make the constant extracted from GLFW source into `time.setTime`, into a better-documented set of comptime instructions
2021-11-26 22:13:47 -07:00
InKryption
9ec72fdb2c glfw: Eliminate Error.InvalidValue 2021-11-26 20:50:38 -07:00
InKryption
7c924700c4 glfw: run zig fmt 2021-11-24 05:14:48 -07:00
InKryption
403e1cc866 glfw: add runtime assertion to Window.setInputMode
Assertion to ensure that the value of 'mode' matches the type of 'value'
2021-11-24 05:14:48 -07:00
InKryption
2822b2862e glfw: Finalize removal of 'InvalidEnum' error 2021-11-24 05:14:48 -07:00
InKryption
23b662f438 glfw: Eliminate InvalidEnum 2021-11-24 05:14:48 -07:00
InKryption
4faa7783e6 glfw: add 'assertInitialized' 2021-11-23 12:12:55 -07:00
InKryption
11a3689cb7 glfw: make comment into doc comment 2021-11-23 12:12:55 -07:00
InKryption
6fbbba7c4c glfw: update possible errors comment
Add 'FormatUnavailable' as a possible error to the 'getClipboardString' comment, which can set it on wayland
2021-11-23 11:07:14 -07:00
InKryption
1f6b5258dc glfw: re-instate prong
Bring back the 'c.GLFW_NOT_INITIALIZED' prong in 'convertError', such that if it is ever passed that error code, we can differentiate it from just an invalid input; because it is a valid input, we just guarantee that it won't occur.
2021-11-23 11:06:19 -07:00
InKryption
e363bb0840 glfw: Change error unions into normal returns, in accordance with the new guarantee to never encounter 'GLFW_NOT_INITIALIZED', and update tests 2021-11-22 12:59:11 -07:00
InKryption
f55e083f05 glfw: enum-ify 'Joystick.jid', set 'InvalidEnum' as unreachable, and run zig fmt 2021-11-22 12:59:11 -07:00
InKryption
fa5f102b2a constify unmutated variables in build files 2021-11-22 12:59:11 -07:00
InKryption
946c059f10 glfw: amend and update various TODOs pertaining to force-init changes 2021-11-22 12:59:11 -07:00
InKryption
5c93c0fe22 glfw: assert initialized in proc address getter functions 2021-11-22 12:59:11 -07:00
InKryption
e3b00f0a7b glfw: fix for getClipboardString reaching unreachable prong on linux CI 2021-11-22 12:59:11 -07:00
InKryption
c7558b61eb glfw: Revert error denormalization 2021-11-22 12:59:11 -07:00
InKryption
db6b48e9e4 glfw: force init error type work around 2021-11-22 12:59:11 -07:00
InKryption
5466115d4d glfw: Remove 'NotInitialized' error 2021-11-22 12:59:11 -07:00
InKryption
400fba7401 glfw: force init in Window.zig 2021-11-22 12:59:11 -07:00
InKryption
ea757b077f glfw: force init in vulkan.zig 2021-11-22 12:59:11 -07:00
InKryption
e05fe5e490 glfw: force init in time.zig 2021-11-22 12:59:11 -07:00
InKryption
0782243a12 glfw: force init in opengl.zig 2021-11-22 12:59:11 -07:00
InKryption
35c27a1d18 glfw: force init in Monitor.zig 2021-11-22 12:59:11 -07:00
InKryption
de0f8aceb3 glfw: force init in Joystick.zig 2021-11-22 12:59:11 -07:00
InKryption
9658c47018 glfw: force init in key.zig 2021-11-22 12:59:11 -07:00
InKryption
2096bb2056 glfw: force init in main.zig 2021-11-22 12:59:11 -07:00
InKryption
6346d1089b glfw: force init in Cursor.zig 2021-11-22 12:59:11 -07:00
InKryption
16492eb794 glfw: force init in clipboard.zig 2021-11-22 12:59:11 -07:00
InKryption
8a0233dd7d glfw: force init before using init dependent functions 2021-11-22 12:59:11 -07:00
Stephen Gutekanst
3726fe98dc glfw: patch GLFW sources to workaround a bug where Zig and Mach C headers conflict
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-21 12:31:55 -07:00
Stephen Gutekanst
5aa3e2a66e glfw: update system_sdk to use latest MacOS 12.0 SDK
Updates us to using the newer SDK https://github.com/hexops/sdk-macos-12.0

Also enables cross-compilation of the `mach/gpu` backend for macOS.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-21 12:31:55 -07:00
InKryption
fe1d10f03f glfw: window hint default values parity test with attributes (#81)
* glfw: window hint default values parity test with attributes
* glfw: add test-mode-only variable that controls whether to set or ignore the `Window.Hints` struct passed to `Window.create`, and inline `failedToCreateWindow`
* glfw: include `context_no_error` hint/attribute in test with comment, fix oversight in `create` concerning the `defer defaultHints()` statement

Co-authored-by: Stephen Gutekanst <stephen.gutekanst@gmail.com>
2021-11-20 12:42:52 -07:00
InKryption
8e062b63cb glfw: further reorganize Window.Attrib to match with Window.Hint. 2021-11-17 09:33:53 -07:00
InKryption
e35c44bb2f glfw: reorganize Window.Attrib to be in the same style as Window.Hint 2021-11-17 09:33:53 -07:00
InKryption
802ec78b68 glfw: make glfw.Cursor.Shape public
Following a similar change made to types in 'Window.zig'
2021-11-16 19:33:24 -07:00
Silver
f0dd193695 glfw: remove [*c] pointers from api and return lengthed strings when possible 2021-11-16 07:12:02 -07:00
InKryption
23c922f0a4 glfw: window hints rework (#71)
* glfw: make comments into doc comments
* glfw: Publicize Window.CursorPos, Window.Size, Window.Pos, and Window.FrameSize
* glfw: Make enum value name the same format as other enum value names
* glfw: Window hints rework patch
* glfw: Relegate `Window.hint` to testing; move it down to just above the tests to reflect this, add doc comment line
* glfw: handle error `Error.InvalidEnum` explicitly, for clear error message in this unlikely edge case
* glfw: instate `Hint.context_no_error` as a hint, as it actually is specified to be a Window creation hint by the docs, and affirm removal of `Hint.context_revision`, which isn't.
The docs don't seem to specify a default value for `Hints.context_no_error` to take on, so we could set it based on `std.debug.runtime_safety` like this.
* glfw: default `context_no_error` to `false`, and added a note of caution about its usage as suggested.
* glfw: Inline enum values of `ClientApi`, `ContextCreationApi`, `ContextRobustness`, `ContextReleaseBehavior`, and `OpenGlProfile` from consts.zig, and remove the now unused constants (replaced by aformentioned enum values).
* glfw: Reference `Window.Hint` enum instead of `Window.Hints` struct to ensure fields are the same
* glfw: add comment explaining default values of `Window.Hints`
* glfw: change `OpenGlProfile` to `OpenGLProfile` based on established naming convention
* glfw: Update actual declaration of `OpenGLProfile`
* glfw: call `Window.defaultHints` after window creation, not before
* glfw: remove 'consts.zig', and move `dont_care` directly into 'main.zig'; fix anything referencing it.
* glfw: put `Window.defaultHints` into defer statement to handle cleanup in all paths
* glfw: move `Hint.focused` to match position of `Hints.focused`
* glfw: do 'zig fmt glfw/src'
* glfw: Cull `Window.Hint` comments, polish remaining; match order entirely according to current GLFW docs
* glfw: Change `Window.Hints.*Api` to `Window.Hints.*API`

Co-authored-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-15 18:41:16 -07:00