EN
이 콘텐츠는 한국어로 제공되지 않아 영어 버전으로 표시됩니다.

enableVertexAttribArray method

Turns on a vertex attribute at a specific index position in a vertex attribute array.

IE11

 

Syntax

WebGLRenderingContext.enableVertexAttribArray(index);

Parameters

index [in]

Type: Number

Index of the vertex attribute to enable.

Return value

This method does not return a value.

Remarks

WebGL errorDescription
gl.INVALID_VALUEIf the index is negative or greater than the gl.MAX_VERTEX_ATTRIBS.

 

All client-side capabilities are disabled by default, including all vertex attribute arrays.

Examples

The following example uses enableVertexAttribArray to enable a vertex attribute in either a line or a photo rendering app. For more info on this example, see Get started with WebGL.


//  Clear color buffer and set it to light gray
    gl.clearColor(1.0, 1.0, 1.0, 0.5);
    gl.clear(this.gl.COLOR_BUFFER_BIT);
            
// This draws either the grid or the photo for stretching
    if (document.getElementById("renderLines").checked)
    {
      gl.bindBuffer(gl.ARRAY_BUFFER, this.texCoordBuffer2);

      gl.useProgram(this.lineprogram);

      gl.uniform2fv(gl.getUniformLocation(this.lineprogram, "p1"), p1);
      gl.uniform2fv(gl.getUniformLocation(this.lineprogram, "p2"), p2);

      gl.vertexAttribPointer(this.texCoordLocation2, 2, gl.FLOAT, false, 0, 0);

      gl.enableVertexAttribArray(this.texCoordLocation2);

      gl.drawArrays(gl.LINES, 0, resolution * resolution * 10);
    }
    else
    { 
      gl.bindBuffer(gl.ARRAY_BUFFER, this.texCoordBuffer);
      
      gl.useProgram(this.pictureprogram);


      gl.uniform2fv(gl.getUniformLocation(this.pictureprogram, "p1"), p1);
      gl.uniform2fv(gl.getUniformLocation(this.pictureprogram, "p2"), p2);

      gl.vertexAttribPointer(this.texCoordLocation, 2, gl.FLOAT, false, 0, 0);

      gl.enableVertexAttribArray(this.texCoordLocation);


      gl.drawArrays(gl.TRIANGLES, 0, resolution * resolution * 2 * 3);
    }


See also

WebGLRenderingContext

 

 

표시:
© 2014 Microsoft