当前位置: 首页>>代码示例>>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;未经允许,请勿转载。