> For the complete documentation index, see [llms.txt](https://yaakuro.gitbook.io/opengl-4-5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yaakuro.gitbook.io/opengl-4-5/first-draw-call.md).

# First Draw Call

For a simple draw call we need at least one **VAO** setup correct and one Shader Program. There are multiple functions in OpenGL to draw. One and maybe the easiest of them is **glDrawArrays:**

```
glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.size());
```

| glDrawArrays | Parameters | Type          | Description                                                                                                     |
| ------------ | ---------- | ------------- | --------------------------------------------------------------------------------------------------------------- |
|              | 1          | GLenum mode   | The primitive type we like to render.                                                                           |
|              | 2          | GLint first   | Offset inside the **BO** we like to use. This is not in bytes, it is more in elements within the **BO** itself. |
|              | 3          | GLsizei count | The number of elements to use within the **BO** to draw the primitive. Better explanation see below :D.         |

The **1.** parameter can be one of the folowwing GL enums:

| Mode                           | Description |
| ------------------------------ | ----------- |
| GL\_POINTS                     |             |
| GL\_PATCHES                    |             |
| GL\_LINE\_STRIP                |             |
| GL\_LINE\_LOOP                 |             |
| GL\_LINE\_STRIP\_ADJACENCY     |             |
| GL\_LINES\_ADJACENCY           |             |
| GL\_LINE\_STRIP                |             |
| GL\_TRIANGLE\_STRIP            |             |
| GL\_TRIANGLE\_FAN              |             |
| GL\_TRIANGLES                  |             |
| GL\_TRIANGLE\_STRIP\_ADJACENCY |             |
| GL\_TRIANGLES\_ADJACENCY       |             |

The **2.** is an offset of the number of to draw primitives.&#x20;

The **3.** parameter tells how many elements you want to use to draw the primitive. This parameter can be confusing. For example, if you want to draw 1 triangle you might think that you pass here 1, but what you have to pass here is the number of elements that shapes the triangle. So for one triangle you have to pass at least the value 3 (3 vertex points = 1 Triangle). If you would want to draw 2 triangles you have to pass the value of 6. Easy right :D? This number of course depends which mode you selected, in short which type of primitive you want to draw. If you have points then yes you pass the number of points you want to draw. If you want to draw 2 points, use pass the value 2 here.

## Before any draw calls

Before we can use the any of the draw functions of OpenGL we have to bind a VAO we like to reference and the same for a shader program. Binding a VAO is easy and is done with **glBindVertexArray.** For our example we would use:

```
glBindVertexArray(vao);
```

Next is we need to tell OpenGL which Shader Program to use. We do that with glUseProgram. Using our simple example this would look like this:

```
glUseProgram(shaderProgram);
```

Now we are ready to use one of the draw calls.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yaakuro.gitbook.io/opengl-4-5/first-draw-call.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
