@defold-typescript/types 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/api-availability.json +3963 -772
  2. package/api-migrations.json +27 -0
  3. package/api-signatures.json +18069 -10240
  4. package/api-targets.json +448 -11
  5. package/examples/translations.json +560 -89
  6. package/fixtures/messages_doc.json +96 -0
  7. package/generated/b2d.d.ts +680 -4
  8. package/generated/b2d_body.d.ts +29 -103
  9. package/generated/b2d_chain.d.ts +5 -6
  10. package/generated/b2d_fixture.d.ts +34 -38
  11. package/generated/b2d_joint.d.ts +503 -25
  12. package/generated/b2d_shape.d.ts +183 -20
  13. package/generated/b2d_world.d.ts +57 -63
  14. package/generated/buffer.d.ts +16 -15
  15. package/generated/builtin-messages.d.ts +7 -1
  16. package/generated/bullet3d.d.ts +91 -0
  17. package/generated/bullet3d_collision_object.d.ts +433 -0
  18. package/generated/bullet3d_constraint.d.ts +818 -0
  19. package/generated/bullet3d_rigid_body.d.ts +429 -0
  20. package/generated/bullet3d_shape.d.ts +123 -0
  21. package/generated/bullet3d_world.d.ts +492 -0
  22. package/generated/camera.d.ts +29 -32
  23. package/generated/collectionfactory.d.ts +15 -18
  24. package/generated/collectionproxy.d.ts +22 -6
  25. package/generated/compute.d.ts +12 -238
  26. package/generated/crash.d.ts +24 -10
  27. package/generated/editor-vm/http.d.ts +90 -7
  28. package/generated/editor-vm/image.d.ts +7 -7
  29. package/generated/editor-vm/json.d.ts +11 -0
  30. package/generated/editor-vm/localization.d.ts +7 -7
  31. package/generated/editor-vm/tilemap_tiles.d.ts +56 -10
  32. package/generated/editor-vm/zip.d.ts +28 -0
  33. package/generated/editor.d.ts +1496 -430
  34. package/generated/factory.d.ts +21 -25
  35. package/generated/font.d.ts +64 -22
  36. package/generated/go.d.ts +235 -182
  37. package/generated/graphics.d.ts +335 -97
  38. package/generated/gui.d.ts +240 -471
  39. package/generated/html5.d.ts +2 -2
  40. package/generated/http.d.ts +28 -35
  41. package/generated/image.d.ts +105 -72
  42. package/generated/json.d.ts +34 -16
  43. package/generated/kinds/gui-script.d.ts +7 -0
  44. package/generated/kinds/render-script.d.ts +7 -0
  45. package/generated/kinds/script.d.ts +7 -0
  46. package/generated/label.d.ts +77 -7
  47. package/generated/liveupdate.d.ts +13 -10
  48. package/generated/material.d.ts +312 -360
  49. package/generated/model.d.ts +40 -39
  50. package/generated/particlefx.d.ts +19 -28
  51. package/generated/physics.d.ts +365 -133
  52. package/generated/profiler.d.ts +13 -23
  53. package/generated/render.d.ts +237 -297
  54. package/generated/resource.d.ts +664 -583
  55. package/generated/socket.d.ts +120 -133
  56. package/generated/sound.d.ts +62 -31
  57. package/generated/sprite.d.ts +31 -17
  58. package/generated/sys.d.ts +234 -190
  59. package/generated/tilemap.d.ts +21 -16
  60. package/generated/timer.d.ts +34 -21
  61. package/generated/versions/defold-1.12.4/b2d_body.d.ts +0 -7
  62. package/generated/versions/defold-1.12.4/buffer.d.ts +1 -3
  63. package/generated/versions/defold-1.12.4/camera.d.ts +21 -21
  64. package/generated/versions/defold-1.12.4/collectionfactory.d.ts +9 -9
  65. package/generated/versions/defold-1.12.4/collectionproxy.d.ts +2 -2
  66. package/generated/versions/defold-1.12.4/crash.d.ts +2 -2
  67. package/generated/versions/defold-1.12.4/factory.d.ts +15 -16
  68. package/generated/versions/defold-1.12.4/go.d.ts +6 -12
  69. package/generated/versions/defold-1.12.4/gui.d.ts +77 -175
  70. package/generated/versions/defold-1.12.4/html5.d.ts +1 -1
  71. package/generated/versions/defold-1.12.4/http.d.ts +0 -13
  72. package/generated/versions/defold-1.12.4/image.d.ts +16 -33
  73. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  74. package/generated/versions/defold-1.12.4/json.d.ts +10 -6
  75. package/generated/versions/defold-1.12.4/label.d.ts +2 -3
  76. package/generated/versions/defold-1.12.4/liveupdate.d.ts +5 -3
  77. package/generated/versions/defold-1.12.4/model.d.ts +2 -10
  78. package/generated/versions/defold-1.12.4/particlefx.d.ts +2 -5
  79. package/generated/versions/defold-1.12.4/physics.d.ts +69 -67
  80. package/generated/versions/defold-1.12.4/profiler.d.ts +2 -5
  81. package/generated/versions/defold-1.12.4/render.d.ts +99 -128
  82. package/generated/versions/defold-1.12.4/resource.d.ts +120 -148
  83. package/generated/versions/defold-1.12.4/socket.d.ts +34 -60
  84. package/generated/versions/defold-1.12.4/sound.d.ts +8 -8
  85. package/generated/versions/defold-1.12.4/sprite.d.ts +15 -5
  86. package/generated/versions/defold-1.12.4/sys.d.ts +37 -71
  87. package/generated/versions/defold-1.12.4/tilemap.d.ts +18 -11
  88. package/generated/versions/defold-1.12.4/timer.d.ts +5 -3
  89. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -21
  90. package/generated/versions/defold-1.12.4/window.d.ts +1 -16
  91. package/generated/versions/defold-1.13.0/b2d_body.d.ts +10 -55
  92. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +25 -25
  93. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +169 -8
  94. package/generated/versions/defold-1.13.0/b2d_world.d.ts +16 -10
  95. package/generated/versions/defold-1.13.0/buffer.d.ts +1 -3
  96. package/generated/versions/defold-1.13.0/camera.d.ts +25 -25
  97. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +9 -9
  98. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +2 -2
  99. package/generated/versions/defold-1.13.0/compute.d.ts +0 -69
  100. package/generated/versions/defold-1.13.0/crash.d.ts +2 -2
  101. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +3 -3
  102. package/generated/versions/defold-1.13.0/editor.d.ts +34 -24
  103. package/generated/versions/defold-1.13.0/factory.d.ts +15 -16
  104. package/generated/versions/defold-1.13.0/go.d.ts +6 -12
  105. package/generated/versions/defold-1.13.0/graphics.d.ts +73 -37
  106. package/generated/versions/defold-1.13.0/gui.d.ts +77 -175
  107. package/generated/versions/defold-1.13.0/html5.d.ts +1 -1
  108. package/generated/versions/defold-1.13.0/http.d.ts +0 -13
  109. package/generated/versions/defold-1.13.0/image.d.ts +16 -33
  110. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  111. package/generated/versions/defold-1.13.0/json.d.ts +10 -6
  112. package/generated/versions/defold-1.13.0/label.d.ts +2 -3
  113. package/generated/versions/defold-1.13.0/liveupdate.d.ts +7 -5
  114. package/generated/versions/defold-1.13.0/material.d.ts +68 -106
  115. package/generated/versions/defold-1.13.0/model.d.ts +2 -10
  116. package/generated/versions/defold-1.13.0/particlefx.d.ts +2 -5
  117. package/generated/versions/defold-1.13.0/physics.d.ts +69 -67
  118. package/generated/versions/defold-1.13.0/profiler.d.ts +2 -5
  119. package/generated/versions/defold-1.13.0/render.d.ts +99 -128
  120. package/generated/versions/defold-1.13.0/resource.d.ts +126 -150
  121. package/generated/versions/defold-1.13.0/socket.d.ts +34 -60
  122. package/generated/versions/defold-1.13.0/sound.d.ts +8 -8
  123. package/generated/versions/defold-1.13.0/sprite.d.ts +15 -5
  124. package/generated/versions/defold-1.13.0/sys.d.ts +37 -71
  125. package/generated/versions/defold-1.13.0/tilemap.d.ts +18 -11
  126. package/generated/versions/defold-1.13.0/timer.d.ts +5 -3
  127. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -21
  128. package/generated/versions/defold-1.13.0/window.d.ts +1 -16
  129. package/generated/versions/defold-1.13.1/b2d.d.ts +33 -0
  130. package/generated/versions/defold-1.13.1/b2d_body.d.ts +636 -0
  131. package/generated/versions/defold-1.13.1/b2d_chain.d.ts +106 -0
  132. package/generated/versions/defold-1.13.1/b2d_fixture.d.ts +157 -0
  133. package/generated/versions/defold-1.13.1/b2d_joint.d.ts +823 -0
  134. package/generated/versions/defold-1.13.1/b2d_shape.d.ts +400 -0
  135. package/generated/versions/defold-1.13.1/b2d_world.d.ts +320 -0
  136. package/generated/versions/defold-1.13.1/buffer.d.ts +189 -0
  137. package/generated/versions/defold-1.13.1/camera.d.ts +303 -0
  138. package/generated/versions/defold-1.13.1/collectionfactory.d.ts +151 -0
  139. package/generated/versions/defold-1.13.1/collectionproxy.d.ts +93 -0
  140. package/generated/versions/defold-1.13.1/compute.d.ts +237 -0
  141. package/generated/versions/defold-1.13.1/crash.d.ts +143 -0
  142. package/generated/versions/defold-1.13.1/editor-vm/http.d.ts +56 -0
  143. package/generated/versions/defold-1.13.1/editor-vm/image.d.ts +48 -0
  144. package/generated/versions/defold-1.13.1/editor-vm/json.d.ts +10 -0
  145. package/generated/versions/defold-1.13.1/editor-vm/localization.d.ts +42 -0
  146. package/generated/versions/defold-1.13.1/editor-vm/tilemap_tiles.d.ts +80 -0
  147. package/generated/versions/defold-1.13.1/editor-vm/zip.d.ts +10 -0
  148. package/generated/versions/defold-1.13.1/editor-vm/zlib.d.ts +24 -0
  149. package/generated/versions/defold-1.13.1/editor.d.ts +1121 -0
  150. package/generated/versions/defold-1.13.1/factory.d.ts +124 -0
  151. package/generated/versions/defold-1.13.1/font.d.ts +81 -0
  152. package/generated/versions/defold-1.13.1/go.d.ts +1107 -0
  153. package/generated/versions/defold-1.13.1/graphics.d.ts +411 -0
  154. package/generated/versions/defold-1.13.1/gui.d.ts +2353 -0
  155. package/generated/versions/defold-1.13.1/html5.d.ts +55 -0
  156. package/generated/versions/defold-1.13.1/http.d.ts +77 -0
  157. package/generated/versions/defold-1.13.1/image.d.ts +131 -0
  158. package/generated/versions/defold-1.13.1/index.d.ts +57 -0
  159. package/generated/versions/defold-1.13.1/json.d.ts +80 -0
  160. package/generated/versions/defold-1.13.1/kinds/editor-script.d.ts +14 -0
  161. package/generated/versions/defold-1.13.1/label.d.ts +93 -0
  162. package/generated/versions/defold-1.13.1/liveupdate.d.ts +142 -0
  163. package/generated/versions/defold-1.13.1/material.d.ts +408 -0
  164. package/generated/versions/defold-1.13.1/model.d.ts +272 -0
  165. package/generated/versions/defold-1.13.1/msg.d.ts +10 -0
  166. package/generated/versions/defold-1.13.1/particlefx.d.ts +163 -0
  167. package/generated/versions/defold-1.13.1/physics.d.ts +559 -0
  168. package/generated/versions/defold-1.13.1/profiler.d.ts +235 -0
  169. package/generated/versions/defold-1.13.1/render.d.ts +1190 -0
  170. package/generated/versions/defold-1.13.1/resource.d.ts +1523 -0
  171. package/generated/versions/defold-1.13.1/socket.d.ts +784 -0
  172. package/generated/versions/defold-1.13.1/sound.d.ts +292 -0
  173. package/generated/versions/defold-1.13.1/sprite.d.ts +175 -0
  174. package/generated/versions/defold-1.13.1/sys.d.ts +678 -0
  175. package/generated/versions/defold-1.13.1/tilemap.d.ts +208 -0
  176. package/generated/versions/defold-1.13.1/timer.d.ts +125 -0
  177. package/generated/versions/defold-1.13.1/types.d.ts +61 -0
  178. package/generated/versions/defold-1.13.1/vmath.d.ts +774 -0
  179. package/generated/versions/defold-1.13.1/window.d.ts +183 -0
  180. package/generated/versions/defold-1.13.1/zlib.d.ts +41 -0
  181. package/generated/vmath.d.ts +1 -21
  182. package/generated/window.d.ts +71 -71
  183. package/identity-vocabulary.json +561 -0
  184. package/index.d.ts +7 -0
  185. package/package.json +18 -2
  186. package/scripts/example-store-io.ts +12 -1
  187. package/scripts/extension-goldens.ts +1 -0
  188. package/scripts/fidelity-baseline.json +146 -46
  189. package/scripts/generate-api-availability.ts +90 -12
  190. package/scripts/generate-api-signatures.ts +12 -2
  191. package/scripts/import-defold-release.ts +106 -26
  192. package/scripts/prose-constants.ts +77 -16
  193. package/scripts/regen.ts +391 -77
  194. package/scripts/shared-handle-methods.ts +53 -0
  195. package/scripts/signature-store-fs.ts +1 -0
  196. package/scripts/sync-api-docs.ts +48 -10
  197. package/src/api-availability.ts +0 -0
  198. package/src/api-doc.ts +201 -3
  199. package/src/api-identity.ts +252 -0
  200. package/src/core-types.ts +26 -3
  201. package/src/correction-pins.ts +49 -0
  202. package/src/doc-comment.ts +104 -11
  203. package/src/doc-corrections.ts +108 -0
  204. package/src/editor-vm-globals.d.ts +5 -2
  205. package/src/emit-dts.ts +2064 -281
  206. package/src/emit-messages.ts +52 -0
  207. package/src/example-store.ts +125 -14
  208. package/src/field-correction-coverage.ts +204 -0
  209. package/src/fnv1a.ts +16 -0
  210. package/src/go-overloads.d.ts +25 -6
  211. package/src/index-base-table.ts +145 -0
  212. package/src/index-slot-classifications.ts +588 -0
  213. package/src/index.ts +38 -5
  214. package/src/library-index-slot-classifications.ts +332 -0
  215. package/src/lifecycle.ts +61 -199
  216. package/src/luals-type-expr.ts +354 -0
  217. package/src/msg-overloads.d.ts +0 -1
  218. package/src/param-correction-provenance.ts +8 -11
  219. package/src/render-overloads.d.ts +0 -15
  220. package/src/return-correction-provenance.ts +58 -16
  221. package/src/sys-overloads.d.ts +48 -0
  222. package/src/vmath-overloads.d.ts +27 -1
  223. package/src/window-event-guard.d.ts +6 -9
  224. package/url-parameters.json +1 -2
