Skip to content
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

Update GLFW to 3.4 #3827

Merged
merged 10 commits into from
Feb 29, 2024
Merged

Update GLFW to 3.4 #3827

merged 10 commits into from
Feb 29, 2024

Conversation

M374LX
Copy link
Contributor

@M374LX M374LX commented Feb 25, 2024

As the title suggests, this PR updates GLFW to version 3.4.

It seems to work on Linux with both X11 and Wayland (tested on Weston), but we cannot use GLFW's new runtime platform detection at the moment when building raylib with the Makefile instead of CMake, as explained in #3827 (comment). Maybe we can merge the PR as is and check this issue at a different moment.

As for testing on other platforms, I would like to ask for help from other users, although all checks from GitHub Actions are successful as of 6a58cbb.

Update: It looks like gamepads have stopped working (actually, only one of the gamepads I tested has stopped working, which is probably a rare case and we don't need to care).

@raysan5
Copy link
Owner

raysan5 commented Feb 25, 2024

Thanks for starting this update! It was in my TODO list! But note it requires testing on Windows, Linux and macOS.

@planetis-m
Copy link
Contributor

Might need to revert #2883 since glfw/glfw@2c3eb75 removed the dependency on wayland-protocols.

@M374LX
Copy link
Contributor Author

M374LX commented Feb 25, 2024

@planetis-m Reverting #2883 is not necessary, as 260a039 contains the necessary changes.

@M374LX
Copy link
Contributor Author

M374LX commented Feb 25, 2024

The new GLFW version supports platform detection at runtime, which enables a single executable to run on both X11 and Wayland. However, it looks like raylib cannot offer the same platform detection functionality at the moment if build with the Makefile (instead of CMake) because some of GLFW's local (static) functions in different platforms have the same name. As a result, we cannot combine source files from multiple platforms into one, as done in rglfw.c, unless GLFW's developers agree to change the names of these functions.

Alternatively, we might get rid of rglfw.c and select the required GLFW source files from the Makefile.

It seems to work fine when raylib is build with CMake, however.

@M374LX M374LX marked this pull request as ready for review February 25, 2024 21:08
@M374LX M374LX changed the title Update GLFW to 3.4 (draft) Update GLFW to 3.4 Feb 25, 2024
@gen2brain
Copy link
Contributor

@M374LX I just updated GLFW to 3.4 in raylib Go bindings. I did rename some functions in gen2brain/raylib-go@8596a5d though. I know this will affect a few more projects, like go-gl/glfw#393, so I hope it will be solved, but for now, it is not a big deal, at least for me. There are also changes for Wayland generated headers, they are renamed, and there are some additions, I use a script for that gen2brain/raylib-go@5abcc8b.

Now the single binary runs on both X11 and Wayland, you can check the output:

WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not provide the window position
WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not provide the window position
WARNING: GLFW: Error: 65548 Description: Wayland: The platform does not support setting the window position

It would be nice to check glfwGetPlatform and add that to i.e. INFO: Platform backend: DESKTOP (GLFW).

@raysan5
Copy link
Owner

raysan5 commented Feb 26, 2024

This is a big change, it needs some careful review... but it will be merged.

@M374LX
Copy link
Contributor Author

M374LX commented Feb 26, 2024

05ba358 implements @gen2brain's suggestion to output the platform selected by GLFW to TRACELOG.

@gen2brain I suggest also renaming the conflicting functions on the "null" platform, as it is expected by GLFW 3.4 to be present and this is actually a (hopefully temporary) hack:

raylib/src/rglfw.c

Lines 74 to 79 in 05ba358

// We do not use GLFW's "null" platform, but the absence of this function
// causes the build to fail
GLFWbool _glfwConnectNull(int platformID, _GLFWplatform* platform)
{
return GLFW_TRUE;
}

Also note that GLFW uses the Zlib license, which states "Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software".

Related GLFW issue: glfw/glfw#2502

As the above issue is unlikely to be fixed in a short period of time, I think getting rid of rglfw.c and using the Makefile instead is a better idea. Also note that rglfw.c is not used when building raylib with CMake, although the Zig build system uses it. Modifying raylib's bundled GLFW is another alternative.

@raysan5
Copy link
Owner

raysan5 commented Feb 27, 2024

@M374LX @gen2brain Changes look good to me for now, please, let me know when you think this PR is ready for merge.

Some point to consider:

  • Are gamepad mappings updated? It has been manually updated in the past.
  • Is this PR tested on all GLFW supported platforms? It should be tested on: Windows, Linux, macOS and Web.

@M374LX
Copy link
Contributor Author

M374LX commented Feb 28, 2024

The gamepad mappings are supposed to be the ones provided by GLFW.

I am able to test this PR on Linux and can confirm that it works on both X11 and Wayland (despite #3827 (comment)), but I prefer to leave the tests on Windows, macOS and Web for someone with access to these systems and Emscripten set up.

Otherwise, I think it is ready to be merged.

@raysan5 raysan5 merged commit 6589311 into raysan5:master Feb 29, 2024
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Feb 29, 2024

@M374LX Thank you very much for this improvement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants