Fallback if OES_texture_float_linear not supported

This commit is contained in:
mike-000
2022-03-25 11:10:11 +00:00
committed by GitHub
parent 396f8b43c2
commit 30ec260c4a

View File

@@ -58,7 +58,18 @@ function uploadDataTexture(
interpolate
) {
const gl = helper.getGL();
bindAndConfigure(gl, texture, interpolate);
let textureType;
let canInterpolate;
if (data instanceof Float32Array) {
textureType = gl.FLOAT;
helper.getExtension('OES_texture_float');
const extension = helper.getExtension('OES_texture_float_linear');
canInterpolate = extension !== null;
} else {
textureType = gl.UNSIGNED_BYTE;
canInterpolate = true;
}
bindAndConfigure(gl, texture, interpolate && canInterpolate);
const bytesPerRow = data.byteLength / size[1];
let unpackAlignment = 1;
@@ -93,15 +104,6 @@ function uploadDataTexture(
}
}
let textureType;
if (data instanceof Float32Array) {
textureType = gl.FLOAT;
helper.getExtension('OES_texture_float');
helper.getExtension('OES_texture_float_linear');
} else {
textureType = gl.UNSIGNED_BYTE;
}
const oldUnpackAlignment = gl.getParameter(gl.UNPACK_ALIGNMENT);
gl.pixelStorei(gl.UNPACK_ALIGNMENT, unpackAlignment);
gl.texImage2D(