本文整理汇总了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));
}