Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes
Accepted

What is an index buffer and how is it related to vertex buffers?

Could someone ELI5 to me, what is an index buffer and how is it related to vertex buffers Your vertex buffer contains the X and Y coordinates of 5 vertices. They are: ...
Rotem's user avatar
  • 443
15 votes
Accepted

GL_STATIC_DRAW vs GL_DYNAMIC_DRAW vs GL_STREAM_DRAW: does it matter?

This will vary between implementations, but the driver I worked on did use these, mainly to decide memory layout. The optimizations enabled by these hints are much smaller than you would like, mainly ...
Dan Hulme's user avatar
  • 6,830
8 votes

GL_STATIC_DRAW vs GL_DYNAMIC_DRAW vs GL_STREAM_DRAW: does it matter?

Functionally they are the same. The driver could use them to differentiate how to handle the buffer behind the scenes. Where for example static_draw would be copied to vram as soon as possible and ...
ratchet freak's user avatar
8 votes
Accepted

What is an OpenGL VAO in a nutshell?

tl;dr The vao caches the calls to glVertexAttribPointer et. al. Every call to glVertexAttribPointer, ...
ratchet freak's user avatar
7 votes
Accepted

Label Placing for thousands of objects with OpenGL

Since you are new to computer graphics, you may be better off avoiding the complications of SIMD and sticking with the traditional 'create a CPU thread + collect results' approach, or even run in the ...
holocronweaver's user avatar
6 votes

Is it possible to create minimal glTF files with vertex and index buffers?

While creating a set of glTF models for a tutorial, I also intended to create THE minimal glTF file. Update: The following referred to glTF 1.0/1.1. See below for an update of this example to glTF 2....
Marco13's user avatar
  • 218
6 votes

What is an index buffer and how is it related to vertex buffers?

If you have a vertex buffer like this: var vertices = [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.6, 0.0, 1.0, 0.6, 0.0, 0.5, 1.0, 0.0 ] And simply draw it ...
q9f's user avatar
  • 703
5 votes

OpenGL VertexArray Data "Retention"?

Deleting an OpenGL object is merely a suggestion. Deleting an object will unbind the object from any binding point it is currently bound to. However, buffer objects are not "bound" to VAOs. They are ...
Nicol Bolas's user avatar
  • 9,832
5 votes
Accepted

Multiple VAO share a VBO

VAO can share VBO's because they do not store vertex data itself but references to Vertex Buffer Objects. So you can first generate your buffers and upload your buffer data (vertex data and index ...
mdkdy's user avatar
  • 2,169
5 votes

How glVertexAttribPointer works?

A VAO holds the attribute information. This means that for each attribute it has a buffer, offset, size, type, stride and whether it's normalized. Separately from those is the element buffer binding ...
ratchet freak's user avatar
5 votes
Accepted

Vulkan: efficient way to update VBO mesh vertices?

With OpenGL I would have to reload whole vertex VBO's. No you wouldn't. You can use glBufferSubData I suppose with Vulkan there could be a way to directly ...
Jherico's user avatar
  • 521
5 votes
Accepted

Are vertices of each LOD version always loaded into VRAM

Many game engines have texture streaming, which means that not all mip levels of each texture are loaded at all times. The game engine will track which textures are in view and how close up they are ...
Nathan Reed's user avatar
4 votes

Is it possible to create minimal glTF files with vertex and index buffers?

You can put the data into a data uri to store the data inline in base64 format. ...
ratchet freak's user avatar
4 votes
Accepted

How glVertexAttribPointer works?

How I call glVertexAttribPointer for the GL_ELEMENT_ARRAY_BUFFER buffer? You don't. The element array buffer is used to store vertex indices, not vertex attribute data and therefore it doesn't have ...
Nathan Reed's user avatar
4 votes

Is it possible to store the plain buffer data in gltf files?

Embedding human readable data is not supported. However you can put the data into a data uri to store the data inline in base64 format. ...
ratchet freak's user avatar
4 votes
Accepted

