Skip to main content
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,880
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
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
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
  • 556
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
  • 25.3k
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,997
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,179
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
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,997
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,402
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
  • 25.3k
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
  • 25.3k
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,997
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
  • 25.3k
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
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,997
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,997
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
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

What does it mean for a buffer to be "tightly packed"?

To take an example from the glTF spec you cited: The stride, in bytes, between vertex attributes. When this is not defined, data is tightly packed. The stride of an array is the number of bytes from ...
Nicol Bolas's user avatar
  • 9,997
2 votes

Which provides better intuition: THREE.Geometry or THREE.BufferGeometry?

Note that BufferGeometry still supports both indexed and non-indexed meshes. It contains arrays of vertex attributes and indices, and works in non-indexed mode if the indices array is null. You can ...
Nathan Reed's user avatar
  • 25.3k
1 vote

Why are the transformations of an object calculated on CPU?

It is perfectly reasonable to do the multiplication on the GPU. The major reason it is taught this way is partly it is historically standard, but the main reason is if you have a vertex shader that ...
pmw1234's user avatar
  • 3,484
1 vote
Accepted

Passing non-interleaved data to glBufferStorage without using glBufferSubData

You can put your data in one piece of memory on the CPU and then copy it in with glBufferStorage. It's just a bunch of memcpy ...
Nicol Bolas's user avatar
  • 9,997
1 vote

How does a Vertex Buffer manage memory?

There are various options, even with OpenGL 3.3 (over a decade old), that will depend on hardware factors, GPU, bus, etc., the driver-specific implementations, and finally, the sort of access patterns ...
Brett Hale's user avatar
1 vote
Accepted

Performance of particle implementation

Updating the position/rotation/scale in the vertex buffer will use less memory bandwidth—that’s 9 values, where a transform matrix would be either 12 or 16—and the GPU can parallelize the work of ...
Noah Witherspoon's user avatar
1 vote
Accepted

Confusion about glVertexAttribPointer and non-active attributes

...have not been able to find much info about the link between programs and dynamic attribute bindings. That is because there really is no link between them. Your vertex array data, i.e. the enabled ...
Christian Rau's user avatar
1 vote

What is an OpenGL VAO in a nutshell?

Buffer objects contain your vertex data. Vertex array objects tell OpenGL how to interpret that data. Without the VAO, OpenGL just knows that you suck some bytes into some buffers. The VAO says that "...
Nicol Bolas's user avatar
  • 9,997
1 vote

How to read vertex color before rendering texture?

For this kind of functionality, you shouldn't try to use the same framebuffer for the vertex colours and for the final image. Don't forget that GL is asynchronous, so alternating CPU reads and GPU ...
Dan Hulme's user avatar
  • 6,880
1 vote
Accepted

LWJGL/OpenGL render textured quad

I figured it out myself, again: just add ...
piegames's user avatar
  • 297

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