@defold-typescript/types 0.25.0 → 0.27.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 (80) hide show
  1. package/api-availability.json +333 -306
  2. package/api-signatures.json +1312 -0
  3. package/api-targets.json +351 -2
  4. package/examples/translations.json +1984 -0
  5. package/fixtures/messages_doc.json +880 -0
  6. package/generated/collectionproxy.d.ts +22 -0
  7. package/generated/editor-vm/http.d.ts +2 -2
  8. package/generated/editor-vm/image.d.ts +48 -0
  9. package/generated/editor.d.ts +27 -8
  10. package/generated/gui.d.ts +35 -6
  11. package/generated/kinds/editor-script.d.ts +1 -0
  12. package/generated/material.d.ts +4 -0
  13. package/generated/versions/defold-1.12.4/liveupdate.d.ts +22 -22
  14. package/generated/versions/defold-1.12.4/physics.d.ts +78 -75
  15. package/generated/versions/defold-1.12.4/render.d.ts +75 -55
  16. package/generated/versions/defold-1.12.4/resource.d.ts +187 -175
  17. package/generated/versions/defold-1.13.0/b2d.d.ts +33 -0
  18. package/generated/versions/defold-1.13.0/b2d_body.d.ts +676 -0
  19. package/generated/versions/defold-1.13.0/b2d_chain.d.ts +106 -0
  20. package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +155 -0
  21. package/generated/versions/defold-1.13.0/b2d_joint.d.ts +823 -0
  22. package/generated/versions/defold-1.13.0/b2d_shape.d.ts +215 -0
  23. package/generated/versions/defold-1.13.0/b2d_world.d.ts +314 -0
  24. package/generated/versions/defold-1.13.0/buffer.d.ts +176 -0
  25. package/generated/versions/defold-1.13.0/camera.d.ts +302 -0
  26. package/generated/versions/defold-1.13.0/collectionfactory.d.ts +146 -0
  27. package/generated/versions/defold-1.13.0/collectionproxy.d.ts +71 -0
  28. package/generated/versions/defold-1.13.0/compute.d.ts +306 -0
  29. package/generated/versions/defold-1.13.0/crash.d.ts +143 -0
  30. package/generated/versions/defold-1.13.0/editor-vm/http.d.ts +56 -0
  31. package/generated/versions/defold-1.13.0/editor-vm/json.d.ts +10 -0
  32. package/generated/versions/defold-1.13.0/editor-vm/localization.d.ts +42 -0
  33. package/generated/versions/defold-1.13.0/editor-vm/tilemap_tiles.d.ts +80 -0
  34. package/generated/versions/defold-1.13.0/editor-vm/zip.d.ts +10 -0
  35. package/generated/versions/defold-1.13.0/editor-vm/zlib.d.ts +24 -0
  36. package/generated/versions/defold-1.13.0/editor.d.ts +1092 -0
  37. package/generated/versions/defold-1.13.0/factory.d.ts +123 -0
  38. package/generated/versions/defold-1.13.0/font.d.ts +81 -0
  39. package/generated/versions/defold-1.13.0/go.d.ts +1054 -0
  40. package/generated/versions/defold-1.13.0/graphics.d.ts +321 -0
  41. package/generated/versions/defold-1.13.0/gui.d.ts +2370 -0
  42. package/generated/versions/defold-1.13.0/html5.d.ts +53 -0
  43. package/generated/versions/defold-1.13.0/http.d.ts +84 -0
  44. package/generated/versions/defold-1.13.0/iac.d.ts +18 -0
  45. package/generated/versions/defold-1.13.0/iap.d.ts +60 -0
  46. package/generated/versions/defold-1.13.0/image.d.ts +139 -0
  47. package/generated/versions/defold-1.13.0/index.d.ts +48 -0
  48. package/generated/versions/defold-1.13.0/json.d.ts +76 -0
  49. package/generated/versions/defold-1.13.0/kinds/editor-script.d.ts +13 -0
  50. package/generated/versions/defold-1.13.0/label.d.ts +94 -0
  51. package/generated/versions/defold-1.13.0/liveupdate.d.ts +140 -0
  52. package/generated/versions/defold-1.13.0/material.d.ts +444 -0
  53. package/generated/versions/defold-1.13.0/model.d.ts +246 -0
  54. package/generated/versions/defold-1.13.0/msg.d.ts +10 -0
  55. package/generated/versions/defold-1.13.0/particlefx.d.ts +166 -0
  56. package/generated/versions/defold-1.13.0/physics.d.ts +548 -0
  57. package/generated/versions/defold-1.13.0/profiler.d.ts +233 -0
  58. package/generated/versions/defold-1.13.0/push.d.ts +66 -0
  59. package/generated/versions/defold-1.13.0/render.d.ts +1185 -0
  60. package/generated/versions/defold-1.13.0/resource.d.ts +1530 -0
  61. package/generated/versions/defold-1.13.0/socket.d.ts +795 -0
  62. package/generated/versions/defold-1.13.0/sound.d.ts +291 -0
  63. package/generated/versions/defold-1.13.0/sprite.d.ts +157 -0
  64. package/generated/versions/defold-1.13.0/sys.d.ts +695 -0
  65. package/generated/versions/defold-1.13.0/tilemap.d.ts +195 -0
  66. package/generated/versions/defold-1.13.0/timer.d.ts +114 -0
  67. package/generated/versions/defold-1.13.0/types.d.ts +61 -0
  68. package/generated/versions/defold-1.13.0/vmath.d.ts +806 -0
  69. package/generated/versions/defold-1.13.0/webview.d.ts +68 -0
  70. package/generated/versions/defold-1.13.0/window.d.ts +198 -0
  71. package/generated/versions/defold-1.13.0/zlib.d.ts +40 -0
  72. package/index.d.ts +4 -81
  73. package/package.json +11 -3
  74. package/scripts/import-defold-release.ts +28 -1
  75. package/scripts/sync-api-docs.ts +4 -3
  76. package/src/api-availability.ts +0 -0
  77. package/src/emit-dts.ts +6 -0
  78. package/src/example-store.ts +5 -0
  79. package/src/index.ts +3 -0
  80. package/scripts/lua-types-signature-index.ts +0 -151
