Difference between “buffer†and “array†in OpenGL?
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
When I read doc on webGL or OpenGL there can be seen some patterns in how names of functions and objects are used. But I can't understand the difference between buffer object and an array.
There are "vertex buffer objects", "vertex array objects" and even some kind of "buffer array" or "arraybuffer".
In OpenGL context, When something is "array" and when it should be called a "buffer" instead?
opengl webgl
add a comment |Â
up vote
3
down vote
favorite
When I read doc on webGL or OpenGL there can be seen some patterns in how names of functions and objects are used. But I can't understand the difference between buffer object and an array.
There are "vertex buffer objects", "vertex array objects" and even some kind of "buffer array" or "arraybuffer".
In OpenGL context, When something is "array" and when it should be called a "buffer" instead?
opengl webgl
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
When I read doc on webGL or OpenGL there can be seen some patterns in how names of functions and objects are used. But I can't understand the difference between buffer object and an array.
There are "vertex buffer objects", "vertex array objects" and even some kind of "buffer array" or "arraybuffer".
In OpenGL context, When something is "array" and when it should be called a "buffer" instead?
opengl webgl
When I read doc on webGL or OpenGL there can be seen some patterns in how names of functions and objects are used. But I can't understand the difference between buffer object and an array.
There are "vertex buffer objects", "vertex array objects" and even some kind of "buffer array" or "arraybuffer".
In OpenGL context, When something is "array" and when it should be called a "buffer" instead?
opengl webgl
opengl webgl
asked 2 hours ago


coobit
1374
1374
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
A Vertex Array Object (VAO) is an object which contains one or more
Vertex Buffer Objects and is designed to store the information for a
complete rendered object.
(pulled from khronos)
Each buffer tends to constitute one attribute of a vertex array (object). A VAO can contain many vertex attributes (e.g. position, color, UV). Each might be held in its own buffer, where buffer indicates an unformatted series of contiguous bytes, and where you need to explicitly specify the size (type) per buffer element for both CPU side OpenGL calls and GPU-side shader work.
That's one way. The other ways this can work are:
- All of the attributes are stored interleaved in a single buffer, OR
- Some of the attributes exist in their own dedicated buffers, while others share buffers.
The below diagram describes these latter two cases.
Bottom line: If the phrase "vertex array" is used unqualified in OpenGL, you can assume it means VAO, which is a very different thing indeed from a buffer.
EDIT re your comment: GL_ARRAY_BUFFER
indicates an intention to use that buffer object for vertex attribute data, as described above. This is because buffers are not used only for vertex attributes. However, as it is the most common use-case and you are asking about VAOs, I won't go into the others; here however is a list of the other types of buffers that can be set up.
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or astruct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
add a comment |Â
up vote
0
down vote
I havent worked with OpenGL in a while, so I might only be half-right. Generally speaking: Buffers store an array of unformatted memory. An array is a general term of contiguous memory.
A buffer needs to be bound to the context, whereas an array is just an array of data. If i recall correctly, the data in the buffer is meant to be copied onto the graphics card (hence the binding).
Hope this helps a bit
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
A Vertex Array Object (VAO) is an object which contains one or more
Vertex Buffer Objects and is designed to store the information for a
complete rendered object.
(pulled from khronos)
Each buffer tends to constitute one attribute of a vertex array (object). A VAO can contain many vertex attributes (e.g. position, color, UV). Each might be held in its own buffer, where buffer indicates an unformatted series of contiguous bytes, and where you need to explicitly specify the size (type) per buffer element for both CPU side OpenGL calls and GPU-side shader work.
That's one way. The other ways this can work are:
- All of the attributes are stored interleaved in a single buffer, OR
- Some of the attributes exist in their own dedicated buffers, while others share buffers.
The below diagram describes these latter two cases.
Bottom line: If the phrase "vertex array" is used unqualified in OpenGL, you can assume it means VAO, which is a very different thing indeed from a buffer.
EDIT re your comment: GL_ARRAY_BUFFER
indicates an intention to use that buffer object for vertex attribute data, as described above. This is because buffers are not used only for vertex attributes. However, as it is the most common use-case and you are asking about VAOs, I won't go into the others; here however is a list of the other types of buffers that can be set up.
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or astruct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
add a comment |Â
up vote
2
down vote
A Vertex Array Object (VAO) is an object which contains one or more
Vertex Buffer Objects and is designed to store the information for a
complete rendered object.
(pulled from khronos)
Each buffer tends to constitute one attribute of a vertex array (object). A VAO can contain many vertex attributes (e.g. position, color, UV). Each might be held in its own buffer, where buffer indicates an unformatted series of contiguous bytes, and where you need to explicitly specify the size (type) per buffer element for both CPU side OpenGL calls and GPU-side shader work.
That's one way. The other ways this can work are:
- All of the attributes are stored interleaved in a single buffer, OR
- Some of the attributes exist in their own dedicated buffers, while others share buffers.
The below diagram describes these latter two cases.
Bottom line: If the phrase "vertex array" is used unqualified in OpenGL, you can assume it means VAO, which is a very different thing indeed from a buffer.
EDIT re your comment: GL_ARRAY_BUFFER
indicates an intention to use that buffer object for vertex attribute data, as described above. This is because buffers are not used only for vertex attributes. However, as it is the most common use-case and you are asking about VAOs, I won't go into the others; here however is a list of the other types of buffers that can be set up.
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or astruct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
A Vertex Array Object (VAO) is an object which contains one or more
Vertex Buffer Objects and is designed to store the information for a
complete rendered object.
(pulled from khronos)
Each buffer tends to constitute one attribute of a vertex array (object). A VAO can contain many vertex attributes (e.g. position, color, UV). Each might be held in its own buffer, where buffer indicates an unformatted series of contiguous bytes, and where you need to explicitly specify the size (type) per buffer element for both CPU side OpenGL calls and GPU-side shader work.
That's one way. The other ways this can work are:
- All of the attributes are stored interleaved in a single buffer, OR
- Some of the attributes exist in their own dedicated buffers, while others share buffers.
The below diagram describes these latter two cases.
Bottom line: If the phrase "vertex array" is used unqualified in OpenGL, you can assume it means VAO, which is a very different thing indeed from a buffer.
EDIT re your comment: GL_ARRAY_BUFFER
indicates an intention to use that buffer object for vertex attribute data, as described above. This is because buffers are not used only for vertex attributes. However, as it is the most common use-case and you are asking about VAOs, I won't go into the others; here however is a list of the other types of buffers that can be set up.
A Vertex Array Object (VAO) is an object which contains one or more
Vertex Buffer Objects and is designed to store the information for a
complete rendered object.
(pulled from khronos)
Each buffer tends to constitute one attribute of a vertex array (object). A VAO can contain many vertex attributes (e.g. position, color, UV). Each might be held in its own buffer, where buffer indicates an unformatted series of contiguous bytes, and where you need to explicitly specify the size (type) per buffer element for both CPU side OpenGL calls and GPU-side shader work.
That's one way. The other ways this can work are:
- All of the attributes are stored interleaved in a single buffer, OR
- Some of the attributes exist in their own dedicated buffers, while others share buffers.
The below diagram describes these latter two cases.
Bottom line: If the phrase "vertex array" is used unqualified in OpenGL, you can assume it means VAO, which is a very different thing indeed from a buffer.
EDIT re your comment: GL_ARRAY_BUFFER
indicates an intention to use that buffer object for vertex attribute data, as described above. This is because buffers are not used only for vertex attributes. However, as it is the most common use-case and you are asking about VAOs, I won't go into the others; here however is a list of the other types of buffers that can be set up.
edited 13 mins ago
answered 1 hour ago


