本文整理汇总了TypeScript中neuroglancer/webgl/context.GL类的典型用法代码示例。如果您正苦于以下问题:TypeScript GL类的具体用法?TypeScript GL怎么用?TypeScript GL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GL类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setupTextureLayout
/**
* Called each time textureLayout changes while drawing chunks.
*/
setupTextureLayout(gl: GL, shader: ShaderProgram, textureLayout: TextureLayout) {
gl.uniform3fv(shader.uniform('uChunkDataSize'), textureLayout.chunkDataSize);
gl.uniform3fv(shader.uniform('uSubchunkGridSize'), textureLayout.subchunkGridSize);
gl.uniform2fv(
shader.uniform('uCompressedSegmentationTextureAccessCoefficients'),
textureLayout.textureAccessCoefficients);
}
示例2: disableCountingBuffer
export function disableCountingBuffer(gl: GL, shader: ShaderProgram, instanced = false) {
const location = shader.attribute('aIndexRaw');
if (location >= 0) {
if (instanced) {
gl.vertexAttribDivisor(location, 0);
}
gl.disableVertexAttribArray(location);
}
}
示例3: draw
draw(gl: GL, numInstances: number) {
if (this.quadsPerInstance === 1) {
gl.drawArraysInstanced(WebGL2RenderingContext.TRIANGLE_FAN, 0, 4, numInstances);
} else {
this.quadIndexBuffer.bind();
gl.drawElementsInstanced(
WebGL2RenderingContext.TRIANGLES, INDICES_PER_QUAD * this.quadsPerInstance,
WebGL2RenderingContext.UNSIGNED_SHORT, /*offset=*/0, numInstances);
}
}
示例4: 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);
}
示例5: 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);
}
示例6: setupTextureLayout
/**
* Called each time textureLayout changes while drawing chunks.
*/
setupTextureLayout(gl: GL, shader: ShaderProgram, textureLayout: TextureLayout) {
const {subchunkGridSize} = textureLayout;
gl.uniform3i(
shader.uniform('uSubchunkGridSize'), subchunkGridSize[0], subchunkGridSize[1],
subchunkGridSize[2]);
this.textureAccessHelper.setupTextureLayout(gl, shader, textureLayout);
}
示例7: webglTest
export function webglTest(f: (gl: GL, canvas: HTMLCanvasElement) => void) {
let canvas = document.createElement('canvas');
document.body.appendChild(canvas);
let gl: GL|undefined;
try {
gl = initializeWebGL(canvas);
f(gl, canvas);
} finally {
if (gl != null) {
const loseContext = gl.getExtension('WEBGL_lose_context');
if (loseContext !== null) {
loseContext.loseContext();
}
}
document.body.removeChild(canvas);
}
}
示例8: enable
enable(shader: ShaderProgram, context: AnnotationRenderContext, callback: () => void) {
shader.bind();
const {gl} = this;
const {renderContext} = context;
const {annotationLayer} = context;
gl.uniformMatrix4fv(shader.uniform('uProjection'), false, context.projectionMatrix);
if (renderContext.emitPickID) {
gl.uniform1ui(shader.uniform('uPickID'), context.basePickId);
}
if (renderContext.emitColor) {
const colorVec4 = tempPickID;
const color = annotationLayer.state.color.value;
colorVec4[0] = color[0];
colorVec4[1] = color[1];
colorVec4[2] = color[2];
colorVec4[3] = 1;
gl.uniform4fv(shader.uniform('uColor'), colorVec4);
const saturationAmount = 0.75;
for (let i = 0; i < 3; ++i) {
colorVec4[i] = saturationAmount + (1 - saturationAmount) * colorVec4[i];
}
gl.uniform4fv(shader.uniform('uColorSelected'), colorVec4);
gl.uniform1ui(shader.uniform('uSelectedIndex'), context.selectedIndex);
}
callback();
}
示例9:
builder.addInitializer(shader => {
let textureIndices: number[] = [];
for (let i = 0; i < numTextures; ++i) {
textureIndices[i] = i;
}
gl.uniform1iv(shader.uniform('uSampler'), textureIndices);
});
示例10: bind
bind(shader: ShaderProgram, divisor = 0) {
const location = shader.attribute('aIndexRaw');
if (location >= 0) {
this.bindToVertexAttrib(location);
if (divisor !== 0) {
this.gl.vertexAttribDivisor(location, divisor);
}
}
}