Skip to content

added minimal example for raylib #35

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

Merged
merged 7 commits into from
May 24, 2025

Conversation

lumenkeyes
Copy link
Contributor

@lumenkeyes lumenkeyes commented May 6, 2025

Finally got around to adding the raylib example, lmk what you think.
The build.zig.zon raylib-zig dep points to my own fork just because it's easier for me to keep that one up-to-date with changes in upstream raylib.

Fixes #31

@lumenkeyes lumenkeyes marked this pull request as draft May 7, 2025 17:04
@lumenkeyes lumenkeyes marked this pull request as ready for review May 7, 2025 17:16
@silbinarywolf
Copy link
Owner

Just a few more requested changes, mostly if the linking of EGL and GLESv2 can occur at the library level for Android/Linux only (where appropriate), that'd be great.

Otherwise this looks fantastic. Thanks for putting this together :)

EGL should be linked at the library level now, and only for the
appropriate targets. Also some conditional compilation as suggested.
@lumenkeyes
Copy link
Contributor Author

Should be good to go now (famous last words). I did take the time to boot up my Windows machine this time and managed to build successfully on it as well. Let me know if you have any more suggestions. Potential concerns that I can think of:

  • this is targeting a rather old version of Android (it's what I had available for testing)
  • getting the app's local directories without hardcoding them is often important/useful, but a little bit of a pain without adding some helper functionality. I don't know if it's worth including in a "minimal" example, though. Something like this:
const c_impl = @cImport({
    @cInclude("android_native_app_glue.h");
});

pub extern "c" fn GetAndroidApp() *c_impl.android_app;
    
pub fn GetInternalDataPath() [:0]const u8 {
        return std.mem.sliceTo((GetAndroidApp()).*.activity.*.internalDataPath, 0);
}

    
pub fn GetDocumentsPath() [:0]const u8 {
        return std.mem.sliceTo((GetAndroidApp()).*.activity.*.externalDataPath, 0);
}

Comment on lines 9 to 10
//The main function is not allowed to return zig errors, so you will have to
//use "catch @panic()" or create other error handling functionality.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is no longer true and should probably be removed right?

Comment on lines +8 to +9
.url = "git+https://github.com/lumenkeyes/raylib-zig#b00d4c2b973665e3a88c2565b6cd63c56d0173c2",
.hash = "raylib_zig-5.6.0-dev-KE8REPwqBQC35iWa2sFblBUNWkTlEi1gjit9dtyOLu_b"
Copy link
Owner

@silbinarywolf silbinarywolf May 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the plan to do a PR here to upstream your Android build support?
https://github.com/Not-Nik/raylib-zig

It'd be ideal if we point at the main maintainer of the library but we can do that in a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only real difference is which version of upstream raylib we're depending on in our zon file. I can definitely submit a PR, but I also figure they'll have to update their dependencies eventually. I can try to get that moving, though, as I agree it would be preferred.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have submitted the PR, but I haven't heard anything back yet

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to merge as-is if you'd like. If/when your PR is merged, we can upstream it if that works?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Fixes an issue where zig was unable to find the "main" entry point for
non-android builds.
@silbinarywolf silbinarywolf merged commit 1ed3836 into silbinarywolf:main May 24, 2025
3 checks passed
@silbinarywolf
Copy link
Owner

awesome, thanks for putting this together. Just raise further PRs if/when your PR is merged :)

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.

Raylib support Please
2 participants