6
$\begingroup$

Problem X: I need to provide "compensation" streams for attributes that are not plugged by the mesh data, but the shader requires them. (In d3d not matching the input layout is a hard error)

Solution Y: In D3D I've created a 16 bytes buffer initialized with some default color (when the missing semantic is color, let's take this as my typical use case) and specified a stride of zero so that one element is repeated whatever the index in the index buffer, and this way I don't need to clog VRAM with the biggest buffer that's necessary to cover all objects. This works in D3D.

But looking at glVertexAttribPointer I see that the API is eating away my stride and makes it automatic when I specify zero.

Any workaround ?

$\endgroup$

2 Answers 2

5
$\begingroup$

Disable the vertex attrib array and use glVertexAttrib to set the data that should be used.

$\endgroup$
5
$\begingroup$

You can set a stride of zero with OpenGL 4.3's separate attribute format API, or the ARB_vertex_attrib_binding extension:

glBindVertexBuffer(index, buffer, offset, 0);

The stride of zero will be a real stride of zero.

This also has the benefit of looking a lot more familiar to D3D users than the glVertexAttribPointer API.

$\endgroup$
1
  • $\begingroup$ hey that's very interesting. that's probably way easier since our engine is more based on d3d ways. I'll look into that tomorrow $\endgroup$
    – v.oddou
    Apr 5, 2017 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.