@@ -0,0 +1,1185 @@
1
+ /** @noSelfInFile */
2
+ import type { Hash, Matrix4, Opaque, Url, Vector4 } from "../../../src/core-types";
3
+
4
+ declare global {
5
+ /**
6
+ * Rendering API documentation
7
+ */
8
+ namespace render {
9
+ type constant_buffer = Opaque<"constant_buffer">;
10
+ type render_target = Opaque<"render_target">;
11
+ type texture = Opaque<"texture">;
12
+ const FRUSTUM_PLANES_ALL: number & { readonly __brand: "render.FRUSTUM_PLANES_ALL" };
13
+ const FRUSTUM_PLANES_SIDES: number & { readonly __brand: "render.FRUSTUM_PLANES_SIDES" };
14
+ const RENDER_TARGET_DEFAULT: number & { readonly __brand: "render.RENDER_TARGET_DEFAULT" };
15
+ /**
16
+ * Depth sort far-to-near (default; good for transparent passes).
17
+ */
18
+ const SORT_BACK_TO_FRONT: number & { readonly __brand: "render.SORT_BACK_TO_FRONT" };
19
+ /**
20
+ * Depth sort near-to-far (good for opaque passes to reduce overdraw).
21
+ */
22
+ const SORT_FRONT_TO_BACK: number & { readonly __brand: "render.SORT_FRONT_TO_BACK" };
23
+ /**
24
+ * No per-call sorting; draw entries in insertion order.
25
+ */
26
+ const SORT_NONE: number & { readonly __brand: "render.SORT_NONE" };
27
+ /**
28
+ * Clear buffers in the currently enabled render target with specified value. If the render target has been created with multiple
29
+ * color attachments, all buffers will be cleared with the same value.
30
+ *
31
+ * @param buffers - table with keys specifying which buffers to clear and values set to clear values. Available keys are:
32
+ *
33
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
34
+ *
35
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
36
+ *
37
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
38
+ * @example
39
+ * ```ts
40
+ * // Clear the color buffer and the depth buffer.
41
+ * render.clear({
42
+ * [graphics.BUFFER_TYPE_COLOR0_BIT]: vmath.vector4(0, 0, 0, 0),
43
+ * [graphics.BUFFER_TYPE_DEPTH_BIT]: 1,
44
+ * });
45
+ * ```
46
+ */
47
+ function clear(buffers: LuaMap<number, number | Vector4>): void;
48
+ /**
49
+ * Constant buffers are used to set shader program variables and are optionally passed to the `render.draw()` function.
50
+ * The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().
51
+ *
52
+ * @returns new constant buffer
53
+ * @example
54
+ * ```ts
55
+ * // Set a "tint" constant in a constant buffer in the render script:
56
+ * const constants = render.constant_buffer();
57
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
58
+ *
59
+ * // Then use the constant buffer when drawing a predicate:
60
+ * render.draw(self.my_pred, { constants });
61
+ *
62
+ * // The constant buffer also supports array values by specifying constants in an array:
63
+ * const constants2 = render.constant_buffer();
64
+ * constants2.light_colors = [];
65
+ * constants2.light_colors[0] = vmath.vector4(1, 0, 0, 1);
66
+ * constants2.light_colors[1] = vmath.vector4(0, 1, 0, 1);
67
+ * constants2.light_colors[2] = vmath.vector4(0, 0, 1, 1);
68
+ *
69
+ * // You can also create the array by passing the vectors directly:
70
+ * const constants3 = render.constant_buffer();
71
+ * constants3.light_colors = [
72
+ * vmath.vector4(1, 0, 0, 1),
73
+ * vmath.vector4(0, 1, 0, 1),
74
+ * vmath.vector4(0, 0, 1, 1),
75
+ * ];
76
+ *
77
+ * // Add more constants to the array
78
+ * constants3.light_colors[3] = vmath.vector4(1, 1, 1, 1);
79
+ * ```
80
+ */
81
+ function constant_buffer(): Opaque<"constant_buffer">;
82
+ /**
83
+ * Deletes a render target created by a render script.
84
+ * You cannot delete a render target resource.
85
+ *
86
+ * @param render_target - render target to delete
87
+ * @example
88
+ * ```ts
89
+ * // How to delete a render target:
90
+ * render.delete_render_target(self.my_render_target);
91
+ * ```
92
+ */
93
+ function delete_render_target(render_target: Opaque<"render_target">): void;
94
+ /**
95
+ * If a material is currently enabled, disable it.
96
+ * The name of the material must be specified in the ".render" resource set
97
+ * in the "game.project" setting.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * // Enable material named "glow", then draw my_pred with it.
102
+ * render.enable_material("glow");
103
+ * render.draw(self.my_pred);
104
+ * render.disable_material();
105
+ * ```
106
+ */
107
+ function disable_material(): void;
108
+ /**
109
+ * Disables a render state.
110
+ *
111
+ * @param state - state to disable
112
+ *
113
+ * - `graphics.STATE_DEPTH_TEST`
114
+ *
115
+ * - `graphics.STATE_STENCIL_TEST`
116
+ *
117
+ * - `graphics.STATE_BLEND`
118
+ *
119
+ * - `graphics.STATE_ALPHA_TEST` ( not available on iOS and Android)
120
+ *
121
+ * - `graphics.STATE_CULL_FACE`
122
+ *
123
+ * - `graphics.STATE_POLYGON_OFFSET_FILL`
124
+ * @example
125
+ * ```ts
126
+ * // Disable face culling when drawing the tile predicate:
127
+ * render.disable_state(graphics.STATE_CULL_FACE);
128
+ * render.draw(self.tile_pred);
129
+ * ```
130
+ */
131
+ function disable_state(state: Opaque<"constant">): void;
132
+ /**
133
+ * Disables a texture that has previourly been enabled.
134
+ *
135
+ * @param binding - texture binding, either by texture unit, string or hash that should be disabled
136
+ * @example
137
+ * ```ts
138
+ * export default defineScript({
139
+ * update(self, dt) {
140
+ * render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
141
+ * // draw a predicate with the render target available as texture 0 in the predicate
142
+ * // material shader.
143
+ * render.draw(self.my_pred);
144
+ * // done, disable the texture
145
+ * render.disable_texture(0);
146
+ * },
147
+ * });
148
+ * ```
149
+ */
150
+ function disable_texture(binding: Opaque<"texture"> | string | Hash): void;
151
+ /**
152
+ * Dispatches the currently enabled compute program. The dispatch call takes three arguments x,y,z which constitutes
153
+ * the 'global working group' of the compute dispatch. Together with the 'local working group' specified in the compute shader
154
+ * as a layout qualifier, these two sets of parameters forms the number of invocations the compute shader will execute.
155
+ * An optional constant buffer can be provided to override the default constants. If no constants buffer is provided, a default
156
+ * system constants buffer is used containing constants as defined in the compute program.
157
+ *
158
+ * @param x - global work group size X
159
+ * @param y - global work group size Y
160
+ * @param z - global work group size Z
161
+ * @param options - optional table with properties:
162
+ *
163
+ * `constants`
164
+ * constant_buffer optional constants to use while rendering
165
+ * @example
166
+ * ```ts
167
+ * export default defineScript({
168
+ * init() {
169
+ * const color_params = {
170
+ * format: graphics.TEXTURE_FORMAT_RGBA,
171
+ * width: render.get_window_width(),
172
+ * height: render.get_window_height(),
173
+ * };
174
+ * return {
175
+ * scene_rt: render.render_target({ [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params }),
176
+ * };
177
+ * },
178
+ *
179
+ * update(self, dt) {
180
+ * render.set_compute("bloom");
181
+ * render.enable_texture(0, self.backing_texture);
182
+ * render.enable_texture(1, self.scene_rt);
183
+ * render.dispatch_compute(128, 128, 1);
184
+ * render.set_compute();
185
+ * },
186
+ * });
187
+ *
188
+ * // Dispatch a compute program with a constant buffer:
189
+ * const constants = render.constant_buffer();
190
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
191
+ * render.dispatch_compute(32, 32, 32, { constants });
192
+ * ```
193
+ */
194
+ function dispatch_compute(x: number, y: number, z: number, options?: { constants?: Opaque<"constant_buffer"> }): void;
195
+ /**
196
+ * Draws all objects that match a specified predicate. An optional constant buffer can be
197
+ * provided to override the default constants. If no constants buffer is provided, a default
198
+ * system constants buffer is used containing constants as defined in materials and set through
199
+ * go.set (or particlefx.set_constant) on visual components.
200
+ *
201
+ * @param predicate - predicate to draw for
202
+ * @param options - optional table with properties:
203
+ *
204
+ * `frustum`
205
+ * matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). default=nil
206
+ * `frustum_planes`
207
+ * int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
208
+ *
209
+ * - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
210
+ *
211
+ * - render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
212
+ *
213
+ * `constants`
214
+ * constant_buffer optional constants to use while rendering
215
+ * `sort_order`
216
+ * int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
217
+ * @example
218
+ * ```ts
219
+ * export default defineScript({
220
+ * init() {
221
+ * // define a predicate matching anything with material tag "my_tag"
222
+ * return { my_pred: render.predicate([hash("my_tag")]) };
223
+ * },
224
+ *
225
+ * update(self, dt) {
226
+ * // draw everything in the my_pred predicate
227
+ * render.draw(self.my_pred);
228
+ * },
229
+ * });
230
+ *
231
+ * // Draw predicate with constants:
232
+ * const constants = render.constant_buffer();
233
+ * constants.tint = vmath.vector4(1, 1, 1, 1);
234
+ * render.draw(self.my_pred, { constants });
235
+ *
236
+ * // Draw with predicate and frustum culling (without near+far planes):
237
+ * const frustum = self.proj.mul(self.view);
238
+ * render.draw(self.my_pred, { frustum });
239
+ *
240
+ * // Draw with predicate and frustum culling (with near+far planes):
241
+ * const frustum2 = self.proj.mul(self.view);
242
+ * render.draw(self.my_pred, { frustum: frustum2, frustum_planes: render.FRUSTUM_PLANES_ALL });
243
+ * ```
244
+ */
245
+ function draw(predicate: number, options?: { frustum?: Matrix4; frustum_planes?: number; constants?: Opaque<"constant_buffer">; sort_order?: number }): void;
246
+ /**
247
+ * Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization.
248
+ *
249
+ * @param options - optional table with properties:
250
+ *
251
+ * `frustum`
252
+ * matrix4 A frustum matrix used to cull renderable items. (E.g. `local frustum = proj * view`). May be nil.
253
+ * `frustum_planes`
254
+ * int Determines which sides of the frustum will be used. Default is render.FRUSTUM_PLANES_SIDES.
255
+ *
256
+ * - render.FRUSTUM_PLANES_SIDES : The left, right, top and bottom sides of the frustum.
257
+ *
258
+ * - render.FRUSTUM_PLANES_ALL : All sides of the frustum.
259
+ * @example
260
+ * ```ts
261
+ * export default defineScript({
262
+ * update(self, dt) {
263
+ * // draw debug visualization
264
+ * render.draw_debug3d();
265
+ * },
266
+ * });
267
+ * ```
268
+ */
269
+ function draw_debug3d(options?: { frustum?: Matrix4; frustum_planes?: number }): void;
270
+ /**
271
+ * If another material was already enabled, it will be automatically disabled
272
+ * and the specified material is used instead.
273
+ * The name of the material must be specified in the ".render" resource set
274
+ * in the "game.project" setting.
275
+ *
276
+ * @param material_id - material id to enable
277
+ * @example
278
+ * ```ts
279
+ * // Enable material named "glow", then draw my_pred with it.
280
+ * render.enable_material("glow");
281
+ * render.draw(self.my_pred);
282
+ * render.disable_material();
283
+ * ```
284
+ */
285
+ function enable_material(material_id: string | Hash): void;
286
+ /**
287
+ * Enables a particular render state. The state will be enabled until disabled.
288
+ *
289
+ * @param state - state to enable
290
+ *
291
+ * - `graphics.STATE_DEPTH_TEST`
292
+ *
293
+ * - `graphics.STATE_STENCIL_TEST`
294
+ *
295
+ * - `graphics.STATE_BLEND`
296
+ *
297
+ * - `graphics.STATE_ALPHA_TEST` ( not available on iOS and Android)
298
+ *
299
+ * - `graphics.STATE_CULL_FACE`
300
+ *
301
+ * - `graphics.STATE_POLYGON_OFFSET_FILL`
302
+ * @example
303
+ * ```ts
304
+ * // Enable stencil test when drawing the gui predicate, then disable it:
305
+ * render.enable_state(graphics.STATE_STENCIL_TEST);
306
+ * render.draw(self.gui_pred);
307
+ * render.disable_state(graphics.STATE_STENCIL_TEST);
308
+ * ```
309
+ */
310
+ function enable_state(state: Opaque<"constant">): void;
311
+ /**
312
+ * Sets the specified texture handle for a render target attachment or a regular texture
313
+ * that should be used for rendering. The texture can be bound to either a texture unit
314
+ * or to a sampler name by a hash or a string.
315
+ * A texture can be bound to multiple units and sampler names at the same time,
316
+ * the actual binding will be applied to the shaders when a shader program is bound.
317
+ * When mixing binding using both units and sampler names, you might end up in situations
318
+ * where two different textures will be applied to the same bind location in the shader.
319
+ * In this case, the texture set to the named sampler will take precedence over the unit.
320
+ * Note that you can bind multiple sampler names to the same texture, in case you want to reuse
321
+ * the same texture for differnt use-cases. It is however recommended that you use the same name
322
+ * everywhere for the textures that should be shared across different materials.
323
+ *
324
+ * @param binding - texture binding, either by texture unit, string or hash for the sampler name that the texture should be bound to
325
+ * @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
326
+ * @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:
327
+ *
328
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
329
+ *
330
+ * If The render target has been created as depth and/or stencil textures, these buffer types can be used:
331
+ *
332
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
333
+ *
334
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
335
+ *
336
+ * If the render target has been created with multiple color attachments, these buffer types can be used
337
+ * to enable those textures as well. Currently 4 color attachments are supported:
338
+ *
339
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
340
+ *
341
+ * - `graphics.BUFFER_TYPE_COLOR1_BIT`
342
+ *
343
+ * - `graphics.BUFFER_TYPE_COLOR2_BIT`
344
+ *
345
+ * - `graphics.BUFFER_TYPE_COLOR3_BIT`
346
+ * @example
347
+ * ```ts
348
+ * export default defineScript({
349
+ * update(self, dt) {
350
+ * // enable target so all drawing is done to it
351
+ * render.set_render_target(self.my_render_target);
352
+ *
353
+ * // draw a predicate to the render target
354
+ * render.draw(self.my_pred);
355
+ *
356
+ * // disable target
357
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
358
+ *
359
+ * render.enable_texture(0, self.my_render_target, graphics.BUFFER_TYPE_COLOR0_BIT);
360
+ * // draw a predicate with the render target available as texture 0 in the predicate
361
+ * // material shader.
362
+ * render.draw(self.my_pred);
363
+ * },
364
+ * });
365
+ *
366
+ * // Or enable a render target by resource id:
367
+ * export default defineScript({
368
+ * update(self, dt) {
369
+ * render.set_render_target("my_rt_resource");
370
+ * render.draw(self.my_pred);
371
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
372
+ *
373
+ * render.enable_texture(0, "my_rt_resource", graphics.BUFFER_TYPE_COLOR0_BIT);
374
+ * // draw a predicate with the render target available as texture 0 in the predicate
375
+ * // material shader.
376
+ * render.draw(self.my_pred);
377
+ * },
378
+ * });
379
+ *
380
+ * // Or bind a texture handle directly:
381
+ * export default defineScript({
382
+ * update(self, dt) {
383
+ * // bind a texture to the texture unit 0
384
+ * render.enable_texture(0, self.my_texture_handle);
385
+ * // bind the same texture to a named sampler
386
+ * render.enable_texture("my_texture_sampler", self.my_texture_handle);
387
+ * },
388
+ * });
389
+ * ```
390
+ */
391
+ function enable_texture(binding: number | string | Hash, handle_or_name: Opaque<"texture"> | string | Hash, buffer_type?: number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR1_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR2_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR3_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }): void;
392
+ /**
393
+ * Returns the logical window height that is set in the "game.project" settings.
394
+ * Note that the actual window pixel size can change, either by device constraints
395
+ * or user input.
396
+ *
397
+ * @returns specified window height
398
+ * @example
399
+ * ```ts
400
+ * // Get the height of the window
401
+ * const h = render.get_height();
402
+ * ```
403
+ */
404
+ function get_height(): number;
405
+ /**
406
+ * Returns the specified buffer height from a render target.
407
+ *
408
+ * @param render_target - render target from which to retrieve the buffer height
409
+ * @param buffer_type - which type of buffer to retrieve the height from
410
+ *
411
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
412
+ *
413
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
414
+ *
415
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
416
+ * @returns the height of the render target buffer texture
417
+ * @example
418
+ * ```ts
419
+ * // get the height of the render target color buffer
420
+ * const h = render.get_render_target_height(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
421
+ * // get the height of a render target resource
422
+ * const w = render.get_render_target_height("my_rt_resource", graphics.BUFFER_TYPE_COLOR0_BIT);
423
+ * ```
424
+ */
425
+ function get_render_target_height(render_target: Opaque<"render_target">, buffer_type: number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR1_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR2_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR3_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }): number;
426
+ /**
427
+ * Returns the specified buffer width from a render target.
428
+ *
429
+ * @param render_target - render target from which to retrieve the buffer width
430
+ * @param buffer_type - which type of buffer to retrieve the width from
431
+ *
432
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
433
+ *
434
+ * - `graphics.BUFFER_TYPE_COLOR[x]_BIT` (x: [0..3], if supported!)
435
+ *
436
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
437
+ *
438
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
439
+ * @returns the width of the render target buffer texture
440
+ * @example
441
+ * ```ts
442
+ * // get the width of the render target color buffer
443
+ * const w = render.get_render_target_width(self.target_right, graphics.BUFFER_TYPE_COLOR0_BIT);
444
+ * // get the width of a render target resource
445
+ * const w2 = render.get_render_target_width("my_rt_resource", graphics.BUFFER_TYPE_COLOR0_BIT);
446
+ * ```
447
+ */
448
+ function get_render_target_width(render_target: Opaque<"render_target">, buffer_type: number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR1_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR2_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR3_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }): number;
449
+ /**
450
+ * Returns the logical window width that is set in the "game.project" settings.
451
+ * Note that the actual window pixel size can change, either by device constraints
452
+ * or user input.
453
+ *
454
+ * @returns specified window width (number)
455
+ * @example
456
+ * ```ts
457
+ * // Get the width of the window.
458
+ * const w = render.get_width();
459
+ * ```
460
+ */
461
+ function get_width(): number;
462
+ /**
463
+ * Returns the actual physical window height.
464
+ * Note that this value might differ from the logical height that is set in the
465
+ * "game.project" settings.
466
+ *
467
+ * @returns actual window height
468
+ * @example
469
+ * ```ts
470
+ * // Get the actual height of the window
471
+ * const h = render.get_window_height();
472
+ * ```
473
+ */
474
+ function get_window_height(): number;
475
+ /**
476
+ * Returns the actual physical window width.
477
+ * Note that this value might differ from the logical width that is set in the
478
+ * "game.project" settings.
479
+ *
480
+ * @returns actual window width
481
+ * @example
482
+ * ```ts
483
+ * // Get the actual width of the window
484
+ * const w = render.get_window_width();
485
+ * ```
486
+ */
487
+ function get_window_width(): number;
488
+ /**
489
+ * This function returns a new render predicate for objects with materials matching
490
+ * the provided material tags. The provided tags are combined into a bit mask
491
+ * for the predicate. If multiple tags are provided, the predicate matches materials
492
+ * with all tags ANDed together.
493
+ * The current limit to the number of tags that can be defined is `64`.
494
+ *
495
+ * @param tags - table of tags that the predicate should match. The tags can be of either hash or string type
496
+ * @returns new predicate
497
+ * @example
498
+ * ```ts
499
+ * // Create a new render predicate containing all visual objects that
500
+ * // have a material with material tags "opaque" AND "smoke".
501
+ * const p = render.predicate([hash("opaque"), hash("smoke")]);
502
+ * ```
503
+ */
504
+ function predicate(tags: (string | Hash)[]): number;
505
+ /**
506
+ * Creates a new render target according to the supplied
507
+ * specification table.
508
+ * The table should contain keys specifying which buffers should be created
509
+ * with what parameters. Each buffer key should have a table value consisting
510
+ * of parameters. The following parameter keys are available:
511
+ *
512
+ * Key
513
+ * Values
514
+ *
515
+ * `format`
516
+ * `graphics.TEXTURE_FORMAT_LUMINANCE`
517
+ * `graphics.TEXTURE_FORMAT_RGB`
518
+ * `graphics.TEXTURE_FORMAT_RGBA`
519
+ * `graphics.TEXTURE_FORMAT_DEPTH`
520
+ * `graphics.TEXTURE_FORMAT_STENCIL`
521
+ * `graphics.TEXTURE_FORMAT_RGBA32F`
522
+ * `graphics.TEXTURE_FORMAT_RGBA16F`
523
+ *
524
+ * `width`
525
+ * number
526
+ *
527
+ * `height`
528
+ * number
529
+ *
530
+ * `min_filter` (optional)
531
+ * `graphics.TEXTURE_FILTER_LINEAR`
532
+ * `graphics.TEXTURE_FILTER_NEAREST`
533
+ *
534
+ * `mag_filter` (optional)
535
+ * `graphics.TEXTURE_FILTER_LINEAR`
536
+ * `graphics.TEXTURE_FILTER_NEAREST`
537
+ *
538
+ * `u_wrap` (optional)
539
+ * `graphics.TEXTURE_WRAP_CLAMP_TO_BORDER`
540
+ * `graphics.TEXTURE_WRAP_CLAMP_TO_EDGE`
541
+ * `graphics.TEXTURE_WRAP_MIRRORED_REPEAT`
542
+ * `graphics.TEXTURE_WRAP_REPEAT`
543
+ *
544
+ * `v_wrap` (optional)
545
+ * `graphics.TEXTURE_WRAP_CLAMP_TO_BORDER`
546
+ * `graphics.TEXTURE_WRAP_CLAMP_TO_EDGE`
547
+ * `graphics.TEXTURE_WRAP_MIRRORED_REPEAT`
548
+ * `graphics.TEXTURE_WRAP_REPEAT`
549
+ *
550
+ * `flags` (optional)
551
+ * `render.TEXTURE_BIT` (only applicable to depth and stencil buffers)
552
+ *
553
+ * The render target can be created to support multiple color attachments. Each attachment can have different format settings and texture filters,
554
+ * but attachments must be added in sequence, meaning you cannot create a render target at slot 0 and 3.
555
+ * Instead it has to be created with all four buffer types ranging from [0..3] (as denoted by graphics.BUFFER_TYPE_COLORX_BIT where 'X' is the attachment you want to create).
556
+ * It is not guaranteed that the device running the script can support creating render targets with multiple color attachments. To check if the device can support multiple attachments,
557
+ * you can check if the `render` table contains any of the `BUFFER_TYPE_COLOR1_BIT`, `BUFFER_TYPE_COLOR2_BIT` or `BUFFER_TYPE_COLOR3_BIT` constants:
558
+ *
559
+ * `function init(self)
560
+ * if graphics.BUFFER_TYPE_COLOR1_BIT == nil then
561
+ * -- this devices does not support multiple color attachments
562
+ * end
563
+ * end
564
+ * `
565
+ *
566
+ * @param name - render target name
567
+ * @param parameters - table of buffer parameters, see the description for available keys and values
568
+ * @returns new render target
569
+ * @example
570
+ * ```ts
571
+ * // How to create a new render target and draw to it:
572
+ * export default defineScript({
573
+ * init() {
574
+ * // render target buffer parameters
575
+ * const color_params = {
576
+ * format: graphics.TEXTURE_FORMAT_RGBA,
577
+ * width: render.get_window_width(),
578
+ * height: render.get_window_height(),
579
+ * min_filter: graphics.TEXTURE_FILTER_LINEAR,
580
+ * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
581
+ * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
582
+ * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
583
+ * };
584
+ * const depth_params = {
585
+ * format: graphics.TEXTURE_FORMAT_DEPTH,
586
+ * width: render.get_window_width(),
587
+ * height: render.get_window_height(),
588
+ * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
589
+ * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
590
+ * };
591
+ * return {
592
+ * my_render_target: render.render_target({
593
+ * [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params,
594
+ * [graphics.BUFFER_TYPE_DEPTH_BIT]: depth_params,
595
+ * }),
596
+ * };
597
+ * },
598
+ *
599
+ * update(self, dt) {
600
+ * // enable target so all drawing is done to it
601
+ * render.set_render_target(self.my_render_target);
602
+ *
603
+ * // draw a predicate to the render target
604
+ * render.draw(self.my_pred);
605
+ * },
606
+ * });
607
+ *
608
+ * // How to create a render target with multiple outputs:
609
+ * export default defineScript({
610
+ * init() {
611
+ * // render target buffer parameters
612
+ * const color_params_rgba = {
613
+ * format: graphics.TEXTURE_FORMAT_RGBA,
614
+ * width: render.get_window_width(),
615
+ * height: render.get_window_height(),
616
+ * min_filter: graphics.TEXTURE_FILTER_LINEAR,
617
+ * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
618
+ * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
619
+ * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
620
+ * };
621
+ * const color_params_float = {
622
+ * format: graphics.TEXTURE_FORMAT_RG32F,
623
+ * width: render.get_window_width(),
624
+ * height: render.get_window_height(),
625
+ * min_filter: graphics.TEXTURE_FILTER_LINEAR,
626
+ * mag_filter: graphics.TEXTURE_FILTER_LINEAR,
627
+ * u_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
628
+ * v_wrap: graphics.TEXTURE_WRAP_CLAMP_TO_EDGE,
629
+ * };
630
+ *
631
+ * // Create a render target with three color attachments
632
+ * // Note: No depth buffer is attached here
633
+ * return {
634
+ * my_render_target: render.render_target({
635
+ * [graphics.BUFFER_TYPE_COLOR0_BIT]: color_params_rgba,
636
+ * [graphics.BUFFER_TYPE_COLOR1_BIT]: color_params_rgba,
637
+ * [graphics.BUFFER_TYPE_COLOR2_BIT]: color_params_float,
638
+ * }),
639
+ * };
640
+ * },
641
+ *
642
+ * update(self, dt) {
643
+ * // enable target so all drawing is done to it
644
+ * render.enable_render_target(self.my_render_target);
645
+ *
646
+ * // draw a predicate to the render target
647
+ * render.draw(self.my_pred);
648
+ * },
649
+ * });
650
+ * ```
651
+ */
652
+ function render_target(name: string, parameters: Record<string | number, unknown>): Opaque<"render_target">;
653
+ /**
654
+ * Sets the blend equation with separate equations for the color and alpha channels.
655
+ *
656
+ * @param equation_color - color blend equation
657
+ * @param equation_alpha - alpha blend equation
658
+ * @example
659
+ * ```ts
660
+ * render.set_blend_equation_separate(graphics.BLEND_EQUATION_ADD, graphics.BLEND_EQUATION_REVERSE_SUBTRACT);
661
+ * ```
662
+ */
663
+ function set_blend_equation_separate(equation_color: number, equation_alpha: number): void;
664
+ /**
665
+ * Specifies the arithmetic used when computing pixel values that are written to the frame
666
+ * buffer. In RGBA mode, pixels can be drawn using a function that blends the source RGBA
667
+ * pixel values with the destination pixel values already in the frame buffer.
668
+ * Blending is initially disabled.
669
+ * `source_factor` specifies which method is used to scale the source color components.
670
+ * `destination_factor` specifies which method is used to scale the destination color
671
+ * components.
672
+ * Source color components are referred to as (Rs,Gs,Bs,As).
673
+ * Destination color components are referred to as (Rd,Gd,Bd,Ad).
674
+ * The color specified by setting the blendcolor is referred to as (Rc,Gc,Bc,Ac).
675
+ * The source scale factor is referred to as (sR,sG,sB,sA).
676
+ * The destination scale factor is referred to as (dR,dG,dB,dA).
677
+ * 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`.
678
+ * Available factor constants and corresponding scale factors:
679
+ *
680
+ * Factor constant
681
+ * Scale factor (fR,fG,fB,fA)
682
+ *
683
+ * `graphics.BLEND_FACTOR_ZERO`
684
+ * (0,0,0,0)
685
+ *
686
+ * `graphics.BLEND_FACTOR_ONE`
687
+ * (1,1,1,1)
688
+ *
689
+ * `graphics.BLEND_FACTOR_SRC_COLOR`
690
+ * (Rs/kR,Gs/kG,Bs/kB,As/kA)
691
+ *
692
+ * `graphics.BLEND_FACTOR_ONE_MINUS_SRC_COLOR`
693
+ * (1,1,1,1) - (Rs/kR,Gs/kG,Bs/kB,As/kA)
694
+ *
695
+ * `graphics.BLEND_FACTOR_DST_COLOR`
696
+ * (Rd/kR,Gd/kG,Bd/kB,Ad/kA)
697
+ *
698
+ * `graphics.BLEND_FACTOR_ONE_MINUS_DST_COLOR`
699
+ * (1,1,1,1) - (Rd/kR,Gd/kG,Bd/kB,Ad/kA)
700
+ *
701
+ * `graphics.BLEND_FACTOR_SRC_ALPHA`
702
+ * (As/kA,As/kA,As/kA,As/kA)
703
+ *
704
+ * `graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA`
705
+ * (1,1,1,1) - (As/kA,As/kA,As/kA,As/kA)
706
+ *
707
+ * `graphics.BLEND_FACTOR_DST_ALPHA`
708
+ * (Ad/kA,Ad/kA,Ad/kA,Ad/kA)
709
+ *
710
+ * `graphics.BLEND_FACTOR_ONE_MINUS_DST_ALPHA`
711
+ * (1,1,1,1) - (Ad/kA,Ad/kA,Ad/kA,Ad/kA)
712
+ *
713
+ * `graphics.BLEND_FACTOR_CONSTANT_COLOR`
714
+ * (Rc,Gc,Bc,Ac)
715
+ *
716
+ * `graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR`
717
+ * (1,1,1,1) - (Rc,Gc,Bc,Ac)
718
+ *
719
+ * `graphics.BLEND_FACTOR_CONSTANT_ALPHA`
720
+ * (Ac,Ac,Ac,Ac)
721
+ *
722
+ * `graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA`
723
+ * (1,1,1,1) - (Ac,Ac,Ac,Ac)
724
+ *
725
+ * `graphics.BLEND_FACTOR_SRC_ALPHA_SATURATE`
726
+ * (i,i,i,1) where i = min(As, kA - Ad) /kA
727
+ *
728
+ * The blended RGBA values of a pixel comes from the following equations:
729
+ *
730
+ * - Rd = min(kR, Rs * sR + Rd * dR)
731
+ *
732
+ * - Gd = min(kG, Gs * sG + Gd * dG)
733
+ *
734
+ * - Bd = min(kB, Bs * sB + Bd * dB)
735
+ *
736
+ * - Ad = min(kA, As * sA + Ad * dA)
737
+ *
738
+ * Blend function `(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA)` is useful for
739
+ * drawing with transparency when the drawn objects are sorted from farthest to nearest.
740
+ * It is also useful for drawing antialiased points and lines in arbitrary order.
741
+ *
742
+ * @param source_factor - source factor
743
+ * @param destination_factor - destination factor
744
+ * @example
745
+ * ```ts
746
+ * // Set the blend func to the most common one:
747
+ * render.set_blend_func(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
748
+ * ```
749
+ */
750
+ function set_blend_func(source_factor: number, destination_factor: number): void;
751
+ /**
752
+ * Sets the blend function with separate blend factors for the color and alpha channels.
753
+ *
754
+ * @param source_factor_color - source color blend factor
755
+ * @param destination_factor_color - destination color blend factor
756
+ * @param source_factor_alpha - source alpha blend factor
757
+ * @param destination_factor_alpha - destination alpha blend factor
758
+ * @example
759
+ * ```ts
760
+ * render.set_blend_func_separate(graphics.BLEND_FACTOR_SRC_ALPHA, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, graphics.BLEND_FACTOR_ONE, graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA);
761
+ * ```
762
+ */
763
+ function set_blend_func_separate(source_factor_color: number, destination_factor_color: number, source_factor_alpha: number, destination_factor_alpha: number): void;
764
+ /**
765
+ * Sets the current render camera to be used for rendering. If a render camera
766
+ * has been set by the render script, the renderer will be using its projection and view matrix
767
+ * during rendering. If a projection and/or view matrix has been set by the render script,
768
+ * they will not be used until the current render camera has been reset by calling `render.set_camera()`.
769
+ * If the 'use_frustum' flag in the options table has been set to true, the renderer will automatically use the
770
+ * camera frustum for frustum culling regardless of what frustum is being passed into the render.draw() function.
771
+ * Note that the frustum plane option in render.draw can still be used together with the camera.
772
+ *
773
+ * @param camera - camera id to use, or nil to reset
774
+ * @param options - optional table with properties:
775
+ *
776
+ * `use_frustum`
777
+ * boolean If true, the renderer will use the cameras view-projection matrix for frustum culling (default: false)
778
+ * @example
779
+ * ```ts
780
+ * // Set the current camera to be used for rendering
781
+ * render.set_camera("main:/my_go#camera");
782
+ * render.draw(self.my_pred);
783
+ * render.set_camera(undefined);
784
+ *
785
+ * // Use the camera frustum for frustum culling together with a specific frustum plane option for the draw command
786
+ * // The camera frustum will take precedence over the frustum plane option in render.draw
787
+ * render.set_camera("main:/my_go#camera", { use_frustum: true });
788
+ * // However, we can still customize the frustum planes regardless of the camera option!
789
+ * render.draw(self.my_pred, { frustum_planes: render.FRUSTUM_PLANES_ALL });
790
+ * render.set_camera();
791
+ * ```
792
+ */
793
+ function set_camera(camera?: Url | number, options?: { use_frustum?: boolean }): void;
794
+ /**
795
+ * 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.
796
+ * The component masks are all initially `true`.
797
+ *
798
+ * @param red - red mask
799
+ * @param green - green mask
800
+ * @param blue - blue mask
801
+ * @param alpha - alpha mask
802
+ * @example
803
+ * ```ts
804
+ * // alpha cannot be written to frame buffer
805
+ * render.set_color_mask(true, true, true, false);
806
+ * ```
807
+ */
808
+ function set_color_mask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void;
809
+ /**
810
+ * The name of the compute program must be specified in the ".render" resource set
811
+ * in the "game.project" setting. If nil (or no arguments) are passed to this function,
812
+ * the current compute program will instead be disabled.
813
+ *
814
+ * @param compute - compute id to use, or nil to disable
815
+ * @example
816
+ * ```ts
817
+ * // Enable compute program named "fractals", then dispatch it.
818
+ * render.set_compute("fractals");
819
+ * render.enable_texture(0, self.backing_texture);
820
+ * render.dispatch_compute(128, 128, 1);
821
+ * render.set_compute();
822
+ * ```
823
+ */
824
+ function set_compute(compute?: string | Hash): void;
825
+ /**
826
+ * Specifies whether front- or back-facing polygons can be culled
827
+ * when polygon culling is enabled. Polygon culling is initially disabled.
828
+ * If mode is `graphics.FACE_TYPE_FRONT_AND_BACK`, no polygons are drawn, but other
829
+ * primitives such as points and lines are drawn. The initial value for
830
+ * `face_type` is `graphics.FACE_TYPE_BACK`.
831
+ *
832
+ * @param face_type - face type
833
+ *
834
+ * - `graphics.FACE_TYPE_FRONT`
835
+ *
836
+ * - `graphics.FACE_TYPE_BACK`
837
+ *
838
+ * - `graphics.FACE_TYPE_FRONT_AND_BACK`
839
+ * @example
840
+ * ```ts
841
+ * // How to enable polygon culling and set front face culling:
842
+ * render.enable_state(graphics.STATE_CULL_FACE);
843
+ * render.set_cull_face(graphics.FACE_TYPE_FRONT);
844
+ * ```
845
+ */
846
+ function set_cull_face(face_type: number): void;
847
+ /**
848
+ * Specifies the function that should be used to compare each incoming pixel
849
+ * depth value with the value present in the depth buffer.
850
+ * The comparison is performed only if depth testing is enabled and specifies
851
+ * the conditions under which a pixel will be drawn.
852
+ * Function constants:
853
+ *
854
+ * - `graphics.COMPARE_FUNC_NEVER` (never passes)
855
+ *
856
+ * - `graphics.COMPARE_FUNC_LESS` (passes if the incoming depth value is less than the stored value)
857
+ *
858
+ * - `graphics.COMPARE_FUNC_LEQUAL` (passes if the incoming depth value is less than or equal to the stored value)
859
+ *
860
+ * - `graphics.COMPARE_FUNC_GREATER` (passes if the incoming depth value is greater than the stored value)
861
+ *
862
+ * - `graphics.COMPARE_FUNC_GEQUAL` (passes if the incoming depth value is greater than or equal to the stored value)
863
+ *
864
+ * - `graphics.COMPARE_FUNC_EQUAL` (passes if the incoming depth value is equal to the stored value)
865
+ *
866
+ * - `graphics.COMPARE_FUNC_NOTEQUAL` (passes if the incoming depth value is not equal to the stored value)
867
+ *
868
+ * - `graphics.COMPARE_FUNC_ALWAYS` (always passes)
869
+ *
870
+ * The depth function is initially set to `graphics.COMPARE_FUNC_LESS`.
871
+ *
872
+ * @param func - depth test function, see the description for available values
873
+ * @example
874
+ * ```ts
875
+ * // Enable depth test and set the depth test function to "not equal".
876
+ * render.enable_state(graphics.STATE_DEPTH_TEST);
877
+ * render.set_depth_func(graphics.COMPARE_FUNC_NOTEQUAL);
878
+ * ```
879
+ */
880
+ function set_depth_func(func: number): void;
881
+ /**
882
+ * Specifies whether the depth buffer is enabled for writing. The supplied mask governs
883
+ * if depth buffer writing is enabled (`true`) or disabled (`false`).
884
+ * The mask is initially `true`.
885
+ *
886
+ * @param depth - depth mask
887
+ * @example
888
+ * ```ts
889
+ * // How to turn off writing to the depth buffer:
890
+ * render.set_depth_mask(false);
891
+ * ```
892
+ */
893
+ function set_depth_mask(depth: boolean): void;
894
+ /**
895
+ * Set or remove listener. Currenly only only two type of events can arrived:
896
+ * `render.CONTEXT_EVENT_CONTEXT_LOST` - when rendering context lost. Rending paused and all graphics resources become invalid.
897
+ * `render.CONTEXT_EVENT_CONTEXT_RESTORED` - when rendering context was restored. Rendering still paused and graphics resources still
898
+ * invalid but can be reloaded.
899
+ *
900
+ * @param callback - A callback that receives all render related events.
901
+ * Pass `nil` if want to remove listener.
902
+ *
903
+ * `self`
904
+ * object The render script
905
+ * `event_type`
906
+ * string Rendering event. Possible values: `render.CONTEXT_EVENT_CONTEXT_LOST`, `render.CONTEXT_EVENT_CONTEXT_RESTORED`
907
+ * @example
908
+ * ```ts
909
+ * // Set listener and handle render context events.
910
+ * // custom.render_script
911
+ * export default defineScript({
912
+ * init() {
913
+ * render.set_listener((self, event_type) => {
914
+ * if (event_type === render.CONTEXT_EVENT_CONTEXT_LOST) {
915
+ * // Some stuff when rendering context is lost
916
+ * } else if (event_type === render.CONTEXT_EVENT_CONTEXT_RESTORED) {
917
+ * // Start reload resources, reload game, etc.
918
+ * }
919
+ * });
920
+ * },
921
+ * });
922
+ * ```
923
+ */
924
+ function set_listener(callback?: (self: unknown, event_type: unknown) => void): void;
925
+ /**
926
+ * Sets the scale and units used to calculate depth values.
927
+ * If `graphics.STATE_POLYGON_OFFSET_FILL` is enabled, each fragment's depth value
928
+ * is offset from its interpolated value (depending on the depth value of the
929
+ * appropriate vertices). Polygon offset can be used when drawing decals, rendering
930
+ * hidden-line images etc.
931
+ * `factor` specifies a scale factor that is used to create a variable depth
932
+ * offset for each polygon. The initial value is `0`.
933
+ * `units` is multiplied by an implementation-specific value to create a
934
+ * constant depth offset. The initial value is `0`.
935
+ * The value of the offset is computed as `factor` &times; `DZ` + `r` &times; `units`
936
+ * `DZ` is a measurement of the depth slope of the polygon which is the change in z (depth)
937
+ * values divided by the change in either x or y coordinates, as you traverse a polygon.
938
+ * The depth values are in window coordinates, clamped to the range [0, 1].
939
+ * `r` is the smallest value that is guaranteed to produce a resolvable difference.
940
+ * It's value is an implementation-specific constant.
941
+ * The offset is added before the depth test is performed and before the
942
+ * value is written into the depth buffer.
943
+ *
944
+ * @param factor - polygon offset factor
945
+ * @param units - polygon offset units
946
+ * @example
947
+ * ```ts
948
+ * render.enable_state(graphics.STATE_POLYGON_OFFSET_FILL);
949
+ * render.set_polygon_offset(1.0, 1.0);
950
+ * ```
951
+ */
952
+ function set_polygon_offset(factor: number, units: number): void;
953
+ /**
954
+ * Sets the projection matrix to use when rendering.
955
+ *
956
+ * @param matrix - projection matrix
957
+ * @example
958
+ * ```ts
959
+ * // How to set the projection to orthographic with world origo at lower left,
960
+ * // width and height as set in project settings and depth (z) between -1 and 1:
961
+ * render.set_projection(vmath.matrix4_orthographic(0, render.get_width(), 0, render.get_height(), -1, 1));
962
+ * ```
963
+ */
964
+ function set_projection(matrix: Matrix4): void;
965
+ /**
966
+ * Sets a render target. Subsequent draw operations will be to the
967
+ * render target until it is replaced by a subsequent call to set_render_target.
968
+ * This function supports render targets created by a render script, or a render target resource.
969
+ *
970
+ * @param render_target - render target to set. render.RENDER_TARGET_DEFAULT to set the default render target
971
+ * @param options - optional table with behaviour parameters
972
+ *
973
+ * `transient`
974
+ * 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.
975
+ * 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!
976
+ * A buffer type defined that doesn't exist in the render target is silently ignored.
977
+ *
978
+ * - `graphics.BUFFER_TYPE_COLOR0_BIT`
979
+ *
980
+ * - `graphics.BUFFER_TYPE_DEPTH_BIT`
981
+ *
982
+ * - `graphics.BUFFER_TYPE_STENCIL_BIT`
983
+ * @example
984
+ * ```ts
985
+ * // How to set a render target and draw to it and then switch back to the default render target
986
+ * // 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
987
+ * export default defineScript({
988
+ * update(self, dt) {
989
+ * // set render target so all drawing is done to it
990
+ * render.set_render_target(self.my_render_target, {
991
+ * transient: [graphics.BUFFER_TYPE_DEPTH_BIT, graphics.BUFFER_TYPE_STENCIL_BIT],
992
+ * });
993
+ *
994
+ * // draw a predicate to the render target
995
+ * render.draw(self.my_pred);
996
+ *
997
+ * // set default render target. This also invalidates the depth and stencil buffers of the current target (self.my_render_target)
998
+ * // which can be an optimisation on some hardware
999
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1000
+ * },
1001
+ * });
1002
+ *
1003
+ * // Or set the render target by a render target resource identifier:
1004
+ * export default defineScript({
1005
+ * update(self, dt) {
1006
+ * render.set_render_target("my_rt_resource");
1007
+ *
1008
+ * // draw a predicate to the render target
1009
+ * render.draw(self.my_pred);
1010
+ *
1011
+ * // reset the render target to the default backbuffer
1012
+ * render.set_render_target(render.RENDER_TARGET_DEFAULT);
1013
+ * },
1014
+ * });
1015
+ * ```
1016
+ */
1017
+ function set_render_target(render_target: Opaque<"render_target">, options?: { transient?: Record<string | number, unknown> }): void;
1018
+ /**
1019
+ * Sets the render target size for a render target created from
1020
+ * either a render script, or from a render target resource.
1021
+ *
1022
+ * @param render_target - render target to set size for
1023
+ * @param width - new render target width
1024
+ * @param height - new render target height
1025
+ * @example
1026
+ * ```ts
1027
+ * // Resize render targets to the current window size:
1028
+ * render.set_render_target_size(self.my_render_target, render.get_window_width(), render.get_window_height());
1029
+ * render.set_render_target_size("my_rt_resource", render.get_window_width(), render.get_window_height());
1030
+ * ```
1031
+ */
1032
+ function set_render_target_size(render_target: Opaque<"render_target">, width: number, height: number): void;
1033
+ /**
1034
+ * Stenciling is similar to depth-buffering as it enables and disables drawing on a
1035
+ * per-pixel basis. First, GL drawing primitives are drawn into the stencil planes.
1036
+ * Second, geometry and images are rendered but using the stencil planes to mask out
1037
+ * where to draw.
1038
+ * The stencil test discards a pixel based on the outcome of a comparison between the
1039
+ * reference value `ref` and the corresponding value in the stencil buffer.
1040
+ * `func` specifies the comparison function. See the table below for values.
1041
+ * The initial value is `graphics.COMPARE_FUNC_ALWAYS`.
1042
+ * `ref` specifies the reference value for the stencil test. The value is clamped to
1043
+ * the range [0, 2n-1], where n is the number of bitplanes in the stencil buffer.
1044
+ * The initial value is `0`.
1045
+ * `mask` is ANDed with both the reference value and the stored stencil value when the test
1046
+ * is done. The initial value is all `1`'s.
1047
+ * Function constant:
1048
+ *
1049
+ * - `graphics.COMPARE_FUNC_NEVER` (never passes)
1050
+ *
1051
+ * - `graphics.COMPARE_FUNC_LESS` (passes if (ref & mask) < (stencil & mask))
1052
+ *
1053
+ * - `graphics.COMPARE_FUNC_LEQUAL` (passes if (ref & mask) <= (stencil & mask))
1054
+ *
1055
+ * - `graphics.COMPARE_FUNC_GREATER` (passes if (ref & mask) > (stencil & mask))
1056
+ *
1057
+ * - `graphics.COMPARE_FUNC_GEQUAL` (passes if (ref & mask) >= (stencil & mask))
1058
+ *
1059
+ * - `graphics.COMPARE_FUNC_EQUAL` (passes if (ref & mask) = (stencil & mask))
1060
+ *
1061
+ * - `graphics.COMPARE_FUNC_NOTEQUAL` (passes if (ref & mask) != (stencil & mask))
1062
+ *
1063
+ * - `graphics.COMPARE_FUNC_ALWAYS` (always passes)
1064
+ *
1065
+ * @param func - stencil test function, see the description for available values
1066
+ * @param ref - reference value for the stencil test
1067
+ * @param mask - mask that is ANDed with both the reference value and the stored stencil value when the test is done
1068
+ * @example
1069
+ * ```ts
1070
+ * // let only 0's pass the stencil test
1071
+ * render.set_stencil_func(graphics.COMPARE_FUNC_EQUAL, 0, 1);
1072
+ * ```
1073
+ */
1074
+ function set_stencil_func(func: number, ref: number, mask: number): void;
1075
+ /**
1076
+ * The stencil mask controls the writing of individual bits in the stencil buffer.
1077
+ * The least significant `n` bits of the parameter `mask`, where `n` is the number of
1078
+ * bits in the stencil buffer, specify the mask.
1079
+ * Where a `1` bit appears in the mask, the corresponding
1080
+ * bit in the stencil buffer can be written. Where a `0` bit appears in the mask,
1081
+ * the corresponding bit in the stencil buffer is never written.
1082
+ * The mask is initially all `1`'s.
1083
+ *
1084
+ * @param mask - stencil mask
1085
+ * @example
1086
+ * ```ts
1087
+ * // set the stencil mask to all 1:s
1088
+ * render.set_stencil_mask(0xff);
1089
+ * ```
1090
+ */
1091
+ function set_stencil_mask(mask: number): void;
1092
+ /**
1093
+ * The stencil test discards a pixel based on the outcome of a comparison between the
1094
+ * reference value `ref` and the corresponding value in the stencil buffer.
1095
+ * To control the test, call render.set_stencil_func.
1096
+ * This function takes three arguments that control what happens to the stored stencil
1097
+ * value while stenciling is enabled. If the stencil test fails, no change is made to the
1098
+ * pixel's color or depth buffers, and `sfail` specifies what happens to the stencil buffer
1099
+ * contents.
1100
+ * Operator constants:
1101
+ *
1102
+ * - `graphics.STENCIL_OP_KEEP` (keeps the current value)
1103
+ *
1104
+ * - `graphics.STENCIL_OP_ZERO` (sets the stencil buffer value to 0)
1105
+ *
1106
+ * - `graphics.STENCIL_OP_REPLACE` (sets the stencil buffer value to `ref`, as specified by render.set_stencil_func)
1107
+ *
1108
+ * - `graphics.STENCIL_OP_INCR` (increments the stencil buffer value and clamp to the maximum representable unsigned value)
1109
+ *
1110
+ * - `graphics.STENCIL_OP_INCR_WRAP` (increments the stencil buffer value and wrap to zero when incrementing the maximum representable unsigned value)
1111
+ *
1112
+ * - `graphics.STENCIL_OP_DECR` (decrements the current stencil buffer value and clamp to 0)
1113
+ *
1114
+ * - `graphics.STENCIL_OP_DECR_WRAP` (decrements the current stencil buffer value and wrap to the maximum representable unsigned value when decrementing zero)
1115
+ *
1116
+ * - `graphics.STENCIL_OP_INVERT` (bitwise inverts the current stencil buffer value)
1117
+ *
1118
+ * `dppass` and `dpfail` specify the stencil buffer actions depending on whether subsequent
1119
+ * depth buffer tests succeed (dppass) or fail (dpfail).
1120
+ * The initial value for all operators is `graphics.STENCIL_OP_KEEP`.
1121
+ *
1122
+ * @param sfail - action to take when the stencil test fails
1123
+ * @param dpfail - the stencil action when the stencil test passes
1124
+ * @param dppass - the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled
1125
+ * @example
1126
+ * ```ts
1127
+ * // Set the stencil function to never pass and operator to always draw 1's
1128
+ * // on test fail.
1129
+ * render.set_stencil_func(graphics.COMPARE_FUNC_NEVER, 1, 0xFF);
1130
+ * // always draw 1's on test fail
1131
+ * render.set_stencil_op(graphics.STENCIL_OP_REPLACE, graphics.STENCIL_OP_KEEP, graphics.STENCIL_OP_KEEP);
1132
+ * ```
1133
+ */
1134
+ function set_stencil_op(sfail: number, dpfail: number, dppass: number): void;
1135
+ /**
1136
+ * Sets the view matrix to use when rendering.
1137
+ *
1138
+ * @param matrix - view matrix to set
1139
+ * @example
1140
+ * ```ts
1141
+ * // How to set the view and projection matrices according to
1142
+ * // the values supplied by a camera.
1143
+ * export default defineScript({
1144
+ * init() {
1145
+ * return {
1146
+ * view: vmath.matrix4(),
1147
+ * projection: vmath.matrix4(),
1148
+ * };
1149
+ * },
1150
+ *
1151
+ * update(self, dt) {
1152
+ * // set the view to the stored view value
1153
+ * render.set_view(self.view);
1154
+ * // now we can draw with this view
1155
+ * },
1156
+ *
1157
+ * on_message(self, message_id, message) {
1158
+ * if (message_id === hash("set_view_projection")) {
1159
+ * // camera view and projection arrives here.
1160
+ * self.view = message.view;
1161
+ * self.projection = message.projection;
1162
+ * }
1163
+ * },
1164
+ * });
1165
+ * ```
1166
+ */
1167
+ function set_view(matrix: Matrix4): void;
1168
+ /**
1169
+ * Set the render viewport to the specified rectangle.
1170
+ *
1171
+ * @param x - left corner
1172
+ * @param y - bottom corner
1173
+ * @param width - viewport width
1174
+ * @param height - viewport height
1175
+ * @example
1176
+ * ```ts
1177
+ * // Set the viewport to the window dimensions.
1178
+ * render.set_viewport(0, 0, render.get_window_width(), render.get_window_height());
1179
+ * ```
1180
+ */
1181
+ function set_viewport(x: number, y: number, width: number, height: number): void;
1182
+ }
1183
+ }
1184
+
1185
+ export {};