Replies: 1 comment 2 replies
-
Hi @dzita19, Thanks for your feedbacks, really! cglm offers 3 maybe 4 types of APIs (https://cglm.readthedocs.io/en/latest/api.html):
This will reduce temp lines as you wish, e.g. #define CGLM_OMIT_NS_FROM_STRUCT_API
#include <cglm/struct.h>
vec4 result = vec4_add(a, vec4_mul(b, vec4_reflect(I, N))); // ... currently apis in global namespace like glms_look(), glms_perspective()... still have namespace prefixes like
#include <cglm/cglm.h> // INLINE ARRAY
#include <cglm/struct.h> // INLINE STRUCT
#include <cglm/call.h> // COMPILED ARRAY Hope this helps to discover some features of cglm. There may be more convenient functions to make Array API more easy to work with. Feedbacks are welcome to improve the library, make it more robust and useful. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there,
I've been using this lib for quite some time and I'm very content with it. I think most of the stuff is pretty handy, and API is approachable. However, one thing absolutely drives me nuts. I have to create a variable for every subexpression that would otherwise be a temporary. It bloats my code and turns a 3 lines function into 20 lines monstrosity that is absolutely unreadable. All of that because vectors are typedefs around arrays. That one design choice made it impossible to return a vector from function. That's totally opposite of the modern C approach.
So ok, I put my critics to the table. I wanna know am I wrong, is there any reason why this approach is better than simply wrapping all vectors with a struct and thus making them copy-able? Maybe that small change would improve the library, and, most importantly, it wouldn't ruin the performance.
Only thing that would be endangered is the API, since the copy-friendly API would not take as much parameters per function (obviously, no need to pass a pointer to destination struct). Some functions would be straight-up useless (like all the functions for duplicating a vector or a matrix). Maybe such an API change would be the sole reason to just let the lib be, I don't know.
I would really like to hear some feedback on this.
Beta Was this translation helpful? Give feedback.
All reactions