@@ -6,13 +6,135 @@ declare global {
6
6
  * Rendering API documentation
7
7
  */
8
8
  namespace render {
9
+ /**
10
+ * Render-camera options
11
+ */
12
+ interface camera_options {
13
+ /**
14
+ * Use the camera view-projection matrix for frustum culling. The default is false.
15
+ */
16
+ use_frustum?: boolean;
17
+ }
9
18
  type constant_buffer = Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
19
+ /**
20
+ * Debug-draw options
21
+ */
22
+ interface debug_draw_options {
23
+ /**
24
+ * Frustum matrix used for culling renderable items.
25
+ */
26
+ frustum?: Matrix4;
27
+ /**
28
+ * Frustum planes used for culling. The default is render.FRUSTUM_PLANES_SIDES.
29
+ */
30
+ frustum_planes?: render.FRUSTUM_PLANES;
31
+ }
32
+ /**
33
+ * Compute-dispatch options
34
+ */
35
+ interface dispatch_options {
36
+ /**
37
+ * Constants used by the compute program. The values are copied when `render.dispatch_compute()` is called.
38
+ */
39
+ constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
40
+ }
41
+ /**
42
+ * Render draw options
43
+ */
44
+ interface draw_options {
45
+ /**
46
+ * Frustum matrix used for culling renderable items.
47
+ */
48
+ frustum?: Matrix4;
49
+ /**
50
+ * Frustum planes used for culling. The default is render.FRUSTUM_PLANES_SIDES.
51
+ */
52
+ frustum_planes?: render.FRUSTUM_PLANES;
53
+ /**
54
+ * Constants used while rendering. The values are copied when `render.draw()` is called.
55
+ */
56
+ constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
57
+ /**
58
+ * World-entry sort order. The default is the renderer's preferred back-to-front order.
59
+ */
60
+ sort_order?: render.SORT;
61
+ }
62
+ type render_predicate = number;
10
63
  type render_target = Opaque<"render_target">;
64
+ /**
65
+ * Render-target attachment parameters
66
+ */
67
+ interface render_target_buffer_params {
68
+ /**
69
+ * Attachment texture format.
70
+ */
71
+ format: graphics.TEXTURE_FORMAT;
72
+ /**
73
+ * Attachment width.
74
+ */
75
+ width: number;
76
+ /**
77
+ * Attachment height.
78
+ */
79
+ height: number;
80
+ /**
81
+ * Minification filter.
82
+ */
83
+ min_filter?: graphics.TEXTURE_FILTER;
84
+ /**
85
+ * Magnification filter.
86
+ */
87
+ mag_filter?: graphics.TEXTURE_FILTER;
88
+ /**
89
+ * Horizontal wrap mode.
90
+ */
91
+ u_wrap?: graphics.TEXTURE_WRAP;
92
+ /**
93
+ * Vertical wrap mode.
94
+ */
95
+ v_wrap?: graphics.TEXTURE_WRAP;
96
+ /**
97
+ * Depth wrap mode.
98
+ */
99
+ w_wrap?: graphics.TEXTURE_WRAP;
100
+ /**
101
+ * Attachment creation flags, applicable only to depth and stencil buffers.
102
+ */
103
+ flags?: render.RENDER_TARGET_FLAG | number;
104
+ }
105
+ type render_target_params = { sample_count?: number } & { [key: number]: render.render_target_buffer_params };
106
+ /**
107
+ * Render-target activation options
108
+ */
109
+ interface set_render_target_options {
110
+ /**
111
+ * Buffers whose contents become undefined after the target is deactivated. Missing buffers are ignored; combined depth-stencil buffers remain non-transient unless both are selected.
112
+ */
113
+ transient?: graphics.BUFFER_TYPE[];
114
+ }
11
115
  type texture = Opaque<"texture">;
12
116
  type ClearBufferKey = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
117
+ type CONTEXT_EVENT = typeof render.CONTEXT_EVENT_CONTEXT_LOST | typeof render.CONTEXT_EVENT_CONTEXT_RESTORED;
118
+ type FRUSTUM_PLANES = typeof render.FRUSTUM_PLANES_ALL | typeof render.FRUSTUM_PLANES_SIDES;
119
+ type RENDER_TARGET_FLAG = typeof render.TEXTURE_BIT;
120
+ type SORT = typeof render.SORT_BACK_TO_FRONT | typeof render.SORT_FRONT_TO_BACK | typeof render.SORT_NONE;
121
+ /**
122
+ * rendering context was lost; rendering pauses and graphics resources become invalid
123
+ */
124
+ const CONTEXT_EVENT_CONTEXT_LOST: number & { readonly __brand: "render.CONTEXT_EVENT_CONTEXT_LOST" };
125
+ /**
126
+ * rendering context was restored; rendering remains paused while resources can be reloaded
127
+ */
128
+ const CONTEXT_EVENT_CONTEXT_RESTORED: number & { readonly __brand: "render.CONTEXT_EVENT_CONTEXT_RESTORED" };
129
+ /**
130
+ * All six frustum planes.
131
+ */
13
132
  const FRUSTUM_PLANES_ALL: number & { readonly __brand: "render.FRUSTUM_PLANES_ALL" };
133
+ /**
134
+ * Left, right, top, and bottom frustum planes.
135
+ */
14
136
  const FRUSTUM_PLANES_SIDES: number & { readonly __brand: "render.FRUSTUM_PLANES_SIDES" };
15
- const RENDER_TARGET_DEFAULT: number & { readonly __brand: "render.RENDER_TARGET_DEFAULT" };
137
+ const RENDER_TARGET_DEFAULT: undefined;
16
138
  /**
17
139
  * Depth sort far-to-near (default; good for transparent passes).
18
140
  */
@@ -25,6 +147,10 @@ declare global {
25
147
  * No per-call sorting; draw entries in insertion order.
26
148
  */
27
149
  const SORT_NONE: number & { readonly __brand: "render.SORT_NONE" };
150
+ /**
151
+ * Create a texture-backed depth or stencil attachment.
152
+ */
153
+ const TEXTURE_BIT: number & { readonly __brand: "render.TEXTURE_BIT" };
28
154
  /**
29
155
  * Clear buffers in the currently enabled render target with specified value. If the render target has been created with multiple
30
156
  * color attachments, all buffers will be cleared with the same value.
@@ -32,9 +158,7 @@ declare global {
32
158
  * @param buffers - table with keys specifying which buffers to clear and values set to clear values. Available keys are:
33
159
  *
34
160
  * - `graphics.BUFFER_TYPE_COLOR0_BIT`
35
- *
36
161
  * - `graphics.BUFFER_TYPE_DEPTH_BIT`
37
- *
38
162
  * - `graphics.BUFFER_TYPE_STENCIL_BIT`
39
163
  * @example
40
164
  * ```ts
@@ -52,39 +176,41 @@ declare global {
52
176
  *
53
177
  * @returns new constant buffer
54
178
  * @example
179
+ * Set a "tint" constant in a constant buffer in the render script:
55
180
  * ```ts
56
- * export default defineRenderScript({
57
- * init() {
58
- * return { my_pred: render.predicate([hash("my_tag")]) };
59
- * },
60
- *
61
- * update(self, dt) {
62
- * // Set a "tint" constant in a constant buffer in the render script:
63
- * const constants = render.constant_buffer();
64
- * constants.tint = vmath.vector4(1, 1, 1, 1);
65
- *
66
- * // Then use the constant buffer when drawing a predicate:
67
- * render.draw(self.my_pred, { constants });
68
- *
69
- * // The constant buffer also supports array values by specifying constants in an array:
70
- * const constants2 = render.constant_buffer();
71
- * constants2.light_colors = [];
72
- * constants2.light_colors[0] = vmath.vector4(1, 0, 0, 1);
73
- * constants2.light_colors[1] = vmath.vector4(0, 1, 0, 1);
74
- * constants2.light_colors[2] = vmath.vector4(0, 0, 1, 1);
75
- *
76
- * // You can also create the array by passing the vectors directly:
77
- * const constants3 = render.constant_buffer();
78
- * constants3.light_colors = [
79
- * vmath.vector4(1, 0, 0, 1),
80
- * vmath.vector4(0, 1, 0, 1),
81
- * vmath.vector4(0, 0, 1, 1),
82
- * ];
83
- *
84
- * // Add more constants to the array
85
- * constants3.light_colors[3] = vmath.vector4(1, 1, 1, 1);
86
- * },
87
- * });
181
+ * const constants = render.constant_buffer();
182
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
183
+ * ```
184
+ * @example
185
+ * Then use the constant buffer when drawing a predicate:
186
+ * ```ts
187
+ * function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
188
+ * const constants = render.constant_buffer();
189
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
190
+ * render.draw(self.my_pred, { constants });
191
+ * }
192
+ * ```
193
+ * @example
194
+ * The constant buffer also supports array values by specifying constants in a table:
195
+ * ```ts
196
+ * const constants = render.constant_buffer();
197
+ * constants.light_colors = [];
198
+ * constants.light_colors[0] = vmath.vector4(1, 0, 0, 1);
199
+ * constants.light_colors[1] = vmath.vector4(0, 1, 0, 1);
200
+ * constants.light_colors[2] = vmath.vector4(0, 0, 1, 1);
201
+ * ```
202
+ * @example
203
+ * You can also create the table by passing the vectors directly when creating the table:
204
+ * ```ts
205
+ * const constants = render.constant_buffer();
206
+ * constants.light_colors = [
207
+ * vmath.vector4(1, 0, 0, 1),
208
+ * vmath.vector4(0, 1, 0, 1),
209
+ * vmath.vector4(0, 0, 1, 1),
210
+ * ];
211
+ *
212
+ * // Add more constants to the array
213
+ * constants.light_colors[3] = vmath.vector4(1, 1, 1, 1);
88
214
  * ```
89
215
  */
90
216
  function constant_buffer(): Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] };
@@ -136,15 +262,10 @@ declare global {
136
262
  * @param state - state to disable
137
263
  *
138
264
  * - `graphics.STATE_DEPTH_TEST`
139
- *
140
265
  * - `graphics.STATE_STENCIL_TEST`
141
- *
142
266
  * - `graphics.STATE_BLEND`
143
- *
144
267
  * - `graphics.STATE_ALPHA_TEST` ( not available on iOS and Android)
145
- *
146
268
  * - `graphics.STATE_CULL_FACE`
147
- *
148
269
  * - `graphics.STATE_POLYGON_OFFSET_FILL`
149
270
  * @example
150
271
  * ```ts
@@ -161,7 +282,7 @@ declare global {
161
282
  * });
162
283
  * ```
163
284
  */
164
- function disable_state(state: graphics.State): void;
285
+ function disable_state(state: graphics.STATE): void;
165
286
  /**
166
287
  * Disables a texture that has previourly been enabled.
167
288
  *
@@ -203,10 +324,7 @@ declare global {
203
324
  * @param x - global work group size X
204
325
  * @param y - global work group size Y
205
326
  * @param z - global work group size Z
206
- * @param options - optional table with properties:
207
- *
208
- * `constants`
209
- * constant_buffer optional constants to use while rendering
327
+ * @param options - optional compute-dispatch options
210
328
  * @example
211
329
  * ```ts
212
330
  * export default defineRenderScript({
@@ -230,14 +348,16 @@ declare global {
230
348
  * render.set_compute();
231
349
  * },
232
350
  * });
233
- *
234
- * // Dispatch a compute program with a constant buffer:
351
+ * ```
352
+ * @example
353
+ * Dispatch a compute program with a constant buffer:
354
+ * ```ts
235
355
  * const constants = render.constant_buffer();
236
356
  * constants.tint = vmath.vector4(1, 1, 1, 1);
237
357
  * render.dispatch_compute(32, 32, 32, { constants });
238
358
  * ```
239
359
  */
240
- function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] } }): void;
360
+ function dispatch_compute(x: number, y: number, z: number, options?: render.dispatch_options): void;
241
361
  /**
242
362
  * Draws all objects that match a specified predicate. An optional constant buffer can be
243
363
  * provided to override the default constants. If no constants buffer is provided, a default
@@ -245,67 +365,52 @@ declare global {
245
365
  * go.set (or particlefx.set_constant) on visual components.
246
366
  *
247
367
  * @param predicate - predicate to draw for
248
- * @param options - optional table with properties:
249
- *
250
- * `frustum`
251
- * matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). default=nil
252
- * `frustum_planes`
253
- * int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
254
- *
255
- * - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
256
- *
257
- * - render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
258
- *
259
- * `constants`
260
- * constant_buffer optional constants to use while rendering
261
- * `sort_order`
262
- * int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
368
+ * @param options - optional draw options
263
369
  * @example
264
370
  * ```ts
265
371
  * export default defineRenderScript({
266
372
  * init() {
267
- * return {
268
- * // define a predicate matching anything with material tag "my_tag"
269
- * my_pred: render.predicate([hash("my_tag")]),
270
- * proj: vmath.matrix4_perspective(math.rad(45), render.get_window_width() / render.get_window_height(), 0.1, 1000),
271
- * view: vmath.matrix4_look_at(vmath.vector3(0, 0, 10), vmath.vector3(0, 0, 0), vmath.vector3(0, 1, 0)),
272
- * };
373
+ * // define a predicate matching anything with material tag "my_tag"
374
+ * return { my_pred: render.predicate([hash("my_tag")]) };
273
375
  * },
274
376
  *
275
377
  * update(self, dt) {
276
378
  * // draw everything in the my_pred predicate
277
379
  * render.draw(self.my_pred);
278
- *
279
- * // Draw predicate with constants:
280
- * const constants = render.constant_buffer();
281
- * constants.tint = vmath.vector4(1, 1, 1, 1);
282
- * render.draw(self.my_pred, { constants });
283
- *
284
- * // Draw with predicate and frustum culling (without near+far planes):
285
- * const frustum = self.proj.mul(self.view);
286
- * render.draw(self.my_pred, { frustum });
287
- *
288
- * // Draw with predicate and frustum culling (with near+far planes):
289
- * const frustum2 = self.proj.mul(self.view);
290
- * render.draw(self.my_pred, { frustum: frustum2, frustum_planes: render.FRUSTUM_PLANES_ALL });
291
380
  * },
292
381
  * });
293
382
  * ```
383
+ * @example
384
+ * Draw predicate with constants:
385
+ * ```ts
386
+ * function draw_tinted(self: { my_pred: Opaque<"render_predicate"> }) {
387
+ * const constants = render.constant_buffer();
388
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
389
+ * render.draw(self.my_pred, { constants });
390
+ * }
391
+ * ```
392
+ * @example
393
+ * Draw with predicate and frustum culling (without near+far planes):
394
+ * ```ts
395
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
396
+ * const frustum = self.proj.mul(self.view);
397
+ * render.draw(self.my_pred, { frustum });
398
+ * }
399
+ * ```
400
+ * @example
401
+ * Draw with predicate and frustum culling (with near+far planes):
402
+ * ```ts
403
+ * function draw_culled(self: { my_pred: Opaque<"render_predicate">; proj: Matrix4; view: Matrix4 }) {
404
+ * const frustum = self.proj.mul(self.view);
405
+ * render.draw(self.my_pred, { frustum, frustum_planes: render.FRUSTUM_PLANES_ALL });
406
+ * }
407
+ * ```
294
408
  */
