本文整理匯總了TypeScript中neuroglancer/webgl/context.GL.texImage2D方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript GL.texImage2D方法的具體用法?TypeScript GL.texImage2D怎麽用?TypeScript GL.texImage2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類neuroglancer/webgl/context.GL
的用法示例。
在下文中一共展示了GL.texImage2D方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setTextureData
setTextureData(gl: GL) {
let {source} = this;
let {chunkFormatHandler} = source;
let {chunkFormat} = chunkFormatHandler;
let textureLayout: TextureLayout;
if (this.chunkDataSize === source.spec.chunkDataSize) {
this.textureLayout = textureLayout = chunkFormatHandler.textureLayout.addRef();
} else {
this.textureLayout = textureLayout = chunkFormat.getTextureLayout(gl, this.chunkDataSize);
}
let requiredSize = textureLayout.textureWidth * textureLayout.textureHeight *
chunkFormat.arrayElementsPerTexel;
let {arrayConstructor} = chunkFormat;
let data: TypedArray = this.data;
if (data.constructor !== arrayConstructor) {
data = new arrayConstructor(data.buffer, data.byteOffset, data.byteLength / arrayConstructor.BYTES_PER_ELEMENT);
}
let padded = maybePadArray(data, requiredSize);
gl.texImage2D(
gl.TEXTURE_2D,
/*level=*/0, chunkFormat.textureFormat,
/*width=*/textureLayout.textureWidth,
/*height=*/textureLayout.textureHeight,
/*border=*/0, chunkFormat.textureFormat, chunkFormat.texelType, padded);
}
示例2: resizeTexture
export function resizeTexture(gl: GL, texture: WebGLTexture, width: number, height: number,
format: number = gl.RGBA, dataType: number = gl.UNSIGNED_BYTE) {
gl.activeTexture(gl.TEXTURE0 + gl.tempTextureUnit);
gl.bindTexture(gl.TEXTURE_2D, texture);
setRawTextureParameters(gl);
gl.texImage2D(
gl.TEXTURE_2D, 0,
/*internalformat=*/format,
/*width=*/width,
/*height=*/height,
/*border=*/0,
/*format=*/format, dataType, null);
gl.bindTexture(gl.TEXTURE_2D, null);
}
示例3: setTextureData
setTextureData(gl: GL) {
let {data} = this;
let {chunkFormat} = this;
let textureLayout = this.textureLayout =
chunkFormat.getTextureLayout(gl, this.chunkDataSize, data.length);
let requiredSize = textureLayout.textureWidth * textureLayout.textureHeight;
let padded = maybePadArray(data, requiredSize);
gl.texImage2D(
gl.TEXTURE_2D,
/*level=*/0, gl.RGBA,
/*width=*/textureLayout.textureWidth,
/*height=*/textureLayout.textureHeight,
/*border=*/0, gl.RGBA, gl.UNSIGNED_BYTE,
new Uint8Array(padded.buffer, padded.byteOffset, padded.byteLength));
}