I am trying to figure out what determines the buffer object that a uniform samplerBuffer
points to.
Let us say we have uniform samplerBuffer aBuffer
and its value is 0; what does aBuffer
point to?
If I understand your question correctly, you are asking how aBuffer
knows which buffer object to fetch texel memory from?
aBuffer
is a sampler (more precisely, a buffer sampler), and it has the value 0 in this example, so it refers to the buffer texture (GL_TEXTURE_BUFFER
) that is currently bound to GL_TEXTURE0
.
The association between the buffer texture bound to GL_TEXTURE_BUFFER
and the backing storage comes from the last parameter in the call to glTexBuffer (...)
. That last parameter is the name of a buffer object.
GL_TEXTURE0
? – Matt MunsonsamplerBuffer
is no different from any other kind of sampler. Really the only unique thing here is the fact that you allocated the thing bound toGL_TEXTURE0
in this example withglTexBuffer (...)
rather than sayglTexImage2D (...)
(in the case of asampler2D
). Well, that and of course, the fact that you have to usetexelFetch (...)
. – Andon M. ColemanglTexImage2d()
? – Matt MunsonglTexImage2D (...)
is forGL_TEXTURE_2D
/sampler2D
.glTexBuffer (...)
is forGL_TEXTURE_BUFFER
/samplerBuffer
. – Andon M. Coleman