Log in or register to post comments

Can I bind multiple textures to the same texture image unit?

April 30, 2012 - 5:22am #1

Suppose I have two textures that I'd like to render based on one trackable in the image.
For example, I have one trackable in the image -> I find it -> draw two different textures with different offset from the trackable.

So, can I do something like that:
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureIDX);
...
glDrawElements(...)
glBindTexture(GL_TEXTURE_2D, textureIDY);
...
glDrawElements(...)

Or should I activate another texture (glActiveTexture(GL_TEXTURE1)) for binding textureIDY?

Thanks

Can I bind multiple textures to the same texture image unit?

July 24, 2013 - 2:05am #5

I am having the same problem. Have you solved it?

Can I bind multiple textures to the same texture image unit?

July 2, 2012 - 1:59am #4

how to modify in ImageTarget.java?

Re: Can I bind multiple textures to the same texture image unit?

May 28, 2012 - 3:06am #3

my application is getting crashed as soon as it tracks the targett
here is my code.please anyone help me

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitcVerts[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitcNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitcTexCoords[0]);

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitfVerts[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitfNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &quitfTexCoords[0]);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textures[0]->mTextureID);
glBindTexture(GL_TEXTURE_2D, textures[1]->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
glDrawArrays(GL_TRIANGLES, 0, quitcNumVerts);
glDrawArrays(GL_TRIANGLES, 0, quitfNumVerts);

Re: Can I bind multiple textures to the same texture image unit?

April 30, 2012 - 6:41pm #2

You can use the same texture unit for both (e.g. GL_TEXTURE0). Just call glBindTexture with the correct textureID before calling glDrawElements.

- Kim

Log in or register to post comments