當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript context.GL類代碼示例

本文整理匯總了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;未經允許,請勿轉載。