295
- function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer"> & { [name: string]: Vector4 | Matrix4 | Vector4[] | Matrix4[] }; sort_order?: number }): void;
409
+ function draw(predicate: Opaque<"render_predicate">, options?: render.draw_options): void;
296
410
  /**
297
411
  * Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
298
412
  *
299
- * @param options - optional table with properties:
300
- *
301
- * `frustum`
302
- * matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). May be nil.
303
- * `frustum_planes`
304
- * int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
305
- *
306
- * - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
307
- *
308
- * - render.FRUSTUM_PLANES_ALL : All sides of the frustum.
413
+ * @param options - optional debug-draw options
309
414
  * @example
310
415
  * ```ts
311
416
  * export default defineRenderScript({
@@ -316,7 +421,7 @@ declare global {
316
421
  * });
317
422
  * ```
318
423
  */
319
- function draw_debug3d(options?: { frustum?: Matrix4; frustum_planes?: number }): void;
424
+ function draw_debug3d(options?: render.debug_draw_options): void;
320
425
  /**
321
426
  * If another material was already enabled, it will be automatically disabled
322
427
  * and the specified material is used instead.
@@ -347,15 +452,10 @@ declare global {
347
452
  * @param state - state to enable
348
453
  *
349
454
  * - `graphics.STATE_DEPTH_TEST`
350
- *
351
455
  * - `graphics.STATE_STENCIL_TEST`
352
- *
353
456
  * - `graphics.STATE_BLEND`
354
- *
355
457
  * - `graphics.STATE_ALPHA_TEST` ( not available on iOS and Android)
356
- *
357
458
  * - `graphics.STATE_CULL_FACE`
358
- *
359
459
  * - `graphics.STATE_POLYGON_OFFSET_FILL`
360
460
  * @example
361
461
  * ```ts
@@ -373,7 +473,7 @@ declare global {
373
473
  * });
374
474
  * ```
375
475
  */
