Commit graph

584 commits

Author SHA1 Message Date
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
Ali Chraghi
da3e76eff1 glfw: fix typo prevents building for Wayland 2021-11-15 17:49:13 -07:00
Stephen Gutekanst
b967fd5e91 glfw: update setIcon hotfix for undefined behavior
See https://github.com/GLFW/glfw/pull/1986

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-16 00:22:45 +00:00
Silver
de499c2b76 glfw: patch more undefined behaviour
See glfw/glfw#1989
2021-11-15 16:22:39 -07:00
Ali Chraghi
80e609b0cb Update README.md 2021-11-15 16:14:38 -07:00
InKryption
e183711e5e glfw: Make enum value name the same format as other enum value names 2021-11-15 15:37:07 -07:00
InKryption
d91d9311ed glfw: Publicize Window.CursorPos, Window.Size, Window.Pos, and Window.FrameSize 2021-11-15 15:37:07 -07:00
InKryption
9bb3803657 glfw: make comments into doc comments 2021-11-15 15:37:07 -07:00
InKryption
ec9e770673 glfw: Update readme to reflect changes made to glfw.init 2021-11-10 11:42:24 -07:00
InKryption
82c5079d1d glfw: Update tests in all other files to reflect changes made to glfw.init 2021-11-10 11:42:24 -07:00
InKryption
025b91ecb0 glfw: change init function to accept hints as paramaters via new InitHints struct which has default field values reflecting the default values specified by GLFW current documentation, privatize hint-setting wrapper API, and update tests 2021-11-10 11:42:24 -07:00
Stephen Gutekanst
1d0d381f48 glfw: inform in PR template to send all PRs to main repository
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-07 20:57:31 -07:00
Stephen Gutekanst
e6084af0e5 glfw: send pull requests to the main repository to avoid merge conflicts
When changes are merged to both hexops/mach and hexops/mach-glfw, we get a conflict
which is difficult to resolve with `git subtree`, particularly because we don't want
to squash commits for either repository (we prefer to maintain the full commit history
in both repos.)

Instead, require that all pull requests be sent to the main hexops/mach repository.
That's not as nice, I admit, but should be pretty easy to handle (literally just copy
changes over) and will ensure we can always keep both repos in sync easily and without
conflict.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-07 20:51:16 -07:00
Stephen Gutekanst
03fc8bc424 glfw: fix linking difference between sysroot and non-sysroot (#63)
This effectively gives us the dependencies we need in any case, and works around ziglang/zig#10103

Importantly, this removes a blocker for landing WebGPU support in hexops/mach#62

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-11-07 17:38:06 -07:00
Noora Heinsuo
fd131c83a9
Fix code example (#1) 2021-11-03 20:13:39 -07:00
Stephen Gutekanst
f340d04eca glfw: hot patch undefined behavior in GLFW that went unnoticed 6+ years
Upstream pull request: https://github.com/glfw/glfw/pull/1986

Article: https://devlog.hexops.com/2021/perfecting-glfw-for-zig-and-finding-undefined-behavior

Fixes hexops/mach#20

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-31 11:50:09 -07:00
Stephen Gutekanst
96cb20e9e8 glfw: add Vulkan example to README
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-31 01:14:46 -07:00
Stephen Gutekanst
1ec1b7dfc4 glfw: zig fmt
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-31 01:00:56 -07:00
Stephen Gutekanst
b87ef62856 glfw: improve ABI compatability with zig-vulkan library
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-31 01:00:02 -07:00
Stephen Gutekanst
4e93fbddd1 glfw: expose system SDK build options
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:47:48 -07:00
Stephen Gutekanst
e752666062 glfw: refactor system SDK inclusion into helper file
This refactors the logic for system SDK inclusion out of the GLFW-specific `build.zig`,
and should make it very easy for anyone to copy this file and start getting cross-platform
builds of their own OpenGL/Vulkan Zig projects.

There may be some libraries we need to add for Vulkan to these SDKs, I haven't yet tested
that - but the overall idea here seems sound.

Fixes hexops/mach#39

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:31:52 -07:00
Stephen Gutekanst
f0a71f53a4 glfw: update README, send pull requests to the main repo if possible
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:23:17 -07:00
Stephen Gutekanst
3b231b7456 glfw: improve README, add getting started, error handling, etc
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 21:23:17 -07:00
Stephen Gutekanst
b96fd437a3 glfw: make init hints a proper enum
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
30abe0c960 glfw: make monitor/joystick events a proper enum
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
2f84bac544 glfw: add [set|get]InputModeRawMouseMotion variants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
27097fee9c glfw: add [set|get]InputModeLockKeyMods variants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
2f9772d36c glfw: add [set|get]InputModeStickyMouseButtons variants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
79fa9f2929 glfw: add setInputModeStickyKeys/getInputModeStickyKeys variants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
93200dbe00 glfw: add setInputModeCursor/getInputModeCursor variants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
be9bbe8f21 glfw: make mouse buttons a proper enum
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
9adc84f638 glfw: expose aliased gamepad axis/button constants
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
5b4743215d glfw: identify remaining constants for enumification
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
21fe561393 glfw: remove duplicated window hints (removed in 14964fa)
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
1158c52f0c glfw: make Window attributes a proper enum
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
1c8bb772c0 glfw: make Window hints a proper enum
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
d951a47348 glfw: make setKeyCallback use Key enum directly
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00