New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLFW v3.4 #400
base: master
Are you sure you want to change the base?
GLFW v3.4 #400
Conversation
Thanks for working on this.
It's not much, but there are two small example programs in https://github.com/go-gl/example. Out of the box, it fails to link on GOOS=darwin GOARCH=arm64 with:
That doesn't happen if this line is added to #include "glfw/src/cocoa_time.c"
+#include "glfw/src/posix_module.c"
#include "glfw/src/posix_thread.c" And with that at least basic functionality seems to work okay on macOS. |
I'll go ahead and try these then.
Cool I'll add this in. By the way, does this fix #272 for you? I think the upstream fix is included in GLFW v3.4. |
Forgot to mention, @dmitshur can you test with |
Without the changes in #399 (and also defining I can replicate the same gles1 and gles3 failures on Fedora 40 (Wayland and X11) but I get the same error on v3.3 so that's fine? Compiling with Isn't Glfw v3.4 supposed to be able to switch between Wayland and X11 at runtime? If that is the case, should we enable that by default? Maybe have x11 and wayland tags for when you only want a single backend? |
I can define
I think it's fine too. To my understanding, GLES v1 & v3 are just different implementations of the OpenGL spec. So, it's probably good keeping them in, but they might be hard to test on bleeding edge distros like Arch and Fedora. Also, I believe
I think it's best to keep X11 as the default to make the transition easier from v3.3 to v3.4, but if GLFW can now choose Wayland or X11 at runtime, maybe we can add support for this when both |
I just pushed support for applying both X11 & Wayland on Linux with (-tags x11,wayland). I will add to BSD later, but I want to get the build working standalone on BSD first. |
That won't make any difference as I was building on FreeBSD. The GOOS value for the native operating system is always added automatically and the same goes for GOARCH. If you build your app on Linux for example, you don't need to pass |
No, it is not an error in Fedora. It is a drawback of the solution. See #359, we need a better solution but right now that is better than not being able to compile. Implicit declarations are emitted (which is treated as an error on Fedora 40 due to stricter security settings) if your don't force _GNU_SOURCE to on but if you do, you get a warning that it is defined twice.
I'm not personally of doing that approach. Wayland is the future and I think we should enable the runtime switching support if we can. However, it is up to @dmitshur at the end of the day. |
Yes, this is a warning due to the manual definition inside GLFW source code. I don't understand why it's defined without a |
// GLFW Options: | ||
#cgo linux,!wayland CFLAGS: -D_GLFW_X11 | ||
#cgo linux,x11 CFLAGS: -D_GLFW_X11 | ||
#cgo linux,wayland CFLAGS: -D_GLFW_WAYLAND |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment on top, is it OK that _GNU_SOURCE
is now globally set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't want it set but I couldn't compile at all without it.
package glfw | ||
|
||
/* | ||
#cgo CFLAGS: -Iglfw/include -D_GNU_SOURCE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So then, _GNU_SOURCE
is now globally set?
@metal3d I think |
@Jacalz I completely agree, but this isn't about ideologies. This is about what is best for the users of this library.
I have added support for this on Linux like I said previously ( |
My point has nothing to do with ideologies. You are taking things out of context and I don't agree that being X11-only would be helpful in the long run. Enabling Wayland-only by default would be stupid but supporting dynamic switching between the two is a good compromise that we should try to make use of now that we can. Enabling runtime switching by default is the best path forward given how quickly Wayland is getting adopted and some distros like Fedora are even disabling Xorg support (XWayland works yes, but you see the direction we are heading). Making the switch to enable Wayland support by default now is going to be the better option as a future-proof setting and that switch will be much harder to make down the line. Remember that v3.4 is an entirely new module import and it would be problematic to suddenly enable Wayland support and require an extra dependency when compiling later in the lifecycle of that existing in the repository. If we are to stay up to date with the times, that support needs to be enabled from the start. If you still want to have X11-only, I see no reason why people can't still use v3.3 given that it still will be maintained some time forward. We have seen in Fyne that the community cares very much for Wayland support to be enabled and Flathub even marks an X11-only application as unsafe nowadays (https://flathub.org/apps/io.github.jacalz.rymdport). Having dynamic runtime switching gets us both X11 and Wayland support and a lot more people will actually use it instead of having to enable an obscure build tag combination. |
Hey @Geo25rey, given that Mac --> opengl32 is checked here, I tried building on an M3 with:
And then running I had to comment out:
in v3.4/glfw/testdata/customcursor/main.go:36, as it was complaining about Cocoa:
Given the above being commented out, the mouse passthrough I was looking for worked (with floating), after adding the Hint to |
@J7mbo Thx for testing this out according to LWJGL/lwjgl3#695, this commit glfw/glfw@9a87c2a introduced 2 new errors affecting macOS and Wayland, so I think we should pass both |
@J7mbo I just looked at your issue #375 (comment) and it looks like all the hints are out of date or have out of date descriptions so I will add them from here https://www.glfw.org/docs/3.4/window_guide.html#window_hints_wnd |
Overview
This is a rough implementation of go-glfw using GLFW v3.4. I have done some basic testing on Linux Wayland and XWayland. I highly recommend reviewing by commit considering the nature and size of this PR.
I am also looking for people to test the builds and functionality on the various platforms listed below. I can personally continue testing on Linux and if I have extra time, MacOS Arm.
Closes: #393
Potentially fixes: #272 @dmitshur
Requesting Review from: @Jacalz
Rundown by commit
C.glfwSetWindowIcon()
under a Wayland environment because it's not supportedTesting
Preamble
I used the short Custom Cursor program for testing. It would probably be a good idea to test with other programs, as well. Does anyone have such test programs?
It is especially important to get more test programs for Wayland since more features than just setting the window icon are not supported by GLFW and/or the Wayland protocols yet, and I'm not sure of other implications of the SIGABRT behavior previously mentioned. For example, I could dynamically add some element to my window at runtime, which could crash my program with a cryptic abort message with no other context. At best, developers using go-glfw can report it here, and at worst a subset of users will report the issue to downstream projects that use go-glfw and the downstream developers may not know what to do with the error message.
cd v3.4/glfw; go run
testdata/customcursor/main.go
-tags linux,wayland
)-tags linux,wayland,gles1
)-tags linux,wayland,gles2
)-tags linux,wayland,gles3
)-tags linux,wayland,vulkan
)-tags linux
)-tags linux,gles1
)-tags linux,gles2
)-tags linux,gles3
)-tags linux,vulkan
)-tags freebsd,wayland
)-tags freebsd
)-tags netbsd,wayland
)-tags netbsd
)-tags openbsd
)-tags darwin
)-tags darwin,gles2
)-tags darwin
)-tags darwin,gles2
)-tags windows
)-tags windows,gles2
)-tags windows
)-tags windows,gles2
)