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

[Core] Minor: it would be nice to make fontId pointer sized #148

Open
mikejsavage opened this issue Jan 2, 2025 · 6 comments
Open

[Core] Minor: it would be nice to make fontId pointer sized #148

mikejsavage opened this issue Jan 2, 2025 · 6 comments

Comments

@mikejsavage
Copy link
Contributor

Very minor, but with certain renderer designs the implementation would be a tiny bit simpler if Clay_TextElementConfig::textId could fit a pointer instead of just a u16

@nicbarker
Copy link
Owner

@ColleagueRiley raised a similar point and I think you're right - the ergonomics are likely worth the increase in struct size here 🙂

@ColleagueRiley
Copy link

ColleagueRiley commented Jan 2, 2025

@nicbarker
Either using void* or size_t would be a potential solution.
Another solution could be:

#ifndef CLAY_FONT_ID
#define CLAY_FONT_ID u16
#endif

This would allow users to use whatever type they like for their "font id", the same could be done for textures. If you choose that route.

worth the increase in struct size here

I agree, I don't think anyone will complain about an extra 48 bits.

@FintasticMan
Copy link
Contributor

intptr_t would also be good.

@ColleagueRiley
Copy link

ColleagueRiley commented Jan 2, 2025

@FintasticMan Yes, I think that's about the same as size_t except that it's explicitly intended for pointers. So it would probably be better to use intptr_t.

@sammonius
Copy link

sammonius commented Jan 3, 2025

On a related note, I think the same could also go for the index in CLAY_IDI(). That way, structs could be used to store certain properties of an element, and a poiner to the struct could be the ID. (I had a similar issue to that and I was trying to get the first half of the pointer using casts and bitwise operations but i ended up giving up after like half an hour.)

intptr_t would be nice but I think that's part of the standard library, isn't it?

@FintasticMan
Copy link
Contributor

It's part of the standard library, but not the part that you have to link against, so it's fair game for Clay. Clay can use things that are available in freestanding C implementations, just not things that are only available in hosted implementations.

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

No branches or pull requests

5 participants