@babylonjs/lite-gl 0.1.0 → 0.2.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 (61) hide show
  1. package/README.md +10 -34
  2. package/apply-states.d.ts +1 -0
  3. package/apply-states.js +30 -0
  4. package/apply-states.js.map +1 -0
  5. package/blend.d.ts +123 -0
  6. package/blend.js +194 -0
  7. package/blend.js.map +1 -0
  8. package/context.d.ts +130 -0
  9. package/context.js +354 -0
  10. package/context.js.map +1 -0
  11. package/depth-stencil.d.ts +155 -231
  12. package/depth-stencil.js +399 -262
  13. package/depth-stencil.js.map +1 -1
  14. package/dynamic-texture.d.ts +59 -149
  15. package/dynamic-texture.js +123 -69
  16. package/dynamic-texture.js.map +1 -1
  17. package/effect-renderer.d.ts +65 -0
  18. package/effect-renderer.js +132 -0
  19. package/effect-renderer.js.map +1 -0
  20. package/effect.d.ts +142 -0
  21. package/effect.js +465 -0
  22. package/effect.js.map +1 -0
  23. package/html-texture.d.ts +44 -143
  24. package/html-texture.js +87 -81
  25. package/html-texture.js.map +1 -1
  26. package/index.d.ts +23 -1482
  27. package/index.js +42 -263
  28. package/index.js.map +1 -1
  29. package/mesh.d.ts +210 -307
  30. package/mesh.js +436 -311
  31. package/mesh.js.map +1 -1
  32. package/package.json +5 -29
  33. package/render-loop.d.ts +8 -0
  34. package/render-loop.js +62 -0
  35. package/render-loop.js.map +1 -0
  36. package/render-target.d.ts +233 -290
  37. package/render-target.js +534 -335
  38. package/render-target.js.map +1 -1
  39. package/scissor.d.ts +30 -72
  40. package/scissor.js +47 -33
  41. package/scissor.js.map +1 -1
  42. package/shader.d.ts +22 -0
  43. package/shader.js +65 -0
  44. package/shader.js.map +1 -0
  45. package/sprites.d.ts +182 -263
  46. package/sprites.js +426 -10
  47. package/sprites.js.map +1 -1
  48. package/state.d.ts +126 -0
  49. package/state.js +153 -0
  50. package/state.js.map +1 -0
  51. package/texture.d.ts +142 -0
  52. package/texture.js +433 -0
  53. package/texture.js.map +1 -0
  54. package/effect-BxxwfB_O.js +0 -737
  55. package/effect-BxxwfB_O.js.map +0 -1
  56. package/sprites--1oyVtJ3.js +0 -437
  57. package/sprites--1oyVtJ3.js.map +0 -1
  58. package/state--j_ncWIi.js +0 -155
  59. package/state--j_ncWIi.js.map +0 -1
  60. package/texture-DaMd1gGm.js +0 -329
  61. package/texture-DaMd1gGm.js.map +0 -1
