recp / cglm

📽 Highly Optimized 2D / 3D Graphics Math (glm) for C
MIT License
2.34k stars 231 forks source link

where is glm_camera_lookat defined? #294

Open badasahog opened 1 year ago

badasahog commented 1 year ago

I'm looking for the cglm equivalent of DirectX's XMMatrixLookAtLH, and found glm_camera_lookat in the test list, which seems promising, but it doesn't seem to be defined anywhere.

Even searching for it in the repo via github gets me nowhere. (https://github.com/recp/cglm/search?q=glm_camera_lookat)

Where is it defined?

recp commented 1 year ago

Hi @badasahog,

In test/tests.h file, TEST_DECLARE(glm_camera_lookat) declares test_glm_camera_lookat() and TEST_ENTRY(glm_camera_lookat) in same file add its to test list.

In test/src/test_cam.h file, TEST_IMPL(GLM_PREFIX, camera_lookat) { defines the test function body. TEST_IMPL Macro adds prefix of the name by GLM_PREFIX e.g. test_glm_camera_lookat, test_glmc_camera_lookat ...

This is how tests work in cglm, make check should run tests...

The actual camera functions are glm_lookat(), glm_look()... which are defined in include/cglm headers...

Hope it helps

recp commented 1 year ago

Also you can use both LH and RH by including (or define CGLM_CLIPSPACE_INCLUDE_ALL to include all) related headers at cglm/clipspace/view_lh.h, cglm/clipspace/view_rh.h, cglm/clipspace/view_lh_zo.h, cglm/clipspace/view_no.h... or just define CGLM_CONFIG_CLIP_CONTROL macro as CGLM_CLIP_CONTROL_LH_ZO, CGLM_CLIP_CONTROL_LH_NO... to switch between them without using lh/rh, no/zo suffixes...

Default is CGLM_CLIP_CONTROL_RH_NO:

#ifdef CGLM_FORCE_DEPTH_ZERO_TO_ONE
#  ifdef CGLM_FORCE_LEFT_HANDED
#    define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_ZO
#  else
#    define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_ZO
#  endif
#else
#  ifdef CGLM_FORCE_LEFT_HANDED
#    define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_NO
#  else
#    define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_NO
#  endif
#endif

the configuration macros must be defined before including cglm headers...