io.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. .. default-domain:: C
  2. io (input / output e.g. print)
  3. ================================================================================
  4. Header: cglm/io.h
  5. There are some built-in print functions which may save your time,
  6. especially for debugging.
  7. All functions accept **FILE** parameter which makes very flexible.
  8. You can even print it to file on disk.
  9. In general you will want to print them to console to see results.
  10. You can use **stdout** and **stderr** to write results to console.
  11. Some programs may occupy **stdout** but you can still use **stderr**.
  12. Using **stderr** is suggested.
  13. Example to print mat4 matrix:
  14. .. code-block:: c
  15. mat4 transform;
  16. /* ... */
  17. glm_mat4_print(transform, stderr);
  18. **NOTE:** print functions use **%0.4f** precision if you need more
  19. (you probably will in some cases), you can change it temporary.
  20. cglm may provide precision parameter in the future
  21. Changes since **v0.7.3**:
  22. * Now mis-alignment of columns are fixed: larger numbers are printed via %g and others are printed via %f. Column withs are calculated before print.
  23. * Now values are colorful ;)
  24. * Some print improvements
  25. * New options with default values:
  26. .. code-block:: c
  27. #define CGLM_PRINT_PRECISION 5
  28. #define CGLM_PRINT_MAX_TO_SHORT 1e5
  29. #define CGLM_PRINT_COLOR "\033[36m"
  30. #define CGLM_PRINT_COLOR_RESET "\033[0m"
  31. * Inline prints are only enabled in DEBUG mode and if **CGLM_DEFINE_PRINTS** is defined.
  32. Check options page.
  33. Table of contents (click to go):
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. Functions:
  36. 1. :c:func:`glm_mat4_print`
  37. #. :c:func:`glm_mat3_print`
  38. #. :c:func:`glm_vec4_print`
  39. #. :c:func:`glm_vec3_print`
  40. #. :c:func:`glm_ivec3_print`
  41. #. :c:func:`glm_versor_print`
  42. #. :c:func:`glm_aabb_print`
  43. Functions documentation
  44. ~~~~~~~~~~~~~~~~~~~~~~~
  45. .. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
  46. | print mat4 to given stream
  47. Parameters:
  48. | *[in]* **matrix** matrix
  49. | *[in]* **ostream** FILE to write
  50. .. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
  51. | print mat3 to given stream
  52. Parameters:
  53. | *[in]* **matrix** matrix
  54. | *[in]* **ostream** FILE to write
  55. .. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream)
  56. | print vec4 to given stream
  57. Parameters:
  58. | *[in]* **vec** vector
  59. | *[in]* **ostream** FILE to write
  60. .. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
  61. | print vec3 to given stream
  62. Parameters:
  63. | *[in]* **vec** vector
  64. | *[in]* **ostream** FILE to write
  65. .. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
  66. | print ivec3 to given stream
  67. Parameters:
  68. | *[in]* **vec** vector
  69. | *[in]* **ostream** FILE to write
  70. .. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream)
  71. | print quaternion to given stream
  72. Parameters:
  73. | *[in]* **vec** quaternion
  74. | *[in]* **ostream** FILE to write
  75. .. c:function:: void glm_aabb_print(versor vec, const char * __restrict tag, FILE * __restrict ostream)
  76. | print aabb to given stream
  77. Parameters:
  78. | *[in]* **vec** aabb (axis-aligned bounding box)
  79. | *[in]* **tag** tag to find it more easly in logs
  80. | *[in]* **ostream** FILE to write