How to use and what are the arguments for this api. And any additional notes.

Link to ES 2.0 site for the API


void glVertexAttribPointer(   GLuint index,
    GLint size,
    GLenum type,
    GLboolean normalized,
    GLsizei stride,
    const GLvoid * pointer);

This is not the same as indexing into set of vertices to reuse vertices. This points to the binding location to the corresponding variable in the vertex shader program.


private void transferTexturePoints(int texturePositionHandle)
    {
        GLES20.glVertexAttribPointer(texturePositionHandle, 2, GLES20.GL_FLOAT, false,
                0, mFVertexBuffer);
        checkGlError("glVertexAttribPointer texture array");
        //mFVertexBuffer.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
        GLES20.glEnableVertexAttribArray(texturePositionHandle);
        checkGlError("glEnableVertexAttribArray textures");
    }

GLES20.glVertexAttribPointer(
  texturePositionHandle, //address of the var in the shader
  2, //how many floats are you transfering: 1,2,3, or 4
  GLES20.GL_FLOAT, //each transfered element type
  false, //not normalized
  0, //stride, or offset
  mFVertexBuffer); //client buffer to transfer from

stride tells you how the vertex data is spaced in the buffer. For example you can say that between two vertex position coordinates there are 10 bytes that don't count. This allows you to pack additional data into the same buffer should that be needed.


uniform mat4 uMVPMatrix;
attribute vec4 aPosition;


//Bind this to the texturePositionHandle
attribute vec2 aTextureCoordinate;

out vec2 v_TextureCoordinate;
void main() 
{
   gl_Position = uMVPMatrix * aPosition;
   v_TextureCoordinate = aTextureCoordinate;
}

to transfer any number of arbitrary vertex related attributes. Some of the vertex attributes are a) color b) position c) normals (in which direction is the surface facing)

Size argument would have been 3 if I were transferring vertex data

glEnableVertexAttribArray(attrib-variable-inthe-shader)

This particular "attribute" variable in the shader program is enabled to use the specified attribute when glDrawArrays or glDrawElements is called.

By default these are disabled.


private void transferVertexPoints(int vertexPositionHandle)
    {
        GLES20.glVertexAttribPointer(
              vertexPositionHandle, //bound address in the vertex shader 
              3, //how may floats for this attribute: x, y, z
              GLES20.GL_FLOAT, //what is type of each attribute? 
              false, // not normalized
                0, //stride
                mFVertexBuffer); //local client pointer to data
        //Check to see if this caused any errors
        checkGlError("glVertexAttribPointer maPosition");
        
        GLES20.glEnableVertexAttribArray(vertexPositionHandle);
        checkGlError("glEnableVertexAttribArray maPositionHandle");
    }

GLES20.glDrawArrays(GLES20.GL_TRIANGLES, //what primitives to use
              0, //at what point to start
              vertexCount); //Starting there how many points to use