PDA

View Full Version : Vertex Array Object and vertex buffer object



Xxacero
07-22-2015, 03:20 PM
I have a question: I can create a vertex buffer object for each array that I want to render ? or i can' t? or i need to render arrays with a single buffer not just one array.2 or more
arrays

"Sorry my English is bad"

Dark Photon
07-22-2015, 04:27 PM
The terminology is a bit confusing:

* vertex arrays - Storage of vertex attributes in a memory buffer
* Vertex buffer object (VBO) - A GPU (GL driver-side) buffer which stores vertex arrays and/or index lists (typically)
* batch - a draw call; may reference one or multiple vertex arrays and possibly an index list (each of which may be stored in one or more VBOs or in client arrays [app CPU-side memory])
* Vertex Array Object (VAO) - Stores the bindings and enables for vertex attributes (and bindings for the index list)

With that preamble, now to your question (if I understood you properly).

You can have one VAO per batch, or you can have one VAO and reprogram it on-the-fly to work for all batches, or some mix of that.

You can store one or more vertex arrays and/or index lists in a single VBO. For example, you can store all of the vertex attribute arrays for a batched interleaved in a VBO, and then later in the same VBO store the index list (if applicable) -- total number of VBOs for that batch == 1. Or, on the other end of the spectrum, you can store each of the vertex attribute arrays for a batch separately each in their own VBO and store the index list (if applicable) in yet another VBO -- total number of VBOs for that batch == N+1.

GClements
07-23-2015, 02:08 AM
I have a question: I can create a vertex buffer object for each array that I want to render ? or i can' t?
Each vertex attribute has an associated buffer from which the attribute's values are taken. A single buffer can be used for any number of attributes. So the data for different attributes can come from different buffers, or different regions of the same buffer, or the same region of the same buffer with the values for different attributes interleaved.

When the data for an attribute is specified using glVertexAttribPointer(), the buffer which is currently bound to GL_ARRAY_BUFFER is associated with that attribute. The buffer can subsequently be unbound; draw calls take data from the buffers which were bound at the time of the corresponding glVertexAttribPointer() calls, regardless of any binding at the time of the draw call.

Xxacero
07-23-2015, 04:13 AM
Each vertex attribute has an associated buffer from which the attribute's values are taken. A single buffer can be used for any number of attributes. So the data for different attributes can come from different buffers, or different regions of the same buffer, or the same region of the same buffer with the values for different attributes interleaved.

When the data for an attribute is specified using glVertexAttribPointer(), the buffer which is currently bound to GL_ARRAY_BUFFER is associated with that attribute. The buffer can subsequently be unbound; draw calls take data from the buffers which were bound at the time of the corresponding glVertexAttribPointer() calls, regardless of any binding at the time of the draw call.

haaa okk okkk noow i know thx