1 | import { ALPHA_MODES } from '@pixi/constants';
|
2 | import { BufferResource } from './BufferResource.mjs';
|
3 |
|
4 | class DepthResource extends BufferResource {
|
5 | upload(renderer, baseTexture, glTexture) {
|
6 | const gl = renderer.gl;
|
7 | gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, baseTexture.alphaMode === ALPHA_MODES.UNPACK);
|
8 | const width = baseTexture.realWidth;
|
9 | const height = baseTexture.realHeight;
|
10 | if (glTexture.width === width && glTexture.height === height) {
|
11 | gl.texSubImage2D(baseTexture.target, 0, 0, 0, width, height, baseTexture.format, glTexture.type, this.data);
|
12 | } else {
|
13 | glTexture.width = width;
|
14 | glTexture.height = height;
|
15 | gl.texImage2D(baseTexture.target, 0, glTexture.internalFormat, width, height, 0, baseTexture.format, glTexture.type, this.data);
|
16 | }
|
17 | return true;
|
18 | }
|
19 | }
|
20 |
|
21 | export { DepthResource };
|
22 |
|