io.rst 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_ivec4_print`
  40. #. :c:func:`glm_vec3_print`
  41. #. :c:func:`glm_ivec3_print`
  42. #. :c:func:`glm_vec2_print`
  43. #. :c:func:`glm_ivec2_print`
  44. #. :c:func:`glm_versor_print`
  45. #. :c:func:`glm_aabb_print`
  46. Functions documentation
  47. ~~~~~~~~~~~~~~~~~~~~~~~
  48. .. c:function:: void glm_mat4_print(mat4 matrix, FILE * __restrict ostream)
  49. | print matrix to given stream
  50. Parameters:
  51. | *[in]* **matrix** matrix
  52. | *[in]* **ostream** FILE to write
  53. .. c:function:: void glm_mat3_print(mat3 matrix, FILE * __restrict ostream)
  54. | print matrix to given stream
  55. Parameters:
  56. | *[in]* **matrix** matrix
  57. | *[in]* **ostream** FILE to write
  58. .. c:function:: void glm_vec4_print(vec4 vec, FILE * __restrict ostream)
  59. | print vector to given stream
  60. Parameters:
  61. | *[in]* **vec** vector
  62. | *[in]* **ostream** FILE to write
  63. .. c:function:: void glm_ivec4_print(ivec4 vec, FILE * __restrict ostream)
  64. | print vector to given stream
  65. Parameters:
  66. | *[in]* **vec** vector
  67. | *[in]* **ostream** FILE to write
  68. .. c:function:: void glm_vec3_print(vec3 vec, FILE * __restrict ostream)
  69. | print vector to given stream
  70. Parameters:
  71. | *[in]* **vec** vector
  72. | *[in]* **ostream** FILE to write
  73. .. c:function:: void glm_ivec3_print(ivec3 vec, FILE * __restrict ostream)
  74. | print vector to given stream
  75. Parameters:
  76. | *[in]* **vec** vector
  77. | *[in]* **ostream** FILE to write
  78. .. c:function:: void glm_vec2_print(vec2 vec, FILE * __restrict ostream)
  79. | print vector to given stream
  80. Parameters:
  81. | *[in]* **vec** vector
  82. | *[in]* **ostream** FILE to write
  83. .. c:function:: void glm_ivec2_print(ivec2 vec, FILE * __restrict ostream)
  84. | print vector to given stream
  85. Parameters:
  86. | *[in]* **vec** vector
  87. | *[in]* **ostream** FILE to write
  88. .. c:function:: void glm_versor_print(versor vec, FILE * __restrict ostream)
  89. | print quaternion to given stream
  90. Parameters:
  91. | *[in]* **vec** quaternion
  92. | *[in]* **ostream** FILE to write
  93. .. c:function:: void glm_aabb_print(versor vec, const char * __restrict tag, FILE * __restrict ostream)
  94. | print aabb to given stream
  95. Parameters:
  96. | *[in]* **vec** aabb (axis-aligned bounding box)
  97. | *[in]* **tag** tag to find it more easly in logs
  98. | *[in]* **ostream** FILE to write