Commit graph

515 commits

Author SHA1 Message Date
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
Stephen Gutekanst
fc6ac619c3 glfw: make setMouseButtonCallback use Mods bitmask directly
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
4241da22ed glfw: add Hat.toInt / Hat.fromInt tests, fix bug
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
987d52e6f9 glfw: make Hat.fromInt, Hat.toInt work on non-5-bit integers
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
bb18c20e00 glfw: fix failing Mod bitmask tests, make fromInt/toInt work on non-6-bit integers
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
36bbd817af glfw: make Window.setKeyCallback use Mods packed struct directly
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
7b5caa5d7c glfw: glfw.mod.Mods -> glfw.Mods, etc. & fix test compilation
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
2c03f286ee glfw: ziggify Joystick hat bitmasks
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
64b50ebd56 glfw: ziggify gamepad button enumerations
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
9f40ee4441 glfw: ziggify gamepad action enumerations
Helps hexops/mach#37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-30 20:06:03 -07:00
Stephen Gutekanst
18226db9fd glfw: ziggify all Action enums
Make the GLFW action enumerations proper Zig enums so one can use `.Name` syntax, etc.

Helps #37

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 21:27:20 -07:00
Stephen Gutekanst
cc4595eb37 glfw: improve panic message for glfw.getInstanceProcAddress
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 17:13:21 -07:00
Stephen Gutekanst
6aaf0b7a68 glfw: make glfw.getProcAddress conform to GLFW C ABI
Having `glfw.getProcAddress` conform to the GLFW C ABI is important as it is often
likely to be passed into libraries which expect exactly that ABI for OpenGL function
loading.

Fixes hexops/mach#52

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 17:13:21 -07:00
Stephen Gutekanst
457c9394ab glfw: make glfw.getInstanceProcAddress conform to GLFW C ABI
Having `glfw.getInstanceProcAddress` conform to the GLFW C ABI is important as it is often
likely to be passed into libraries which expect exactly that ABI, e.g. zig-vulkan.

Fixes hexops/mach#49

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 16:15:42 -07:00
Stephen Gutekanst
058443c3da glfw: workaround framework dependency inclusion bug for now
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 12:31:28 -07:00
Stephen Gutekanst
59f23242d9 glfw: CI: update to latest Zig nightly 1444+e2a2e6c14
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-29 12:31:28 -07:00
Stephen Gutekanst
0f5de6d435 glfw: do not set sysroot (prevents linking libs not in our system SDKs) (#47)
* glfw: do not set sysroot (prevents linking libs not in our system SDKs)

Fixes hexops/mach#40

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 21:14:13 -07:00
Stephen Gutekanst
94f530b3f1 glfw: add intermediate static lib
Previously, @Avokadoen and @mattnite ran into issues including the GLFW library
in other projects, e.g. https://github.com/Avokadoen/zig_vulkan/issues/17

In #24 we removed the intermediate static library, which solved the issue. The
problem is that when the function is invoked in the directory of the project
including GLFW, then our code:

```
const lib = b.addStaticLibrary("glfw", "src/main.zig");
```

Would refer to the project's `src/main.zig` -- not the GLFW library `main.zig`.

Although removing the intermediate lib worked around the issue, it created a
new one - slower compilation: hexops/mach#31

This fixes the issue by ensuring that the path we pass to `addStaticLibrary` is
in fact absolute, not relative.

Fixes hexops/mach#31

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 13:55:52 -07:00
Stephen Gutekanst
77cf3dd85c glfw: build: eliminate duplicative arena allocator
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 13:42:20 -07:00
Stephen Gutekanst
91e80234bb glfw: correct clipboard test
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2021-10-24 08:55:26 -07:00