DataType.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. return {
  2. description = [[
  3. Different types for `Buffer` fields. These are scalar, vector, or matrix types, usually packed
  4. into small amounts of space to reduce the amount of memory they occupy.
  5. The names are encoded as follows:
  6. - The data type:
  7. - `i` for signed integer
  8. - `u` for unsigned integer
  9. - `sn` for signed normalized (-1 to 1)
  10. - `un` for unsigned normalized (0 to 1)
  11. - `f` for floating point
  12. - The bit depth of each component
  13. - The letter `x` followed by the component count (for vectors)
  14. ]],
  15. values = {
  16. {
  17. name = 'i8x4',
  18. description = 'Four 8-bit signed integers.'
  19. },
  20. {
  21. name = 'u8x4',
  22. description = 'Four 8-bit unsigned integers.'
  23. },
  24. {
  25. name = 'sn8x4',
  26. description = 'Four 8-bit signed normalized values.'
  27. },
  28. {
  29. name = 'un8x4',
  30. description = 'Four 8-bit unsigned normalized values (aka `color`).'
  31. },
  32. {
  33. name = 'un10x3',
  34. description = 'Three 10-bit unsigned normalized values, and 2 padding bits (aka `normal`).'
  35. },
  36. {
  37. name = 'i16',
  38. description = 'One 16-bit signed integer.'
  39. },
  40. {
  41. name = 'i16x2',
  42. description = 'Two 16-bit signed integers.'
  43. },
  44. {
  45. name = 'i16x4',
  46. description = 'Four 16-bit signed integers.'
  47. },
  48. {
  49. name = 'u16',
  50. description = 'One 16-bit unsigned integer.'
  51. },
  52. {
  53. name = 'u16x2',
  54. description = 'Two 16-bit unsigned integers.'
  55. },
  56. {
  57. name = 'u16x4',
  58. description = 'Four 16-bit unsigned integers.'
  59. },
  60. {
  61. name = 'sn16x2',
  62. description = 'Two 16-bit signed normalized values.'
  63. },
  64. {
  65. name = 'sn16x4',
  66. description = 'Four 16-bit signed normalized values.'
  67. },
  68. {
  69. name = 'un16x2',
  70. description = 'Two 16-bit unsigned normalized values.'
  71. },
  72. {
  73. name = 'un16x4',
  74. description = 'Four 16-bit unsigned normalized values.'
  75. },
  76. {
  77. name = 'i32',
  78. description = 'One 32-bit signed integer (aka `int`).'
  79. },
  80. {
  81. name = 'i32x2',
  82. description = 'Two 32-bit signed integers.'
  83. },
  84. {
  85. name = 'i32x2',
  86. description = 'Two 32-bit signed integers.'
  87. },
  88. {
  89. name = 'i32x3',
  90. description = 'Three 32-bit signed integers.'
  91. },
  92. {
  93. name = 'i32x4',
  94. description = 'Four 32-bit signed integers.'
  95. },
  96. {
  97. name = 'u32',
  98. description = 'One 32-bit unsigned integer (aka `uint`).'
  99. },
  100. {
  101. name = 'u32x2',
  102. description = 'Two 32-bit unsigned integers.'
  103. },
  104. {
  105. name = 'u32x3',
  106. description = 'Three 32-bit unsigned integers.'
  107. },
  108. {
  109. name = 'u32x4',
  110. description = 'Four 32-bit unsigned integers.'
  111. },
  112. {
  113. name = 'f16x2',
  114. description = 'Two 16-bit floating point numbers.'
  115. },
  116. {
  117. name = 'f16x4',
  118. description = 'Four 16-bit floating point numbers.'
  119. },
  120. {
  121. name = 'f32',
  122. description = 'One 32-bit floating point number (aka `float`).'
  123. },
  124. {
  125. name = 'f32x2',
  126. description = 'Two 32-bit floating point numbers (aka `vec2`).'
  127. },
  128. {
  129. name = 'f32x3',
  130. description = 'Three 32-bit floating point numbers (aka `vec3`).'
  131. },
  132. {
  133. name = 'f32x4',
  134. description = 'Four 32-bit floating point numbers (aka `vec4`).'
  135. },
  136. {
  137. name = 'mat2',
  138. description = 'A 2x2 matrix containing four 32-bit floats.'
  139. },
  140. {
  141. name = 'mat3',
  142. description = 'A 3x3 matrix containing nine 32-bit floats.'
  143. },
  144. {
  145. name = 'mat4',
  146. description = 'A 4x4 matrix containing sixteen 32-bit floats.'
  147. },
  148. {
  149. name = 'index16',
  150. description = 'Like u16, but 1-indexed.'
  151. },
  152. {
  153. name = 'index32',
  154. description = 'Like u32, but 1-indexed.'
  155. }
  156. },
  157. notes = [[
  158. In addition to these values, the following aliases can be used:
  159. <table>
  160. <thead>
  161. <tr>
  162. <td>Alias</td>
  163. <td>Maps to</td>
  164. </tr>
  165. </thead>
  166. <tbody>
  167. <tr>
  168. <td><code>vec2</code></td>
  169. <td><code>f32x2</code></td>
  170. </tr>
  171. <tr>
  172. <td><code>vec3</code></td>
  173. <td><code>f32x3</code></td>
  174. </tr>
  175. <tr>
  176. <td><code>vec4</code></td>
  177. <td><code>f32x4</code></td>
  178. </tr>
  179. <tr>
  180. <td><code>int</code></td>
  181. <td><code>i32</code></td>
  182. </tr>
  183. <tr>
  184. <td><code>uint</code></td>
  185. <td><code>u32</code></td>
  186. </tr>
  187. <tr>
  188. <td><code>float</code></td>
  189. <td><code>f32</code></td>
  190. </tr>
  191. <tr>
  192. <td><code>color</code></td>
  193. <td><code>un8x4</code></td>
  194. </tr>
  195. </tbody>
  196. </table>
  197. Additionally, the following convenience rules apply:
  198. - Field types can end in an `s`, which will be stripped off.
  199. - Field types can end in `x1`, which will be stripped off.
  200. So you can write, e.g. `lovr.graphics.newBuffer(4, 'floats')`, which is cute!
  201. ]],
  202. related = {
  203. 'lovr.graphics.newBuffer',
  204. 'Buffer:getFormat'
  205. }
  206. }