160k views
0 votes
Assume that the render function will make the call gIDrawArrays( GL_TRIANGLES, 0, NumVertices ). In this example, (if all we draw is the square) what will NumVertices be?

User Mia Clarke
by
7.4k points

2 Answers

1 vote

Final answer:

When drawing a square with GL_TRIANGLES, NumVertices would be 6, as a square requires two triangles, each with 3 vertices.

Step-by-step explanation:

If you are drawing a square using GL_TRIANGLES, and the function call is gIDrawArrays(GL_TRIANGLES, 0, NumVertices), then NumVertices would typically be 6. A square is composed of two triangles, and each triangle requires 3 vertices to be drawn. Therefore, for a complete square, you would need 2 triangles x 3 vertices each = 6 vertices in total. It's important to note that this assumes you are not using an indexing method, which could reduce the number of vertices by reusing them for drawing multiple triangles.

User Eric Zinda
by
8.4k points
3 votes

Final answer:

The NumVertices parameter in the gIDrawArrays function specifies the number of vertices to be drawn.

Step-by-step explanation:

The OpenGL function

gIDrawArrays( GL_TRIANGLES, 0, NumVertices )

is used to draw geometric shapes in computer graphics. The second parameter, 0, specifies the starting index of the vertex array, and the third parameter, NumVertices, specifies the number of vertices to be drawn.

In this example, if only a square is drawn, the NumVertices will be the number of vertices in the square, which is usually 4 (assuming each corner of the square is defined).

When rendering a square with GL_TRIANGLES, we need 6 vertices as a square is composed of 2 triangles, each needing 3 vertices.

If we are drawing a square using glDrawArrays with the mode set to GL_TRIANGLES, then we need to consider how many vertices are required to create a square using triangles. A square can be divided into two triangles, and each triangle requires 3 vertices, making a total requirement of 6 vertices to draw a square. Therefore, NumVertices would be 6 in this case.

User MooHa
by
8.7k points