opt.rst 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. default-domain:: C
  2. Options
  3. ===============================================================================
  4. A few options are provided via macros.
  5. Alignment Option
  6. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. As default, cglm requires types to be aligned. Alignment requirements:
  8. vec3: 8 byte
  9. vec4: 16 byte
  10. mat4: 16 byte
  11. versor: 16 byte
  12. By starting **v0.4.5** cglm provides an option to disable alignment requirement.
  13. To enable this option define **CGLM_ALL_UNALIGNED** macro before all headers.
  14. You can define it in Xcode, Visual Studio (or other IDEs) or you can also prefer
  15. to define it in build system. If you use pre-compiled versions then you
  16. have to compile cglm with **CGLM_ALL_UNALIGNED** macro.
  17. **VERY VERY IMPORTANT:** If you use cglm in multiple projects and
  18. those projects are depends on each other, then
  19. | *ALWAYS* or *NEVER USE* **CGLM_ALL_UNALIGNED** macro in linked projects
  20. if you do not know what you are doing. Because a cglm header included
  21. via 'project A' may force types to be aligned and another cglm header
  22. included via 'project B' may not require alignment. In this case
  23. cglm functions will read from and write to **INVALID MEMORY LOCATIONs**.
  24. ALWAYS USE SAME CONFIGURATION / OPTION for **cglm** if you have multiple projects.
  25. For instance if you set CGLM_ALL_UNALIGNED in a project then set it in other projects too
  26. SSE and SSE2 Shuffle Option
  27. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. **_mm_shuffle_ps** generates **shufps** instruction even if registers are same.
  29. You can force it to generate **pshufd** instruction by defining
  30. **CGLM_USE_INT_DOMAIN** macro. As default it is not defined.
  31. SSE3 and SSE4 Dot Product Options
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. You have to extra options for dot product: **CGLM_SSE4_DOT** and **CGLM_SSE3_DOT**.
  34. - If **SSE4** is enabled then you can define **CGLM_SSE4_DOT** to force cglm to use **_mm_dp_ps** instruction.
  35. - If **SSE3** is enabled then you can define **CGLM_SSE3_DOT** to force cglm to use **_mm_hadd_ps** instructions.
  36. otherwise cglm will use custom cglm's hadd functions which are optimized too.
  37. Print Options
  38. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  39. 1. **CGLM_DEFINE_PRINTS**
  40. 2. **CGLM_NO_PRINTS_NOOP** (use CGLM_DEFINE_PRINTS)
  41. Inline prints are only enabled in **DEBUG** mode or if **CGLM_DEFINE_PRINTS** is defined.
  42. **glmc_** versions will always print too.
  43. Because **cglm** tried to enable print functions in debug mode and disable them in
  44. release/production mode to eliminate printing costs when we do not need them.
  45. **cglm** checks **DEBUG** or **_DEBUG** macros to test debug mode, if these are not working for you then you can use
  46. **CGLM_DEFINE_PRINTS** to force enable, or create a PR to introduce new macro to test against debugging mode.
  47. If DEBUG mode is not enabled then print functions will be emptied to eliminate print function calls.
  48. You can disable this feature too by defining **CGLM_DEFINE_PRINTS** macro top of cglm header
  49. or in project/build settings...
  50. 3. **CGLM_PRINT_PRECISION** 5
  51. precision.
  52. 4. **CGLM_PRINT_MAX_TO_SHORT** 1e5
  53. if a number is greater than this value then %g will be used, since this is shorten print you won't be able to see high precision.
  54. 5. **CGLM_PRINT_COLOR** "\033[36m"
  55. 6. **CGLM_PRINT_COLOR_RESET** "\033[0m"
  56. You can disable colorful print output by defining **CGLM_PRINT_COLOR** and **CGLM_PRINT_COLOR_RESET** as empty macro.
  57. Because some terminals may not support colors.