How to use multiple texture buffers?

How can I use multiple texture buffers? I want to use two texture buffers but after generating the 2nd buffer the mesh doesnt get drawn. Did I miss something here?

glUniform1i(glGetUniformLocation(programId, "charTexture"), 0);
glUniform1i(glGetUniformLocation(programId, "AnimationData"), 1);
glUniform1i(glGetUniformLocation(programId, "InstanceData"), 2);

glGenBuffers(1, &animationTBO);
glBindBuffer(GL_TEXTURE_BUFFER, animationTBO);
glBufferData(GL_TEXTURE_BUFFER, animationsize, animationdata), GL_STATIC_DRAW);

glGenTextures(1, &animationTex);
glBindTexture(GL_TEXTURE_BUFFER, animationTex);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, animationTBO);

//after adding below, the mesh doesnt get drawn
/*
  glGenBuffers(1, &instanceTBO);
  glBindBuffer(GL_TEXTURE_BUFFER, instanceTBO);
  glBufferData(GL_TEXTURE_BUFFER, sizeof(InstanceData)*2, instancedata, GL_DYNAMIC_DRAW);
  glGenTextures(1, &instanceTex);
  glBindTexture(GL_TEXTURE_BUFFER, instanceTex);
  glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, instanceTBO);
*/

render code


  glActiveTexture(GL_TEXTURE1);
  glBindBuffer(GL_TEXTURE_BUFFER, animationTex);
  glBindTexture(GL_TEXTURE_BUFFER, animationTex);
/* //i should uncomment this if everything works well
  glActiveTexture(GL_TEXTURE2);
  glBindBuffer(GL_TEXTURE_BUFFER, instanceTBO);
  glBufferSubData(GL_TEXTURE_BUFFER, 0, sizeof(InstanceData)*instanceCount, instancedata);
  glBindTexture(GL_TEXTURE_BUFFER, instanceTex);
*/

  glUseProgram(programId);
  glBindVertexArray(characterVA);
  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, characterTexture);
  glDrawElements(GL_TRIANGLES, indexcount, GL_UNSIGNED_SHORT, 0);
  glBindVertexArray(0);
  glUseProgram(0);

glBindTexture(GL_TEXTURE_BUFFER, animationTex);

I’m pretty sure this is unnecessary. Once you use TexBuffer, you have made an association between the texture object and the BufferObject.

I think you mean glBindBuffer is not needed. You don’t need this actually:

glBindBuffer(GL_TEXTURE_BUFFER, animationTex);

As Alfonse said, TexBuffer already establishes the connection between the buffer texture and the buffer object itself.

I think the problem maybe is related to the shader you use or the connection between the textures and uniforms.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.