Skip to content

Make generated bindings no_std compatible and add CStr symbol names feature #551

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

nigrodev
Copy link

@nigrodev nigrodev commented Mar 4, 2025

Generated bindings no_std compatibility

The generated bindings was already using core functions, but was getting them through re-exports of std. This is now replaced to use the original core ones. Now the generated bindings works in no_std enviroments 🎉

&CStr symbols support

Right now, if the user needs a null-terminated c-string from the gl::load_with function, they need to convert the &str to a CString. Since CString is only available in std and requires an allocator, the usage in std enviroments is limited.

With this pull request, using Rust 2021 edition C-string literals, the user have the possibility to enable the feature cstr_symbols on both gl_generator and gl to generate the bindings using &'static CStr instead of &'static str.

Examples of this problem can be seen on both SDL2 and SDL3 safe wrappers, where they need to perform a conversion using CString.

@Lokathor
Copy link

Lokathor commented Mar 4, 2025

This looks really cool, but I think unfortunately this crate is effectively unmaintained for years now.

Last I heard the best crate to use for GL is glow.

@nigrodev
Copy link
Author

nigrodev commented Mar 4, 2025

Last I heard the best crate to use for GL is glow.

I've been using this crate because it's the only one that looks the most like raw OpenGL with C, glow is more "high level".

I recently read about some people being able to use Rust on consoles that don't support std, replacing the std calls with SDL. So I was experimenting with using the new SDL3 and opengl in a no_std environment with rust.

This looks really cool, but I think unfortunately this crate is effectively unmaintained for years now.

Since I've already made the changes, I decided to post it here anyway. At least, if anyone looks for it, they'll find it here :P

@Lokathor
Copy link

Lokathor commented Mar 4, 2025

I had a similar concern about no_std, and so I made the gl33 and gl46 crates at one point, though I don't really get them updates either. Most people working on new graphics seem to want to work with Vulkan or WGPU, so I sorta lost interest in keeping up with the periodic minor updates to GL stuff.

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

Successfully merging this pull request may close these issues.

2 participants