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


TypeScript buffer.Buffer類代碼示例

本文整理匯總了TypeScript中neuroglancer/webgl/buffer.Buffer的典型用法代碼示例。如果您正苦於以下問題:TypeScript Buffer類的具體用法?TypeScript Buffer怎麽用?TypeScript Buffer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Buffer類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: draw

  draw(mat: Mat4, blend = true) {
    let shader = this.trivialColorShader;
    let gl = this.gl;
    shader.bind();
    gl.uniformMatrix4fv(shader.uniform('uProjectionMatrix'), false, mat);
    let aVertexPosition = shader.attribute('aVertexPosition');
    this.vertexBuffer.bindToVertexAttrib(aVertexPosition, 4);

    let aColor = shader.attribute('aColor');
    this.colorBuffer.bindToVertexAttrib(aColor, 4);

    if (blend) {
      gl.colorMask(false, false, false, true);
      gl.clearColor(0, 0, 0, 0);
      gl.clear(gl.COLOR_BUFFER_BIT);
      gl.colorMask(true, true, true, true);
      gl.enable(gl.BLEND);
      gl.blendFunc(gl.ONE_MINUS_DST_ALPHA, gl.DST_ALPHA);
    }


    gl.lineWidth(1);
    gl.drawArrays(gl.LINES, 0, 6);

    if (blend) {
      gl.disable(gl.BLEND);
    }

    gl.disableVertexAttribArray(aVertexPosition);
    gl.disableVertexAttribArray(aColor);
  }
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:31,代碼來源:axes_lines.ts

示例2: constructor

  constructor(public gl: GL) {
    super();
    this.vertexBuffer = this.registerDisposer(Buffer.fromData(
        gl, new Float32Array([
          0, 0, 0, 1,  //
          1, 0, 0, 1,  //
          0, 0, 0, 1,  //
          0, 1, 0, 1,  //
          0, 0, 0, 1,  //
          0, 0, 1, 1,  //
        ]),
        gl.ARRAY_BUFFER, gl.STATIC_DRAW));

    let alpha = 0.5;
    this.colorBuffer = this.registerDisposer(Buffer.fromData(
        gl, new Float32Array([
          1, 0, 0, alpha,  //
          1, 0, 0, alpha,  //
          0, 1, 0, alpha,  //
          0, 1, 0, alpha,  //
          0, 0, 1, alpha,  //
          0, 0, 1, alpha,  //
        ]),
        gl.ARRAY_BUFFER, gl.STATIC_DRAW));
    this.trivialColorShader = this.registerDisposer(trivialColorShader(gl));
  }
開發者ID:j6k4m8,項目名稱:neuroglancer,代碼行數:26,代碼來源:axes_lines.ts

示例3: draw

 draw(shader: ShaderProgram, numInstances: number) {
   const aSphereVertex = shader.attribute('aSphereVertex');
   this.vertexBuffer.bindToVertexAttrib(
       aSphereVertex, /*components=*/3, /*attributeType=*/WebGL2RenderingContext.FLOAT,
       /*normalized=*/false);
   this.indexBuffer.bind();
   shader.gl.drawElementsInstanced(
       WebGL2RenderingContext.TRIANGLES, this.numIndices, WebGL2RenderingContext.UNSIGNED_SHORT,
       /*offset=*/0, numInstances);
   shader.gl.disableVertexAttribArray(aSphereVertex);
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:11,代碼來源:spheres.ts

示例4: RefCountedValue

 () => new RefCountedValue(Buffer.fromData(
     gl, new Float32Array([
       startX, startY,  //
       startX, endY,    //
       endX, endY,      //
       endX, startY,    //
     ]),
     GL_ARRAY_BUFFER, GL_STATIC_DRAW)))
開發者ID:janelia-flyem,項目名稱:neuroglancer,代碼行數:8,代碼來源:square_corners_buffer.ts

示例5: 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

示例6: resize

 resize(length: number) {
   let bufferData: ArrayBufferView;
   if (length < 256) {
     let data = bufferData = new Uint8Array(length);
     for (let i = 0; i < length; ++i) {
       data[i] = i;
     }
     this.webglType = WebGL2RenderingContext.UNSIGNED_BYTE;
   } else if (length < 65536) {
     const data = bufferData = new Uint16Array(length);
     for (let i = 0; i < length; ++i) {
       data[i] = i;
     }
     this.webglType = WebGL2RenderingContext.UNSIGNED_SHORT;
   } else {
     const data = bufferData = new Uint32Array(length);
     for (let i = 0; i < length; ++i) {
       data[i] = i;
     }
     this.webglType = WebGL2RenderingContext.UNSIGNED_INT;
   }
   this.buffer.setData(bufferData);
   this.length = length;
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:24,代碼來源:index_emulation.ts

示例7: makeIndexBuffer

export function makeIndexBuffer(gl: WebGL2RenderingContext, data: Uint32Array) {
  return Buffer.fromData(
      gl, data, WebGL2RenderingContext.ARRAY_BUFFER, WebGL2RenderingContext.STATIC_DRAW);
}
開發者ID:google,項目名稱:neuroglancer,代碼行數:4,代碼來源:index_emulation.ts

示例8: bind

 bind(buffer: Buffer, shader: ShaderProgram) {
   const attrib = shader.attribute(this.name);
   buffer.bindToVertexAttribI(attrib, /*components=*/ 1, WebGL2RenderingContext.UNSIGNED_INT);
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:4,代碼來源:index_emulation.ts

示例9: bindToVertexAttrib

 bindToVertexAttrib(location: number) {
   this.buffer.bindToVertexAttribI(location, 1, this.webglType);
 }
開發者ID:google,項目名稱:neuroglancer,代碼行數:3,代碼來源:index_emulation.ts


注:本文中的neuroglancer/webgl/buffer.Buffer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。