Search code examples
openglglslopengl-3

OpenGL uniform samplerBuffer: what does it point to?


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?


Solution

  • 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.