376
- function enable_state(state: graphics.State): void;
476
+ function enable_state(state: graphics.STATE): void;
377
477
  /**
378
478
  * Sets the specified texture handle for a render target attachment or a regular texture
379
479
  * that should be used for rendering. The texture can be bound to either a texture unit
@@ -389,26 +489,7 @@ declare global {
389
489
  *
390
490
  * @param binding - texture binding, either by texture unit, string or hash for the sampler name that the texture should be bound to
391
491
  * @param handle_or_name - render target or texture handle that should be bound, or a named resource in the "Render Resource" table in the currently assigned .render file
392
- * @param buffer_type - optional buffer type from which to enable the texture. Note that this argument only applies to render targets. Defaults to `graphics.BUFFER_TYPE_COLOR0_BIT`. These values are supported:
393
- *
394
- * - `graphics.BUFFER_TYPE_COLOR0_BIT`
395
- *
396
- * If The render target has been created as depth and/or stencil textures, these buffer types can be used:
397
- *
398
- * - `graphics.BUFFER_TYPE_DEPTH_BIT`
399
- *
400
- * - `graphics.BUFFER_TYPE_STENCIL_BIT`
401
- *
402
- * If the render target has been created with multiple color attachments, these buffer types can be used
403
- * to enable those textures as well. Currently 4 color attachments are supported:
404
- *
405
- * - `graphics.BUFFER_TYPE_COLOR0_BIT`
406
- *
407
- * - `graphics.BUFFER_TYPE_COLOR1_BIT`
408
- *
409
- * - `graphics.BUFFER_TYPE_COLOR2_BIT`
410
- *
411
- * - `graphics.BUFFER_TYPE_COLOR3_BIT`
492
+ * @param buffer_type - optional render-target attachment. Defaults to `graphics.BUFFER_TYPE_COLOR0_BIT`. Depth and stencil attachments must have been created as textures; color attachments beyond the first require a render target with multiple color attachments (up to four are supported).
412
493
  * @example
413
494
  * ```ts
414
495
  * export default defineRenderScript({
@@ -478,7 +559,7 @@ declare global {
478
559
  * });
479
560
  * ```
480
561
  */