Replacing Vertex Attributes (glBufferData vs glBufferSubData)

There is a difference between "can" and "should". You "should" not use glBufferData to change the size of an existing non-immutable buffer. You can still do so, ...
Nicol Bolas's user avatar
  • 9,832
4 votes

What is an OpenGL VAO in a nutshell?

VAOs are essentially 'plumbing' objects that help get data from your buffers into your vertex shader ready for drawing. On the GPU this is handled by the vertex fetch stage, so a VAO is basically just ...
russ's user avatar
  • 2,392
3 votes
Accepted

Multiple buffers and calling glBufferSubData

It depends. There are a few competing factors at work here. First, consolidating terrain data into fewer buffers (or one) may allow you to combine multiple terrain patches together in a single draw ...
Nathan Reed's user avatar
3 votes
Accepted

Attribute Location in Multiple Shader Programs

Each VAO, and shader for that matter, has a separate space of attribute locations. It's perfectly fine to have multiple shaders use the same attribute locations. Indeed, it's a good idea to do so if ...
Nicol Bolas's user avatar
  • 9,832
3 votes

Can one VAO store multiple calls to glVertexAttribPointer?

In version 4.3+ the vao layout can be set independently from the VBO buffer which allows you to rebind the vbo without having to call vertexAttribPointer every time: ...
ratchet freak's user avatar
3 votes
Accepted

Is it possible to create minimal glTF files with vertex and index buffers?

After spending a hard time to understand the way how the binary buffers work in the gltf files I finally managed to generate a truely minimal gltf file. It's a single yellow triangle (demo). I tried ...
q9f's user avatar
  • 703
3 votes
Accepted

Different Vertex structures in multi-purpose system

Most rendering engines do need to handle multiple vertex structures depending on the type of shading being used on the mesh. If there are only a small number of discrete vertex structures, you could ...
Nathan Reed's user avatar
2 votes

How to encode/decode buffer data in glTF?

In addition to @russ' answer, I was able to decode the buffer with the gltf Utilities. ...
q9f's user avatar
  • 703
2 votes
Accepted

How to encode/decode buffer data in glTF?

The information you're looking for is defined in the 'accessors' and 'bufferViews' near the top of the source file you linked. Bufferviews simply divide the buffer up into sub ranges and define ...
russ's user avatar
  • 2,392
2 votes
Accepted

Is it possible to store the plain buffer data in gltf files?

It's not possible to store the plain text array buffers in gltf, however, here is the code I use to generate buffers in JavaScript: ...
q9f's user avatar
  • 703
2 votes
Accepted

Can one VAO store multiple calls to glVertexAttribPointer?

Yes, VAO state includes vertex attribute specification for multiple attributes. Each attribute has its own format information and can come from a distinct buffer object. That's part of why you can ...
Nicol Bolas's user avatar
  • 9,832
2 votes
Accepted

Sharing calculation result between shader programs in OpenGL

Yes you can, this is how deferred rendering for example would work. For that you would render to a texture in one pass, in openGL this would be via an FBO, then feed that texture as the input to the ...
PaulHK's user avatar
  • 2,322
2 votes

Same draw call causing extremely different GPU usage under different triangle orders

I think you're seeing cache effects. The GPU will begin vertex processing for each strip in sequential order, and in configuration 1 the GPU will fetch a different chunk of memory for each triangle in ...
John Calsbeek's user avatar
2 votes
Accepted

Passing Colour from program to vertex shader

I don't know what language that is, but I'm going to hazard a guess that the arrays points and gl.Ptr([]float32{0.5,0.5,0.0}) ...
Nicol Bolas's user avatar
  • 9,832
2 votes
Accepted

Role of gl.vertexAttrib

gl.vertexAttribPointer is used when different vertices should have different values, and gl.vertexAttrib is used when all vertices should have the same values, and you don't want to use a special ...
Daniel Kareh's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible