Binding texture coordinates

I am new to textures (not new to OF in general)
I have another thread on this forum that has my code of me trying to sample from a list of textures. What I found confusing (among other failures) is understanding which texCoords get bound and how to get their identity/index that oF passes under the hood in the form of tex.bind(location=x);

For example if I have a code like this

// ofImage imageA & imageB loaded from file

shader.setUniformTexture("imageBTex", imgB.getTexture(),1);

then in the fragment shader I understand that

uniform sampler2D imageBTex; // belongs to imageB
uniform sampler2D tex0; // belongs to imageA becuase of draw binding the texture under the hood
in vec2 texCoord;

but from what image is texCoord bound? is there a way to explicitly pass it?

in my other example I have it like this

//self bound GL_TEXTURE_2D_ARRAY that gets sent as texArray
shader.uniform1f("texArray", 0);

now for the fragment shader

uniform sampler2DArray texArray;
in vec2 texCoord;

I would want the texCoords from the image.draw() and sampler2DArray from the self bound GL_TEXTURE_2D_ARRAY

how would I make sure that happens?

Hey so ofBook describes some of the variables that can be accessed in the vertex shader (and the fragment shader too?) by default from oF. There is some code in the “Adding Textures” section of the Introdcing Shaders chapter that has most (all?) of them. One of them is in vec2 texcoord. Its pretty common to see shader code that passes texcoord from the vertex shader to the fragment shader as a different variable, like vTexCoord, texCoordVarrying, texCoord, etc.

An easy and explicit way to pass the texture coordinates of some object as texcoord is to call .draw() on it. If .draw() is called on 2 things with texture coordinates in a shader, I’m not sure which one prevails, but I’d bet on the last of the .draw() calls.

If all of the textures in a sampler2DArray are the same, then calling .draw() on a proxy should be fine. And it may be easier to resize/crop the textures to a standard, rather than deal with variable sizes of them in the sampler2DArray in the shader.

An ofPlanePrimitive, which inherits from of3dPrimititive, also has texture coordinates in its ofMesh. In particular, there are 2 particularly convenient ways to set texture coordinates: of3dPrimitieves::mapTexCoords() and ::mapTexCoordsFromTexture(). There may be a way to use a plane to provide texture coordinates for the sampler2DArray.

Then there is probably an openGL way to do this, outside of oF, where the color data of the textures is passed along with other attributes (vertex, texture coords). The Textures chapter of learnopengl discusses this some detail.