pixi.js
Version:
<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">
87 lines (85 loc) • 2.1 kB
JavaScript
;
const glUploadImageResource = {
id: "image",
upload(source, glTexture, gl, webGLVersion) {
const glWidth = glTexture.width;
const glHeight = glTexture.height;
const textureWidth = source.pixelWidth;
const textureHeight = source.pixelHeight;
const resourceWidth = source.resourceWidth;
const resourceHeight = source.resourceHeight;
if (resourceWidth < textureWidth || resourceHeight < textureHeight) {
if (glWidth !== textureWidth || glHeight !== textureHeight) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
null
);
}
if (webGLVersion === 2) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
resourceWidth,
resourceHeight,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
}
} else if (glWidth === textureWidth && glHeight === textureHeight) {
gl.texSubImage2D(
gl.TEXTURE_2D,
0,
0,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else if (webGLVersion === 2) {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
textureWidth,
textureHeight,
0,
glTexture.format,
glTexture.type,
source.resource
);
} else {
gl.texImage2D(
glTexture.target,
0,
glTexture.internalFormat,
glTexture.format,
glTexture.type,
source.resource
);
}
glTexture.width = textureWidth;
glTexture.height = textureHeight;
}
};
export { glUploadImageResource };
//# sourceMappingURL=glUploadImageResource.mjs.map