# Set vertex attributes

## glVertexAttribPointer() Function Signature

<table data-header-hidden><thead><tr><th width="337.3333740234375"></th><th></th></tr></thead><tbody><tr><td><code>void </code><strong><code>glVertexAttribPointer</code></strong><code>(</code></td><td>GLuint index,</td></tr><tr><td> </td><td>GLint size,</td></tr><tr><td> </td><td>GLenum type,</td></tr><tr><td> </td><td>GLboolean normalized,</td></tr><tr><td> </td><td>GLsizei stride, // vertex stride</td></tr><tr><td> </td><td>const void * pointer<code>)</code>; // attribute start pointer</td></tr></tbody></table>

## Modify vertex position attribute

now we have 6 floats for each vertex

```cpp
  glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, 0);
```

## Add colour attribute

```cpp
    // set colour attributes
    glEnableVertexAttribArray(1);
    glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 6, (void *) (sizeof(float) * 3));
```

We are still getting this

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FyRxfVs2NE2EzZ1zPmnkJ%2Fimage.png?alt=media&#x26;token=b57177b4-a69e-45d5-bae5-71bf64b7d909" alt=""><figcaption></figcaption></figure>

To render vertex colour we need to write shaders