481
- function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash | Opaque<"render_target"> | number, buffer_type?: graphics.BufferType): void;
562
+ function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash | Opaque<"render_target"> | number, buffer_type?: graphics.BUFFER_TYPE): void;
482
563
  /**
483
564
  * Returns the logical window height that is set in the "game.project" settings.
484
565
  * Note that the actual window pixel size can change, either by device constraints
@@ -499,9 +580,7 @@ declare global {
499
580
  * @param buffer_type - which type of buffer to retrieve the height from
500
581
  *
501
582
  * - `graphics.BUFFER_TYPE_COLOR0_BIT`
502
- *
503
583
  * - `graphics.BUFFER_TYPE_DEPTH_BIT`
504
- *
505
584
  * - `graphics.BUFFER_TYPE_STENCIL_BIT`
506
585
  * @returns the height of the render target buffer texture
507
586
  * @example
@@ -534,7 +613,7 @@ declare global {
534
613
  * });
535
614
  * ```
536
615
  */
537
- function get_render_target_height(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
616
+ function get_render_target_height(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BUFFER_TYPE): number;
538
617
  /**
539
618
  * Returns the specified buffer width from a render target.
540
619
  *
@@ -542,11 +621,8 @@ declare global {
542
621
  * @param buffer_type - which type of buffer to retrieve the width from
543
622
  *
544
623
  * - `graphics.BUFFER_TYPE_COLOR0_BIT`
545
- *
546
624
  * - `graphics.BUFFER_TYPE_COLOR[x]_BIT` (x: [0..3], if supported!)
547
- *
548
625
  * - `graphics.BUFFER_TYPE_DEPTH_BIT`
549
- *
550
626
  * - `graphics.BUFFER_TYPE_STENCIL_BIT`
551
627
  * @returns the width of the render target buffer texture
552
628
  * @example
@@ -579,13 +655,13 @@ declare global {
579
655
  * });
580
656
  * ```
581
657
  */
582
- function get_render_target_width(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BufferType): number;
658
+ function get_render_target_width(render_target: Opaque<"render_target"> | string | Hash, buffer_type: graphics.BUFFER_TYPE): number;
583
659
  /**
584
660
  * Returns the logical window width that is set in the "game.project" settings.
585
661
  * Note that the actual window pixel size can change, either by device constraints
586
662
  * or user input.
587
663
  *
588
- * @returns specified window width (number)
664
+ * @returns specified window width
589
665
  * @example
590
666
  * ```ts
591
667
  * // Get the width of the window.
@@ -635,7 +711,7 @@ declare global {
635
711
  * const p = render.predicate([hash("opaque"), hash("smoke")]);
636
712
  * ```
637
713
  */
638
- function predicate(tags: (string | Hash)[]): number;
714
+ function predicate(tags: (string | Hash)[]): Opaque<"render_predicate">;
639
715
  /**
640
716
  * Sets the blend equation with separate equations for the color and alpha channels.
641
717
  *
@@ -646,7 +722,7 @@ declare global {
646
722
  * render.set_blend_equation_separate(graphics.BLEND_EQUATION_ADD, graphics.BLEND_EQUATION_REVERSE_SUBTRACT);
647
723
  * ```
648
724
  */
649
- function set_blend_equation_separate(equation_color: number, equation_alpha: number): void;
725
+ function set_blend_equation_separate(equation_color: graphics.BLEND_EQUATION, equation_alpha: graphics.BLEND_EQUATION): void;
650
726
  /**
651
727
  * Specifies the arithmetic used when computing pixel values that are written to the frame
652
728
  * buffer. In RGBA mode, pixels can be drawn using a function that blends the source RGBA
@@ -661,64 +737,11 @@ declare global {
661
737
  * The source scale factor is referred to as (sR,sG,sB,sA).
662
738
  * The destination scale factor is referred to as (dR,dG,dB,dA).
663
739
  * The color values have integer values between 0 and (kR,kG,kB,kA), where kc = 2mc - 1 and mc is the number of bitplanes for that color. I.e for 8 bit color depth, color values are between `0` and `255`.
664
- * Available factor constants and corresponding scale factors:
665
- *
666
- * Factor constant
667
- * Scale factor (fR,fG,fB,fA)
668
- *
669
- * `graphics.BLEND_FACTOR_ZERO`
670
- * (0,0,0,0)
671
- *
672
- * `graphics.BLEND_FACTOR_ONE`
673
- * (1,1,1,1)
674
- *
675
- * `graphics.BLEND_FACTOR_SRC_COLOR`
676
- * (Rs/kR,Gs/kG,Bs/kB,As/kA)
677
- *
678
- * `graphics.BLEND_FACTOR_ONE_MINUS_SRC_COLOR`
679
- * (1,1,1,1) - (Rs/kR,Gs/kG,Bs/kB,As/kA)
680
- *
681
- * `graphics.BLEND_FACTOR_DST_COLOR`
682
- * (Rd/kR,Gd/kG,Bd/kB,Ad/kA)
683
- *
684
- * `graphics.BLEND_FACTOR_ONE_MINUS_DST_COLOR`
685
- * (1,1,1,1) - (Rd/kR,Gd/kG,Bd/kB,Ad/kA)
686
- *
687
- * `graphics.BLEND_FACTOR_SRC_ALPHA`
688
- * (As/kA,As/kA,As/kA,As/kA)
689
- *
690
- * `graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA`
691
- * (1,1,1,1) - (As/kA,As/kA,As/kA,As/kA)
692
- *
693
- * `graphics.BLEND_FACTOR_DST_ALPHA`
694
- * (Ad/kA,Ad/kA,Ad/kA,Ad/kA)
695
- *
696
- * `graphics.BLEND_FACTOR_ONE_MINUS_DST_ALPHA`
697
- * (1,1,1,1) - (Ad/kA,Ad/kA,Ad/kA,Ad/kA)
698
- *
699
- * `graphics.BLEND_FACTOR_CONSTANT_COLOR`
700
- * (Rc,Gc,Bc,Ac)
701
- *
702
- * `graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR`
703
- * (1,1,1,1) - (Rc,Gc,Bc,Ac)
704
- *
705
- * `graphics.BLEND_FACTOR_CONSTANT_ALPHA`
706
- * (Ac,Ac,Ac,Ac)
707
- *
708
- * `graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA`
709
- * (1,1,1,1) - (Ac,Ac,Ac,Ac)
710
- *
711
- * `graphics.BLEND_FACTOR_SRC_ALPHA_SATURATE`
712
- * (i,i,i,1) where i = min(As, kA - Ad) /kA
713
- *
714
740
  * The blended RGBA values of a pixel comes from the following equations:
715
741
  *
716
742
  * - Rd = min(kR, Rs * sR + Rd * dR)
717
- *
718
743
  * - Gd = min(kG, Gs * sG + Gd * dG)
719
- *
720
744
  * - Bd = min(kB, Bs * sB + Bd * dB)
721
- *
722
745
  * - Ad = min(kA, As * sA + Ad * dA)
723
746
  *
724
747
  * Blend function `(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA)` is useful for
@@ -733,7 +756,7 @@ declare global {
733
756
  * render.set_blend_func(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
734
757
  * ```
735
758
  */
736
- function set_blend_func(source_factor: number, destination_factor: number): void;
759
+ function set_blend_func(source_factor: graphics.BLEND_FACTOR, destination_factor: graphics.BLEND_FACTOR): void;
737
760
  /**
738
761
  * Sets the blend function with separate blend factors for the color and alpha channels.
739
762
  *
@@ -757,34 +780,29 @@ declare global {
757
780
  * Note that the frustum plane option in render.draw can still be used together with the camera.
758
781
  *
759
782
  * @param camera - camera id to use, or nil to reset
760
- * @param options - optional table with properties:
761
- *
762
- * `use_frustum`
763
- * boolean If true, the renderer will use the cameras view-projection matrix for frustum culling (default: false)
783
+ * @param options - optional camera options
764
784
  * @example
785
+ * Set the current camera to be used for rendering
765
786
  * ```ts
766
- * export default defineRenderScript({
767
- * init() {
768
- * return { my_pred: render.predicate([hash("my_tag")]) };
769
- * },
770
- *
771
- * update(self, dt) {
772
- * // Set the current camera to be used for rendering
773
- * render.set_camera("main:/my_go#camera");
774
- * render.draw(self.my_pred);
775
- * render.set_camera(undefined);
776
- *
777
- * // Use the camera frustum for frustum culling together with a specific frustum plane option for the draw command
778
- * // The camera frustum will take precedence over the frustum plane option in render.draw
779
- * render.set_camera("main:/my_go#camera", { use_frustum: true });
780
- * // However, we can still customize the frustum planes regardless of the camera option!
781
- * render.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });
782
- * render.set_camera();
783
- * },
784
- * });
787
+ * function draw_through_camera(self: { my_pred: Opaque<"render_predicate"> }) {
788
+ * render.set_camera("main:/my_go#camera");
789
+ * render.draw(self.my_pred);
790
+ * render.set_camera(undefined);
791
+ * }
792
+ * ```
793
+ * @example
794
+ * Use the camera frustum for frustum culling together with a specific frustum plane option for the draw command
795
+ * ```ts
796
+ * function draw_through_camera(self: { my_pred: Opaque<"render_predicate"> }) {
797
+ * // The camera frustum will take precedence over the frustum plane option in render.draw
798
+ * render.set_camera("main:/my_go#camera", { use_frustum: true });
799
+ * // However, we can still customize the frustum planes regardless of the camera option!
800
+ * render.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });
801
+ * render.set_camera();
802
+ * }
785
803
  * ```
786
804
  */
787
- function set_camera(camera?: Url | number | string, options?: { use_frustum?: boolean }): void;
805
+ function set_camera(camera?: Url | number | string | Hash, options?: render.camera_options): void;
788
806
  /**
789
807
  * Specifies whether the individual color components in the frame buffer is enabled for writing (`true`) or disabled (`false`). For example, if `blue` is `false`, nothing is written to the blue component of any pixel in any of the color buffers, regardless of the drawing operation attempted. Note that writing are either enabled or disabled for entire color components, not the individual bits of a component.
790
808
  * The component masks are all initially `true`.
@@ -832,12 +850,6 @@ declare global {
832
850
  * `face_type` is `graphics.FACE_TYPE_BACK`.
833
851
  *
834
852
  * @param face_type - face type
835
- *
836
- * - `graphics.FACE_TYPE_FRONT`
837
- *
838
- * - `graphics.FACE_TYPE_BACK`
839
- *
840
- * - `graphics.FACE_TYPE_FRONT_AND_BACK`
841
853
  * @example
842
854
  * ```ts
843
855
  * // How to enable polygon culling and set front face culling:
@@ -845,30 +857,12 @@ declare global {
845
857
  * render.set_cull_face(graphics.FACE_TYPE_FRONT);
846
858
  * ```
847
859
  */
848
- function set_cull_face(face_type: number): void;
860
+ function set_cull_face(face_type: graphics.FACE_TYPE): void;
849
861
  /**
850
862
  * Specifies the function that should be used to compare each incoming pixel
851
863
  * depth value with the value present in the depth buffer.
852
864
  * The comparison is performed only if depth testing is enabled and specifies
853
865
  * the conditions under which a pixel will be drawn.
854
- * Function constants:
855
- *
856
- * - `graphics.COMPARE_FUNC_NEVER` (never passes)
857
- *
858
- * - `graphics.COMPARE_FUNC_LESS` (passes if the incoming depth value is less than the stored value)
859
- *
860
- * - `graphics.COMPARE_FUNC_LEQUAL` (passes if the incoming depth value is less than or equal to the stored value)
861
- *
862
- * - `graphics.COMPARE_FUNC_GREATER` (passes if the incoming depth value is greater than the stored value)
863
- *
864
- * - `graphics.COMPARE_FUNC_GEQUAL` (passes if the incoming depth value is greater than or equal to the stored value)
865
- *
866
- * - `graphics.COMPARE_FUNC_EQUAL` (passes if the incoming depth value is equal to the stored value)
867
- *
868
- * - `graphics.COMPARE_FUNC_NOTEQUAL` (passes if the incoming depth value is not equal to the stored value)
869
- *
870
- * - `graphics.COMPARE_FUNC_ALWAYS` (always passes)
871
- *
872
866
  * The depth function is initially set to `graphics.COMPARE_FUNC_LESS`.
873
867
  *
874
868
  * @param func - depth test function, see the description for available values
@@ -879,7 +873,7 @@ declare global {
879
873
  * render.set_depth_func(graphics.COMPARE_FUNC_NOTEQUAL);
880
874
  * ```
881
875
  */
882
- function set_depth_func(func: number): void;
876
+ function set_depth_func(func: graphics.COMPARE_FUNC): void;
883
877
  /**
884
878
  * Specifies whether the depth buffer is enabled for writing. The supplied mask governs
885
879
  * if depth buffer writing is enabled (`true`) or disabled (`false`).
@@ -894,18 +888,10 @@ declare global {
894
888
  */
895
889
  function set_depth_mask(depth: boolean): void;
896
890
  /**
897
- * Set or remove listener. Currenly only only two type of events can arrived:
898
- * `render.CONTEXT_EVENT_CONTEXT_LOST` - when rendering context lost. Rending paused and all graphics resources become invalid.
899
- * `render.CONTEXT_EVENT_CONTEXT_RESTORED` - when rendering context was restored. Rendering still paused and graphics resources still
900
- * invalid but can be reloaded.
891
+ * Set or remove the rendering-context event listener.
901
892
  *
902
893
  * @param callback - A callback that receives all render related events.
903
894
  * Pass `nil` if want to remove listener.
904
- *
905
- * `self`
906
- * object The render script
907
- * `event_type`
908
- * string Rendering event. Possible values: `render.CONTEXT_EVENT_CONTEXT_LOST`, `render.CONTEXT_EVENT_CONTEXT_RESTORED`
909
895
  * @example
910
896
  * ```ts
911
897
  * // Set listener and handle render context events.
@@ -923,7 +909,7 @@ declare global {
923
909
  * });
924
910
  * ```
925
911
  */
926
- function set_listener(callback?: (self: unknown, event_type: unknown) => void): void;
912
+ function set_listener(callback?: (self: unknown, event_type: render.CONTEXT_EVENT) => void): void;
927
913
  /**
928
914
  * Sets the scale and units used to calculate depth values.
929
915
  * If `graphics.STATE_POLYGON_OFFSET_FILL` is enabled, each fragment's depth value
@@ -969,19 +955,8 @@ declare global {
969
955
  * render target until it is replaced by a subsequent call to set_render_target.
970
956
  * This function supports render targets created by a render script, or a render target resource.
971
957
  *
972
- * @param render_target - render target to set. render.RENDER_TARGET_DEFAULT to set the default render target
973
- * @param options - optional table with behaviour parameters
974
- *
975
- * `transient`
976
- * table Transient frame buffer types are only valid while the render target is active, i.e becomes undefined when a new target is set by a subsequent call to set_render_target.
977
- * Default is all non-transient. Be aware that some hardware uses a combined depth stencil buffer and when this is the case both are considered non-transient if exclusively selected!
978
- * A buffer type defined that doesn't exist in the render target is silently ignored.
979
- *
980
- * - `graphics.BUFFER_TYPE_COLOR0_BIT`
981
- *
982
- * - `graphics.BUFFER_TYPE_DEPTH_BIT`
983
- *
984
- * - `graphics.BUFFER_TYPE_STENCIL_BIT`
958
+ * @param render_target - render target to set. Omit it, pass `nil`, or use render.RENDER_TARGET_DEFAULT to set the default render target
959
+ * @param options - optional render-target activation options
985
960
  * @example
986
961
  * How to set a render target and draw to it and then switch back to the default render target
987
962
  * The render target defines the depth/stencil buffers as transient, when set_render_target is called the next time the buffers may be invalidated and allow for optimisations depending on driver support
@@ -1036,7 +1011,7 @@ declare global {
1036
1011
  * });
1037
1012
  * ```
1038
1013
  */
1039
- function set_render_target(render_target: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: { transient?: graphics.BufferType[] }): void;
1014
+ function set_render_target(render_target?: Opaque<"render_target"> | string | Hash | typeof render.RENDER_TARGET_DEFAULT, options?: render.set_render_target_options): void;
1040
1015
  /**
1041
1016
  * Sets the render target size for a render target created from
1042
1017
  * either a render script, or from a render target resource.
@@ -1067,30 +1042,13 @@ declare global {
1067
1042
  * where to draw.
1068
1043
  * The stencil test discards a pixel based on the outcome of a comparison between the
1069
1044
  * reference value `ref` and the corresponding value in the stencil buffer.
1070
- * `func` specifies the comparison function. See the table below for values.
1045
+ * `func` specifies the comparison function.
1071
1046
  * The initial value is `graphics.COMPARE_FUNC_ALWAYS`.
1072
1047
  * `ref` specifies the reference value for the stencil test. The value is clamped to
1073
1048
  * the range [0, 2n-1], where n is the number of bitplanes in the stencil buffer.
1074
1049
  * The initial value is `0`.
1075
1050
  * `mask` is ANDed with both the reference value and the stored stencil value when the test
1076
1051
  * is done. The initial value is all `1`'s.
1077
- * Function constant:
1078
- *
1079
- * - `graphics.COMPARE_FUNC_NEVER` (never passes)
1080
- *
1081
- * - `graphics.COMPARE_FUNC_LESS` (passes if (ref & mask) < (stencil & mask))
1082
- *
1083
- * - `graphics.COMPARE_FUNC_LEQUAL` (passes if (ref & mask) <= (stencil & mask))
1084
- *
1085
- * - `graphics.COMPARE_FUNC_GREATER` (passes if (ref & mask) > (stencil & mask))
1086
- *
1087
- * - `graphics.COMPARE_FUNC_GEQUAL` (passes if (ref & mask) >= (stencil & mask))
1088
- *
1089
- * - `graphics.COMPARE_FUNC_EQUAL` (passes if (ref & mask) = (stencil & mask))
1090
- *
1091
- * - `graphics.COMPARE_FUNC_NOTEQUAL` (passes if (ref & mask) != (stencil & mask))
1092
- *
1093
- * - `graphics.COMPARE_FUNC_ALWAYS` (always passes)
1094
1052
  *
1095
1053
  * @param func - stencil test function, see the description for available values
1096
1054
  * @param ref - reference value for the stencil test
@@ -1101,7 +1059,7 @@ declare global {
1101
1059
  * render.set_stencil_func(graphics.COMPARE_FUNC_EQUAL, 0, 1);
1102
1060
  * ```
1103
1061
  */
1104
- function set_stencil_func(func: number, ref: number, mask: number): void;
1062
+ function set_stencil_func(func: graphics.COMPARE_FUNC, ref: number, mask: number): void;
1105
1063
  /**
1106
1064
  * The stencil mask controls the writing of individual bits in the stencil buffer.
1107
1065
  * The least significant `n` bits of the parameter `mask`, where `n` is the number of
@@ -1127,24 +1085,6 @@ declare global {
1127
1085
  * value while stenciling is enabled. If the stencil test fails, no change is made to the
1128
1086
  * pixel's color or depth buffers, and `sfail` specifies what happens to the stencil buffer
1129
1087
  * contents.
1130
- * Operator constants:
1131
- *
1132
- * - `graphics.STENCIL_OP_KEEP` (keeps the current value)
1133
- *
1134
- * - `graphics.STENCIL_OP_ZERO` (sets the stencil buffer value to 0)
1135
- *
1136
- * - `graphics.STENCIL_OP_REPLACE` (sets the stencil buffer value to `ref`, as specified by render.set_stencil_func)
1137
- *
1138
- * - `graphics.STENCIL_OP_INCR` (increments the stencil buffer value and clamp to the maximum representable unsigned value)
1139
- *
1140
- * - `graphics.STENCIL_OP_INCR_WRAP` (increments the stencil buffer value and wrap to zero when incrementing the maximum representable unsigned value)
1141
- *
1142
- * - `graphics.STENCIL_OP_DECR` (decrements the current stencil buffer value and clamp to 0)
1143
- *
1144
- * - `graphics.STENCIL_OP_DECR_WRAP` (decrements the current stencil buffer value and wrap to the maximum representable unsigned value when decrementing zero)
1145
- *
1146
- * - `graphics.STENCIL_OP_INVERT` (bitwise inverts the current stencil buffer value)
1147
- *
1148
1088
  * `dppass` and `dpfail` specify the stencil buffer actions depending on whether subsequent
1149
1089
  * depth buffer tests succeed (dppass) or fail (dpfail).
1150
1090
  * The initial value for all operators is `graphics.STENCIL_OP_KEEP`.
@@ -1161,7 +1101,7 @@ declare global {
1161
1101
  * render.set_stencil_op(graphics.STENCIL_OP_REPLACE, graphics.STENCIL_OP_KEEP, graphics.STENCIL_OP_KEEP);
1162
1102
  * ```
1163
1103
  */
1164
- function set_stencil_op(sfail: number, dpfail: number, dppass: number): void;
1104
+ function set_stencil_op(sfail: graphics.STENCIL_OP, dpfail: graphics.STENCIL_OP, dppass: graphics.STENCIL_OP): void;
1165
1105
  /**
1166
1106
  * Sets the view matrix to use when rendering.
1167
1107
  *