On Fri, 23 Mar 2012 20:48:18 +0000, VelociChicken wrote:
> OK, it turns out I should not have used the texture IDs for 'glBindTexture.'
> It's a little bit confusing as to how this function actually works with
> shaders... :(
The value passed to glUniform1i for a uniform variable of sampler type is
the texture unit number, i.e. a value of N refers to the texture unit
which is selected by glActiveTexture(GL_TEXTURE0 + N).
glBindTexture associates a texture name (handle) with a particular
target in the active texture unit. There is an implementation-defined
limit on the number of available texture units, but the number of textures
is limited only by available memory. A shader accesses texture *units*
rather than textures per se, so it can only access textures which are
bound to a texture unit.
More generally: many dynamically-created entity types can only be
manipulated while bound to some "target"; textures, buffers, framebuffers,
renderbuffers and VAOs all fall into this category. OTOH, shaders,
programs and samplers can be queried and/or manipulated by name (handle)
without having to be bound to a target.