Look for GLP(BindTexture) in glGraphicsStateGuardian_src.cxx. (We use a macro to wrap most OpenGL calls, to allow explicit support for Mesa as a separate compilation.) Note, though, that this is just the OpenGL pathway; the DirectX GSG’s have their own, different mechanism.
I don’t think it makes sense to return a vector of indices to the user–texture indices are used only in OpenGL, not in DirectX; and it doesn’t make sense to expose this detail to the user. The user should deal only with Texture objects. (Unless you’re referring to indices into the texture array itself?)
I imagine the user would load a TextureCollection with the array of textures he intends to load, and set this on the ShaderAttrib. Then the GSG would convert this internally into an array of texture indices, which is delivered to the shader for processing.
I am referring to the fact that the user should know the position of the texture in the array if he want to access it in the shader. Makes no sense if the user itself load the textures, as the order could just be the same.
Then the GSG would convert this internally into an array of texture indices
I guess you mean doing something like this in glGraphicsStateGuardian::upload_texture_image(…) right?
Hum. I’ve just done some reading up on how texture arrays are actually implemented by the OpenGL and DirectX API’s. I had been fuzzy on the concept before, and I was thinking that an OpenGL texture array was just an array of existing and previously-loaded 2-d texture objects; I hadn’t realized a texture array is actually a unique copy of texture data, which all must have the same height and width, and which are uploaded to graphics memory using the existing glTexImage3d() call.
In that model, a texture array is very similar to a 3-d texture, whose layers can be individually addressed by the shader. Well, why don’t we follow a similar model, then?
We can just add TT_2d_texture_array to Texture::TextureType, and use the existing Texture interfaces to load these pages from disk or wherever. So there’s no need to use TextureCollection; the user creates a TextureArray by creating a single Texture object and filling it up with the desired contents. And this greatly simplifies the work needed by the GSG; it simply uploads the texture_array texture in a method very similar to the way it currently uploads a 3-d texture.
The binding of the texture is performed by glShaderContext::update_shader_texture_bindings(). But the loading of the texture data still funnels through glGraphicsStateGuardian::update_texture_image(), in both the shader and the FF cases.
I don’t have a big knowledge of how panda3D handles textures at the moment, but I was planning to follow the 3D-texture path. You guys, in an older post convinced me it was necessary to use a TextureCollection. I didn’t understand really well the reason at the moment, but I tend to trust more you than me…