Arcane Engineer
25.3k355111
25.3k355111
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or astruct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
add a comment |Â
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or astruct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
So buffers are: 1.reside in GPU, 2.most of the time contain one kind of data (only vertex, only color ect), 3.Data is interleaved, that is 111122223333 ect. 4. provide no method to access data (not buffer[2] or buffer[vertex_3434]) Now, arrays are: 1.collection of buffers, 2.store information on how to parse buffers which it contains.(that is array store stride, size of an element, offsets, so data from buffers can be accessed correctly. right?
– coobit
12 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or a
struct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)– Arcane Engineer
2 mins ago
1. Buffers exist on both ends and transfer between CPU and GPU (back AND forth potentially), else how would you populate the data to be uploaded to GPU when loading a mesh from disk?. Yes, elements are of uniform type throughout the buffer, but depending on the tech you are using, each buffer element can be either a primitive or a
struct
type. Data may be interleaved or be completely uniform, per buffer. You can index into them, just as with a traditional C array on the CPU. Array objects (use this correct terminology or end up confusing yourself!)– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
2. Lastly, yes, and you need to explicitly make sure your in-shader buffer declarations will match those specifications you set on your VAO on the CPU side: "All state related to the definition of data used by the vertex processor is encapsulated in a vertex array object." (khronos docs)
– Arcane Engineer
2 mins ago
add a comment |Â
up vote
0
down vote
I havent worked with OpenGL in a while, so I might only be half-right. Generally speaking: Buffers store an array of unformatted memory. An array is a general term of contiguous memory.
A buffer needs to be bound to the context, whereas an array is just an array of data. If i recall correctly, the data in the buffer is meant to be copied onto the graphics card (hence the binding).
Hope this helps a bit
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
add a comment |Â
up vote
0
down vote
I havent worked with OpenGL in a while, so I might only be half-right. Generally speaking: Buffers store an array of unformatted memory. An array is a general term of contiguous memory.
A buffer needs to be bound to the context, whereas an array is just an array of data. If i recall correctly, the data in the buffer is meant to be copied onto the graphics card (hence the binding).
Hope this helps a bit
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
add a comment |Â
up vote
0
down vote
up vote
0
down vote
I havent worked with OpenGL in a while, so I might only be half-right. Generally speaking: Buffers store an array of unformatted memory. An array is a general term of contiguous memory.
A buffer needs to be bound to the context, whereas an array is just an array of data. If i recall correctly, the data in the buffer is meant to be copied onto the graphics card (hence the binding).
Hope this helps a bit
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I havent worked with OpenGL in a while, so I might only be half-right. Generally speaking: Buffers store an array of unformatted memory. An array is a general term of contiguous memory.
A buffer needs to be bound to the context, whereas an array is just an array of data. If i recall correctly, the data in the buffer is meant to be copied onto the graphics card (hence the binding).
Hope this helps a bit
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
answered 1 hour ago
Juicef
91
91
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Juicef is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
add a comment |Â
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
What is GL_ARRAY_BUFFER then? Why it was called so? According to you hypothesis it is "Unformatted contiguous memory" :)
– coobit
1 hour ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgamedev.stackexchange.com%2fquestions%2f164992%2fdifference-between-buffer-and-array-in-opengl%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password