本文整理汇总了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);
}
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:10,代码来源:chunk_format.ts
示例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);
}
}
开发者ID:google,项目名称:neuroglancer,代码行数:9,代码来源:index_emulation.ts
示例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);
}
}
开发者ID:google,项目名称:neuroglancer,代码行数:10,代码来源:quad.ts
示例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);
}
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:14,代码来源:texture.ts
示例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);
}
开发者ID:j6k4m8,项目名称:neuroglancer,代码行数:27,代码来源:uncompressed_chunk_format.ts
示例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);
}
开发者ID:google,项目名称:neuroglancer,代码行数:10,代码来源:chunk_format.ts
示例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);
}
}
开发者ID:google,项目名称:neuroglancer,代码行数:17,代码来源:testing.ts
示例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();
}
开发者ID:google,项目名称:neuroglancer,代码行数:27,代码来源:type_handler.ts
示例9:
builder.addInitializer(shader => {
let textureIndices: number[] = [];
for (let i = 0; i < numTextures; ++i) {
textureIndices[i] = i;
}
gl.uniform1iv(shader.uniform('uSampler'), textureIndices);
});
开发者ID:janelia-flyem,项目名称:neuroglancer,代码行数:7,代码来源:trivial_shaders.ts
示例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);
}
}
}
开发者ID:google,项目名称:neuroglancer,代码行数:9,代码来源:index_emulation.ts
注:本文中的neuroglancer/webgl/context.GL类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论