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

Start porting <c3d/maths.h>, vectors and matrices #27

Merged
merged 6 commits into from
Oct 12, 2023

Conversation

ian-h-chamberlain
Copy link
Member

@ian-h-chamberlain ian-h-chamberlain commented Oct 6, 2023

Expose safe wrappers for Mtx_ APIs, for now mainly just the constructors that are used for projection matrices, since those will probably be the most commonly used. This PR also adds a Uniform trait which is how those matrices are bound to a shader to get sent to the GPU, and should also work for other types like FVec and possibly even custom data types.

I think once I get this to pass CI I will merge it since I've iterated a few times already and it's starting to get a little bigger than I should have let it, really... We're getting closer to a fully safe triangle example though!


TODOs remaining:

  • vector math, transformations etc. Might will save for another PR
  • Docstrings and general cleanup
  • Consider a more general API for binding uniforms to shaders, I don't love the idea of having a separate update_blah per matrix / vector type / dimension. Maybe a trait would be nice?

It's not much but it should be extensible enough to apply for other
uniform types. We might want a generic impl for &[u8] or something
as well to support custom uniform types, but that gets trickier.
Also add some doc aliases for citro3d functions. We could probably stand
to add more aliases to other wrappers too.
@ian-h-chamberlain ian-h-chamberlain marked this pull request as ready for review October 9, 2023 01:58
Finally, something that I don't think totally sucks. Pick some sane
defaults for some fields, and use generics to split between
orthographic and perspective implementations. It's still not perfect but
I think this looks a lot more ergonomic to use vs what I had before (and
compared to the C APIs).
@ian-h-chamberlain ian-h-chamberlain merged commit 6ce6c96 into main Oct 12, 2023
4 checks passed
@ian-h-chamberlain ian-h-chamberlain deleted the feature/safe-math-wrappers branch October 12, 2023 04:01
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.

1 participant