@@ -1,290 +1,233 @@
1
- /**
2
- * Bind the render target's framebuffer as the draw target and set the viewport
3
- * to cover it. `rt = null` binds the default (canvas) framebuffer and resets the
4
- * viewport to the full canvas the counterpart of Babylon's
5
- * `restoreDefaultFramebuffer`. Subsequent `drawEffect` / `drawIndexed` /
6
- * `clearEngine` calls write into the bound target.
7
- *
8
- * Cached. No-op on a lost/disposed context or a disposed `rt`. Mipmaps are NOT
9
- * regenerated here refresh a target's mip chain explicitly via
10
- * {@link generateRenderTargetMipMaps} after rendering into it.
11
- *
12
- * @param engine - The engine.
13
- * @param rt - The render target to draw into, or `null` for the canvas.
14
- */
15
- export declare function bindRenderTarget(engine: GLEngineContext, rt: GLRenderTarget | null): void;
16
-
17
- /**
18
- * Create an offscreen **float / half-float** render target the HDR opt-in
19
- * counterpart of {@link createRenderTarget}. This is the only render-target
20
- * factory that references the `RGBA16F` / `RGBA32F` sized-format table, so RGBA8
21
- * consumers ship none of it.
22
- *
23
- * Defaults to `gl.HALF_FLOAT`; pass `options.type = gl.FLOAT` for full 32-bit.
24
- * The requested type is downgraded to the best renderable type the engine
25
- * supports (mirroring Babylon's `getTextureType`).
26
- *
27
- * @param engine - The engine to allocate GL resources on.
28
- * @param options - See {@link GLFloatRenderTargetOptions}.
29
- * @returns The new {@link GLRenderTarget}.
30
- * @throws As {@link createRenderTarget}.
31
- */
32
- export declare function createFloatRenderTarget(engine: GLEngineContext, options: GLFloatRenderTargetOptions): GLRenderTarget;
33
-
34
- /**
35
- * Create a {@link GLPingPong}: two same-sized {@link GLRenderTarget}s for
36
- * self-feedback effects. `read` starts as the first target and `write` the
37
- * second; {@link GLPingPong.swap} exchanges them allocation-free.
38
- *
39
- * @param engine - The engine to create GL resources on.
40
- * @param options - Applied identically to both targets.
41
- * @returns The new {@link GLPingPong}.
42
- * @throws As {@link createRenderTarget}. If the second target fails to build the
43
- * first is disposed before rethrowing (no leak).
44
- */
45
- export declare function createPingPong(engine: GLEngineContext, options: GLRenderTargetOptions): GLPingPong;
46
-
47
- /**
48
- * Create an offscreen **RGBA8** render target.
49
- *
50
- * The color attachment is an owned {@link GLTexture} (rebuilt by this target's
51
- * own restore hook), unless {@link GLRenderTargetOptions.colorTexture} supplies a
52
- * caller-managed (BYO) one. Mirrors Babylon's `createRenderTargetTexture`.
53
- *
54
- * @param engine - The engine to allocate GL resources on.
55
- * @param options - See {@link GLRenderTargetOptions} (`width`/`height` required).
56
- * @returns The new {@link GLRenderTarget}.
57
- * @throws If `width`/`height` are not positive integers, a GL handle could not
58
- * be allocated, or the resulting framebuffer is not complete. On failure every
59
- * partial GPU object (including an owned color texture) is released first.
60
- */
61
- export declare function createRenderTarget(engine: GLEngineContext, options: GLRenderTargetOptions): GLRenderTarget;
62
-
63
- /**
64
- * Release both targets of a {@link GLPingPong}. Idempotent, and a no-op for
65
- * `null`/`undefined` (matching {@link disposeRenderTarget}).
66
- *
67
- * @param engine - The engine that owns `pp`.
68
- * @param pp - The ping-pong pair to release, or `null`/`undefined` for a no-op.
69
- */
70
- export declare function disposePingPong(engine: GLEngineContext, pp: GLPingPong | null | undefined): void;
71
-
72
- /**
73
- * Release the render target's framebuffer, depth/stencil renderbuffer and (iff
74
- * owned) color texture, and unregister it from the engine. Idempotent, and a
75
- * no-op for `null`/`undefined` (so an optional target can be released
76
- * unconditionally). Clears the bound-framebuffer cache if it pointed at this
77
- * target, and any sampler slot that held the color texture handle.
78
- *
79
- * A BYO {@link GLRenderTargetOptions.colorTexture} is NOT disposed here — it is
80
- * engine-managed and the caller owns its lifetime.
81
- *
82
- * @param engine - The engine.
83
- * @param rt - The render target to dispose, or `null`/`undefined` for a no-op.
84
- */
85
- export declare function disposeRenderTarget(engine: GLEngineContext, rt: GLRenderTarget | null | undefined): void;
86
-
87
- /** Regenerate a render target's color-attachment mip chain from its (freshly
88
- * rendered) level-0 mipmaps for render targets are a pure manual opt-in
89
- * (call this after rendering into the target). No-op for a disposed target, a
90
- * handle-less color attachment, or a lost/disposed context. */
91
- export declare function generateRenderTargetMipMaps(engine: GLEngineContext, rt: GLRenderTarget): void;
92
-
93
- /** Read-only WebGL2 capability limits, queried once at context creation. */
94
- declare interface GLEngineCaps {
95
- /** `gl.MAX_TEXTURE_SIZE` largest supported texture dimension, in texels. */
96
- readonly maxTextureSize: number;
97
- /** `gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS` number of sampler binding slots. */
98
- readonly maxTextureUnits: number;
99
- /** The `KHR_parallel_shader_compile` extension used for async link polling,
100
- * or null when unsupported — linking is then treated as synchronous. */
101
- readonly parallelShaderCompile: {
102
- COMPLETION_STATUS_KHR: number;
103
- } | null;
104
- /** True when 32-bit float color attachments are renderable
105
- * (`EXT_color_buffer_float`). Mirrors Babylon's `caps.textureFloatRender`. */
106
- readonly textureFloatRender: boolean;
107
- /** True when 32-bit float textures support linear filtering
108
- * (`OES_texture_float_linear`). Mirrors `caps.textureFloatLinearFiltering`. */
109
- readonly textureFloatLinearFiltering: boolean;
110
- /** True when 16-bit half-float color attachments are renderable
111
- * (`EXT_color_buffer_float` or `EXT_color_buffer_half_float`). Mirrors
112
- * `caps.textureHalfFloatRender`. */
113
- readonly textureHalfFloatRender: boolean;
114
- /** Half-float linear filtering — always `true` in WebGL2 (it is core).
115
- * Kept as a field to mirror Babylon's `caps.textureHalfFloatLinearFiltering`. */
116
- readonly textureHalfFloatLinearFiltering: boolean;
117
- /** Whether non-power-of-two textures need POT dimensions for mips / wrap.
118
- * Always `false` in WebGL2 (NPOT is core). Mirrors `engine.needPOTTextures`. */
119
- readonly needPOTTextures: boolean;
120
- }
121
-
122
- /**
123
- * Pure-state handle for a WebGL2 canvas + its cached GL state.
124
- *
125
- * INVARIANT: consumers MUST NOT mutate GL state directly through `engine.gl`.
126
- * Doing so silently corrupts the cache in `_state`. The package owns every
127
- * GL call. (`engine.gl` is exposed only so downstream code that already has the
128
- * pattern of poking `engine._gl.getExtension(...)` can do that, but must NOT
129
- * call `bindTexture`/`useProgram`/`bindBuffer`/`viewport`/etc.)
130
- */
131
- declare interface GLEngineContext {
132
- /** The canvas the WebGL2 context was acquired from. An `OffscreenCanvas` is
133
- * supported for worker render paths (e.g. the Lottie player); it has no CSS
134
- * box, so it must be sized explicitly via `setGLEngineSize` rather than the
135
- * CSS-derived `resizeGLEngine`. */
136
- readonly canvas: HTMLCanvasElement | OffscreenCanvas;
137
- /** The raw WebGL2 context. Do NOT mutate GL state through it — see the
138
- * type-level invariant above; the package owns every state-changing call. */
139
- readonly gl: WebGL2RenderingContext;
140
- /** Queried capability limits for this context. */
141
- readonly caps: GLEngineCaps;
142
-
143
- /** Options for {@link createFloatRenderTarget} {@link GLRenderTargetOptions}
144
- * plus the float color `type`. */
145
- export declare interface GLFloatRenderTargetOptions extends GLRenderTargetOptions {
146
- /** Float color attachment type. Default `gl.HALF_FLOAT`. Pass `gl.FLOAT` for
147
- * full 32-bit. Downgraded to the best renderable type the engine supports
148
- * (`caps.textureFloatRender` / `caps.textureHalfFloatRender`), mirroring
149
- * Babylon's `getTextureType`. */
150
- type?: GLenum;
151
- }
152
-
153
- /**
154
- * A pair of {@link GLRenderTarget}s for self-feedback effects: SAMPLE the
155
- * {@link GLPingPong.read | read} target (last frame's output) while RENDERING
156
- * into the {@link GLPingPong.write | write} target, then {@link GLPingPong.swap}.
157
- */
158
- export declare interface GLPingPong {
159
- /** The target to SAMPLE this frame (the previous frame's output). */
160
- readonly read: GLRenderTarget;
161
- /** The target to RENDER into this frame. */
162
- readonly write: GLRenderTarget;
163
- /** Exchange `read` and `write`. Call after rendering the `write` target each
164
- * frame. Allocation-free flips an internal index, no objects created. */
165
- swap(): void;
166
-
167
- /**
168
- * An offscreen render target a `WebGLFramebuffer` wrapping a color
169
- * {@link GLTexture} and an optional depth / stencil renderbuffer. The lite-gl
170
- * counterpart of Babylon's `RenderTargetWrapper`.
171
- */
172
- export declare interface GLRenderTarget {
173
- /** The color attachment, sampleable like any other {@link GLTexture}
174
- * (`setEffectTexture` / `bindTexture`). For an owned attachment its handle
175
- * is swapped on `webglcontextrestored` while consumers keep this same
176
- * reference. */
177
- texture: GLTexture;
178
- /** Color attachment width in texels. */
179
- width: number;
180
- /** Color attachment height in texels. */
181
- height: number;
182
- /** True once the color attachment + framebuffer are allocated. */
183
- isReady: boolean;
184
-
185
- /** Options for {@link createRenderTarget}. `width`/`height` are required; every
186
- * other field has a Babylon-matching default. The bare
187
- * `createRenderTarget(engine, { width, height })` makes an RGBA8 color-only
188
- * target with linear filtering and clamp wrapping. */
189
- export declare interface GLRenderTargetOptions {
190
- /** Color attachment width in texels. Must be a positive integer. */
191
- width: number;
192
- /** Color attachment height in texels. Must be a positive integer. */
193
- height: number;
194
- /** Allocate a depth renderbuffer (`DEPTH_COMPONENT16`). Default `false`.
195
- * Stencil is NOT a create option opt in (packed depth+stencil, or
196
- * stencil-only) via `generateRenderTargetStencil`
197
- * (`@babylonjs/lite-gl/depth-stencil`), which keeps the stencil/packed
198
- * renderbuffer code out of the render-target core bundle. */
199
- generateDepthBuffer?: boolean;
200
- /** Color texture minification filter. Default `gl.LINEAR`. */
201
- minFilter?: GLenum;
202
- /** Color texture magnification filter. Default `gl.LINEAR`. */
203
- magFilter?: GLenum;
204
- /** Color texture S wrap. Default `gl.CLAMP_TO_EDGE`. */
205
- wrapS?: GLenum;
206
- /** Color texture T wrap. Default `gl.CLAMP_TO_EDGE`. */
207
- wrapT?: GLenum;
208
- /** Attach a caller-supplied (BYO) color {@link GLTexture} instead of creating
209
- * one. When supplied the render target does NOT own or restore it — the
210
- * texture is engine-managed (restored by the standard texture-restore path
211
- * first) and the RT re-attaches its swapped handle afterwards. The caller is
212
- * responsible for sizing it to `width`×`height` and for disposing it. */
213
- colorTexture?: GLTexture;
214
- }
215
-
216
- /**
217
- * Pure-state texture handle. The `handle` field is MUTABLE so the same logical
218
- * texture survives a `webglcontextrestored` event every consumer keeps the
219
- * same `GLTexture` reference; only the internal `WebGLTexture` is swapped.
220
- *
221
- * `loadTexture2D` also uses the same handle for the 1×1 placeholder upload AND
222
- * the final image upload so a `bindTexture(engine, unit, tex)` made before the
223
- * image has decoded remains valid once the image arrives.
224
- */
225
- declare interface GLTexture {
226
- /** The live `WebGLTexture`. MUTABLE — swapped for a fresh handle on
227
- * `webglcontextrestored` while consumers keep the same `GLTexture` reference. */
228
- handle: WebGLTexture;
229
- /** GL texture target (always `gl.TEXTURE_2D` for this package). */
230
- readonly target: GLenum;
231
- /** Texture width in texels. Updated once an async upload resolves. */
232
- width: number;
233
- /** Texture height in texels. Updated once an async upload resolves. */
234
- height: number;
235
- /** True when the texture is safe to sample with final content (placeholders
236
- * read as not-ready until their image/upload completes). */
237
- isReady: boolean;
238
-
239
- /**
240
- * Synchronously read back a rectangle of the render target's color attachment
241
- * via `gl.readPixels` — the lite-gl equivalent of Babylon's
242
- * `_readTexturePixelsSync`. Binds the target's framebuffer (leaving it bound,
243
- * matching Babylon).
244
- *
245
- * The returned array element type follows the color attachment type:
246
- * `Uint8Array` for `UNSIGNED_BYTE`, `Float32Array` for `FLOAT`, `Uint16Array`
247
- * for `HALF_FLOAT`. Origin is GL bottom-left.
248
- *
249
- * @param engine - The engine.
250
- * @param rt - The render target to read from.
251
- * @param x - Lower-left X of the read rectangle, in texels.
252
- * @param y - Lower-left Y of the read rectangle, in texels.
253
- * @param width - Read rectangle width in texels.
254
- * @param height - Read rectangle height in texels.
255
- * @param into - Optional preallocated buffer (`width*height*4` elements of the
256
- * matching type). Reused to avoid per-call allocation.
257
- * @returns The pixel buffer (the provided `into`, or a freshly allocated one).
258
- * Empty buffer on a lost/disposed context.
259
- */
260
- export declare function readRenderTargetPixels(engine: GLEngineContext, rt: GLRenderTarget, x: number, y: number, width: number, height: number, into?: ArrayBufferView): ArrayBufferView;
261
-
262
- /**
263
- * Resize both targets of a {@link GLPingPong}. No-op when disposed.
264
- *
265
- * @param engine - The engine that owns `pp`.
266
- * @param pp - The ping-pong pair to resize.
267
- * @param width - New width in texels (positive integer).
268
- * @param height - New height in texels (positive integer).
269
- */
270
- export declare function resizePingPong(engine: GLEngineContext, pp: GLPingPong, width: number, height: number): void;
271
-
272
- /**
273
- * Resize the render target's color attachment (and depth/stencil renderbuffer).
274
- * Reallocates storage at the new size; the contents are discarded. The
275
- * `GLRenderTarget` / `GLTexture` identity is preserved, so consumers and
276
- * effect-sampler bindings holding the reference stay valid. If this target was
277
- * the live draw target, it is rebound (with the new-size viewport) afterwards.
278
- *
279
- * No-op when the size is unchanged or `rt` is disposed. While the context is
280
- * lost the new size is recorded but the GL reallocation is deferred to the
281
- * restore hook.
282
- *
283
- * @param engine - The engine.
284
- * @param rt - The render target to resize.
285
- * @param width - New width in texels (≥ 1).
286
- * @param height - New height in texels (≥ 1).
287
- */
288
- export declare function resizeRenderTarget(engine: GLEngineContext, rt: GLRenderTarget, width: number, height: number): void;
289
-
290
- export { }
1
+ /**
2
+ * Render-to-texture (offscreen framebuffer) support.
3
+ *
4
+ * Part of the public API via the `@babylonjs/lite-gl` barrel. The package is
5
+ * `sideEffects: false`, so consumers that only render fullscreen effects to the
6
+ * canvas tree-shake the FBO code out.
7
+ *
8
+ * This is the lite-gl equivalent of Babylon's `RenderTargetWrapper` +
9
+ * `ThinEngine.createRenderTargetTexture` / `bindFramebuffer` /
10
+ * `restoreDefaultFramebuffer` / `_readTexturePixelsSync`. A render target owns a
11
+ * color {@link GLTexture} (or attaches a caller-supplied one) plus an optional
12
+ * depth and/or stencil renderbuffer, all wrapped in a single
13
+ * `WebGLFramebuffer`.
14
+ *
15
+ * The default {@link createRenderTarget} makes an **RGBA8** color target and
16
+ * ships none of the HDR sized-format knowledge; {@link createFloatRenderTarget}
17
+ * is the separate opt-in for float / half-float color attachments (it alone
18
+ * carries the `RGBA16F` / `RGBA32F` table, so RGBA8 consumers tree-shake it
19
+ * away).
20
+ *
21
+ * The full color/depth/stencil GPU set is rebuilt automatically on
22
+ * `webglcontextrestored` — the render target registers itself with the engine's
23
+ * `_renderTargets` registry, and the context-restore protocol calls its
24
+ * `_restore` closure AFTER the standalone texture replay. A caller-supplied
25
+ * (BYO) color texture lives in the engine's `_textures` registry and is restored
26
+ * there first; the RT then re-attaches its freshly-swapped handle.
27
+ */
28
+ import { type GLTexture } from "./texture.js";
29
+ import type { GLEngineContext } from "./context.js";
30
+ /** Options for {@link createRenderTarget}. `width`/`height` are required; every
31
+ * other field has a Babylon-matching default. The bare
32
+ * `createRenderTarget(engine, { width, height })` makes an RGBA8 color-only
33
+ * target with linear filtering and clamp wrapping. */
34
+ export interface GLRenderTargetOptions {
35
+ /** Color attachment width in texels. Must be a positive integer. */
36
+ width: number;
37
+ /** Color attachment height in texels. Must be a positive integer. */
38
+ height: number;
39
+ /** Allocate a depth renderbuffer (`DEPTH_COMPONENT16`). Default `false`.
40
+ * Stencil is NOT a create option opt in (packed depth+stencil, or
41
+ * stencil-only) via `generateRenderTargetStencil`
42
+ * (`@babylonjs/lite-gl`), which keeps the stencil/packed
43
+ * renderbuffer code out of the render-target core bundle. */
44
+ generateDepthBuffer?: boolean;
45
+ /** Color texture minification filter. Default `gl.LINEAR`. */
46
+ minFilter?: GLenum;
47
+ /** Color texture magnification filter. Default `gl.LINEAR`. */
48
+ magFilter?: GLenum;
49
+ /** Color texture S wrap. Default `gl.CLAMP_TO_EDGE`. */
50
+ wrapS?: GLenum;
51
+ /** Color texture T wrap. Default `gl.CLAMP_TO_EDGE`. */
52
+ wrapT?: GLenum;
53
+ /** Attach a caller-supplied (BYO) color {@link GLTexture} instead of creating
54
+ * one. When supplied the render target does NOT own or restore it — the
55
+ * texture is engine-managed (restored by the standard texture-restore path
56
+ * first) and the RT re-attaches its swapped handle afterwards. The caller is
57
+ * responsible for sizing it to `width`×`height` and for disposing it. */
58
+ colorTexture?: GLTexture;
59
+ }
60
+ /** Options for {@link createFloatRenderTarget} — {@link GLRenderTargetOptions}
61
+ * plus the float color `type`. */
62
+ export interface GLFloatRenderTargetOptions extends GLRenderTargetOptions {
63
+ /** Float color attachment type. Default `gl.HALF_FLOAT`. Pass `gl.FLOAT` for
64
+ * full 32-bit. Downgraded to the best renderable type the engine supports
65
+ * (`caps.textureFloatRender` / `caps.textureHalfFloatRender`), mirroring
66
+ * Babylon's `getTextureType`. */
67
+ type?: GLenum;
68
+ }
69
+ /**
70
+ * An offscreen render target a `WebGLFramebuffer` wrapping a color
71
+ * {@link GLTexture} and an optional depth / stencil renderbuffer. The lite-gl
72
+ * counterpart of Babylon's `RenderTargetWrapper`.
73
+ */
74
+ export interface GLRenderTarget {
75
+ /** The color attachment, sampleable like any other {@link GLTexture}
76
+ * (`setEffectTexture` / `bindTexture`). For an owned attachment its handle
77
+ * is swapped on `webglcontextrestored` while consumers keep this same
78
+ * reference. */
79
+ texture: GLTexture;
80
+ /** Color attachment width in texels. */
81
+ width: number;
82
+ /** Color attachment height in texels. */
83
+ height: number;
84
+ /** True once the color attachment + framebuffer are allocated. */
85
+ isReady: boolean;
86
+ }
87
+ /**
88
+ * A pair of {@link GLRenderTarget}s for self-feedback effects: SAMPLE the
89
+ * {@link GLPingPong.read | read} target (last frame's output) while RENDERING
90
+ * into the {@link GLPingPong.write | write} target, then {@link GLPingPong.swap}.
91
+ */
92
+ export interface GLPingPong {
93
+ /** The target to SAMPLE this frame (the previous frame's output). */
94
+ readonly read: GLRenderTarget;
95
+ /** The target to RENDER into this frame. */
96
+ readonly write: GLRenderTarget;
97
+ /** Exchange `read` and `write`. Call after rendering the `write` target each
98
+ * frame. Allocation-free — flips an internal index, no objects created. */
99
+ swap(): void;
100
+ }
101
+ /**
102
+ * Create an offscreen **RGBA8** render target.
103
+ *
104
+ * The color attachment is an owned {@link GLTexture} (rebuilt by this target's
105
+ * own restore hook), unless {@link GLRenderTargetOptions.colorTexture} supplies a
106
+ * caller-managed (BYO) one. Mirrors Babylon's `createRenderTargetTexture`.
107
+ *
108
+ * @param engine - The engine to allocate GL resources on.
109
+ * @param options - See {@link GLRenderTargetOptions} (`width`/`height` required).
110
+ * @returns The new {@link GLRenderTarget}.
111
+ * @throws If `width`/`height` are not positive integers, a GL handle could not
112
+ * be allocated, or the resulting framebuffer is not complete. On failure every
113
+ * partial GPU object (including an owned color texture) is released first.
114
+ */
115
+ export declare function createRenderTarget(engine: GLEngineContext, options: GLRenderTargetOptions): GLRenderTarget;
116
+ /**
117
+ * Create an offscreen **float / half-float** render target — the HDR opt-in
118
+ * counterpart of {@link createRenderTarget}. This is the only render-target
119
+ * factory that references the `RGBA16F` / `RGBA32F` sized-format table, so RGBA8
120
+ * consumers ship none of it.
121
+ *
122
+ * Defaults to `gl.HALF_FLOAT`; pass `options.type = gl.FLOAT` for full 32-bit.
123
+ * The requested type is downgraded to the best renderable type the engine
124
+ * supports (mirroring Babylon's `getTextureType`).
125
+ *
126
+ * @param engine - The engine to allocate GL resources on.
127
+ * @param options - See {@link GLFloatRenderTargetOptions}.
128
+ * @returns The new {@link GLRenderTarget}.
129
+ * @throws As {@link createRenderTarget}.
130
+ */
131
+ export declare function createFloatRenderTarget(engine: GLEngineContext, options: GLFloatRenderTargetOptions): GLRenderTarget;
132
+ /**
133
+ * Bind the render target's framebuffer as the draw target and set the viewport
134
+ * to cover it. `rt = null` binds the default (canvas) framebuffer and resets the
135
+ * viewport to the full canvas — the counterpart of Babylon's
136
+ * `restoreDefaultFramebuffer`. Subsequent `drawEffect` / `drawIndexed` /
137
+ * `clearEngine` calls write into the bound target.
138
+ *
139
+ * Cached. No-op on a lost/disposed context or a disposed `rt`. Mipmaps are NOT
140
+ * regenerated here refresh a target's mip chain explicitly via
141
+ * {@link generateRenderTargetMipMaps} after rendering into it.
142
+ *
143
+ * @param engine - The engine.
144
+ * @param rt - The render target to draw into, or `null` for the canvas.
145
+ */
146
+ export declare function bindRenderTarget(engine: GLEngineContext, rt: GLRenderTarget | null): void;
147
+ /** Regenerate a render target's color-attachment mip chain from its (freshly
148
+ * rendered) level-0 mipmaps for render targets are a pure manual opt-in
149
+ * (call this after rendering into the target). No-op for a disposed target, a
150
+ * handle-less color attachment, or a lost/disposed context. */
151
+ export declare function generateRenderTargetMipMaps(engine: GLEngineContext, rt: GLRenderTarget): void;
152
+ /**
153
+ * Resize the render target's color attachment (and depth/stencil renderbuffer).
154
+ * Reallocates storage at the new size; the contents are discarded. The
155
+ * `GLRenderTarget` / `GLTexture` identity is preserved, so consumers and
156
+ * effect-sampler bindings holding the reference stay valid. If this target was
157
+ * the live draw target, it is rebound (with the new-size viewport) afterwards.
158
+ *
159
+ * No-op when the size is unchanged or `rt` is disposed. While the context is
160
+ * lost the new size is recorded but the GL reallocation is deferred to the
161
+ * restore hook.
162
+ *
163
+ * @param engine - The engine.
164
+ * @param rt - The render target to resize.
165
+ * @param width - New width in texels (≥ 1).
166
+ * @param height - New height in texels (≥ 1).
167
+ */
168
+ export declare function resizeRenderTarget(engine: GLEngineContext, rt: GLRenderTarget, width: number, height: number): void;
169
+ /**
170
+ * Synchronously read back a rectangle of the render target's color attachment
171
+ * via `gl.readPixels` — the lite-gl equivalent of Babylon's
172
+ * `_readTexturePixelsSync`. Binds the target's framebuffer (leaving it bound,
173
+ * matching Babylon).
174
+ *
175
+ * The returned array element type follows the color attachment type:
176
+ * `Uint8Array` for `UNSIGNED_BYTE`, `Float32Array` for `FLOAT`, `Uint16Array`
177
+ * for `HALF_FLOAT`. Origin is GL bottom-left.
178
+ *
179
+ * @param engine - The engine.
180
+ * @param rt - The render target to read from.
181
+ * @param x - Lower-left X of the read rectangle, in texels.
182
+ * @param y - Lower-left Y of the read rectangle, in texels.
183
+ * @param width - Read rectangle width in texels.
184
+ * @param height - Read rectangle height in texels.
185
+ * @param into - Optional preallocated buffer (`width*height*4` elements of the
186
+ * matching type). Reused to avoid per-call allocation.
187
+ * @returns The pixel buffer (the provided `into`, or a freshly allocated one).
188
+ * Empty buffer on a lost/disposed context.
189
+ */
190
+ export declare function readRenderTargetPixels(engine: GLEngineContext, rt: GLRenderTarget, x: number, y: number, width: number, height: number, into?: ArrayBufferView): ArrayBufferView;
191
+ /**
192
+ * Release the render target's framebuffer, depth/stencil renderbuffer and (iff
193
+ * owned) color texture, and unregister it from the engine. Idempotent, and a
194
+ * no-op for `null`/`undefined` (so an optional target can be released
195
+ * unconditionally). Clears the bound-framebuffer cache if it pointed at this
196
+ * target, and any sampler slot that held the color texture handle.
197
+ *
198
+ * A BYO {@link GLRenderTargetOptions.colorTexture} is NOT disposed here — it is
199
+ * engine-managed and the caller owns its lifetime.
200
+ *
201
+ * @param engine - The engine.
202
+ * @param rt - The render target to dispose, or `null`/`undefined` for a no-op.
203
+ */
204
+ export declare function disposeRenderTarget(engine: GLEngineContext, rt: GLRenderTarget | null | undefined): void;
205
+ /**
206
+ * Create a {@link GLPingPong}: two same-sized {@link GLRenderTarget}s for
207
+ * self-feedback effects. `read` starts as the first target and `write` the
208
+ * second; {@link GLPingPong.swap} exchanges them allocation-free.
209
+ *
210
+ * @param engine - The engine to create GL resources on.
211
+ * @param options - Applied identically to both targets.
212
+ * @returns The new {@link GLPingPong}.
213
+ * @throws As {@link createRenderTarget}. If the second target fails to build the
214
+ * first is disposed before rethrowing (no leak).
215
+ */
216
+ export declare function createPingPong(engine: GLEngineContext, options: GLRenderTargetOptions): GLPingPong;
217
+ /**
218
+ * Resize both targets of a {@link GLPingPong}. No-op when disposed.
219
+ *
220
+ * @param engine - The engine that owns `pp`.
221
+ * @param pp - The ping-pong pair to resize.
222
+ * @param width - New width in texels (positive integer).
223
+ * @param height - New height in texels (positive integer).
224
+ */
225
+ export declare function resizePingPong(engine: GLEngineContext, pp: GLPingPong, width: number, height: number): void;
226
+ /**
227
+ * Release both targets of a {@link GLPingPong}. Idempotent, and a no-op for
228
+ * `null`/`undefined` (matching {@link disposeRenderTarget}).
229
+ *
230
+ * @param engine - The engine that owns `pp`.
231
+ * @param pp - The ping-pong pair to release, or `null`/`undefined` for a no-op.
232
+ */
233
+ export declare function disposePingPong(engine: GLEngineContext, pp: GLPingPong | null | undefined): void;