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

[raymath] Type-Generic RayMath (tgraymath.h) #4170

Closed
wants to merge 3 commits into from

Conversation

JayLCypher
Copy link
Contributor

Tags: [TEACH] [CONVENIENCE]

TL;DR: Type-Generic RayMath function-like macros in the spirit of tgmath.h

Since the standard library has tgmath for type-generic math, thought it was only fitting to create type-generic raymath! 💯

Probably not wanted or needed but offered as convenience. Allows omitting specific type for a bunch of Vector operations and some operations also supporting floats and numbers.

Most things are limited, but I decided to use defaults for the variants which also includes floats. This will allow usage of any number type, but I suspect -Wconversion will complain if someone aren't using compatible float types on float functions. Trying to set up _Generic for compatible type will literally explode the macros.
_Generic is ass.

For Raylib as a teaching tool, I suspect there are examples here of nested _Generics.

Includes a preprocessor warning in case someone tries to use the file in a project that is compiled with versions less than C11. (-Wcpp)

Test file

@raysan5
Copy link
Owner

raysan5 commented Jul 18, 2024

@JayLCypher Interesting but I'm afraid that's out of scope for raylib, it should be moved to a separate repo.

@raysan5 raysan5 closed this Jul 18, 2024
@JayLCypher
Copy link
Contributor Author

Alright, I have created a repo for it just to have it up.
If you ever set raymath up as it's own thing, feel free to include tgraymath.h

Thanks for looking at it so quick Ray!

@raysan5
Copy link
Owner

raysan5 commented Jul 18, 2024

@JayLCypher Thanks for your comprehension. Please, could you share the repo for reference?

@JayLCypher
Copy link
Contributor Author

tgraymath.h repository

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.

None yet

2 participants