mathc icon indicating copy to clipboard operation
mathc copied to clipboard

Suggestion: rename last two parameters of mat4_perspective in mathc.h to speaking names

Open ghost opened this issue 4 years ago • 2 comments

I had to google around and check out libglm usage to see what parameters a perspective transformation commonly takes (and yes I'm familiar with clipping planes and all, I just never used lowlevel OpenGL directly before) to figure out what on earth n or f are. Turns out it's "near clipping" and "far clipping":

mfloat_t *mat4_perspective(mfloat_t *result, mfloat_t fov_y, mfloat_t aspect, mfloat_t n, mfloat_t f)

Therefore, I recommend renaming them to znear and zfar in the header since that will make it way easier both to guess and to google what they are used for. It may seem like a minor nitpick but this can really help a lot when there's otherwise no documentation available.

Edit: proposal updated due to @RandyGaul 's remark

ghost avatar Jan 29 '20 01:01 ghost

near and far are names taken by Windows.h, so any other names would be slightly simpler to use.

RandyGaul avatar Jan 29 '20 15:01 RandyGaul

~~What do you mean with "taken by Windows.h"? If you rename them in the header only they aren't in anyone's scope, so that shouldn't be an issue on a technical level. (You can still keep the old parameter names in the mathc.c actual implementation file.) Or are you saying people would be confused by these names?~~

Edit: oh fascinating, seems like they're macros which is a problem. Good catch! What about znear and zfar then?

ghost avatar Jan 29 '20 17:01 ghost