@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.
- package/README.md +10 -34
- package/apply-states.d.ts +1 -0
- package/apply-states.js +30 -0
- package/apply-states.js.map +1 -0
- package/blend.d.ts +123 -0
- package/blend.js +194 -0
- package/blend.js.map +1 -0
- package/context.d.ts +130 -0
- package/context.js +354 -0
- package/context.js.map +1 -0
- package/depth-stencil.d.ts +155 -231
- package/depth-stencil.js +399 -262
- package/depth-stencil.js.map +1 -1
- package/dynamic-texture.d.ts +59 -149
- package/dynamic-texture.js +123 -69
- package/dynamic-texture.js.map +1 -1
- package/effect-renderer.d.ts +65 -0
- package/effect-renderer.js +132 -0
- package/effect-renderer.js.map +1 -0
- package/effect.d.ts +142 -0
- package/effect.js +465 -0
- package/effect.js.map +1 -0
- package/html-texture.d.ts +44 -143
- package/html-texture.js +87 -81
- package/html-texture.js.map +1 -1
- package/index.d.ts +23 -1482
- package/index.js +42 -263
- package/index.js.map +1 -1
- package/mesh.d.ts +210 -307
- package/mesh.js +436 -311
- package/mesh.js.map +1 -1
- package/package.json +5 -29
- package/render-loop.d.ts +8 -0
- package/render-loop.js +62 -0
- package/render-loop.js.map +1 -0
- package/render-target.d.ts +233 -290
- package/render-target.js +534 -335
- package/render-target.js.map +1 -1
- package/scissor.d.ts +30 -72
- package/scissor.js +47 -33
- package/scissor.js.map +1 -1
- package/shader.d.ts +22 -0
- package/shader.js +65 -0
- package/shader.js.map +1 -0
- package/sprites.d.ts +182 -263
- package/sprites.js +426 -10
- package/sprites.js.map +1 -1
- package/state.d.ts +126 -0
- package/state.js +153 -0
- package/state.js.map +1 -0
- package/texture.d.ts +142 -0
- package/texture.js +433 -0
- package/texture.js.map +1 -0
- package/effect-BxxwfB_O.js +0 -737
- package/effect-BxxwfB_O.js.map +0 -1
- package/sprites--1oyVtJ3.js +0 -437
- package/sprites--1oyVtJ3.js.map +0 -1
- package/state--j_ncWIi.js +0 -155
- package/state--j_ncWIi.js.map +0 -1
- package/texture-DaMd1gGm.js +0 -329
- package/texture-DaMd1gGm.js.map +0 -1
package/render-target.d.ts
CHANGED
|
@@ -1,290 +1,233 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* `
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
readonly
|
|
97
|
-
/** `
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*/
|
|
131
|
-
declare
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
*
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*/
|
|
225
|
-
declare
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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;
|