Trying to get texture buffer objects working. I'm planning on updating a buffer every frame with instance matrices, for now I have stored a single color. I stripped my code to a simple example. Right now the color I am getting is black. I'm wondering if there is something dumb I need to know about TBO's. I have 0 glGetError() issues. The buffer should definitely contain data, so I wonder if there isn't something with binding the texture properly.
***I missed in my example, but I am calling glUniform1i("instanceMatrixBuffer", 11); To properly bind texture 11 to the sampler in the shader.
glGenVertexArrays(1, &VAO_Handle);
glBindVertexArray(VAO_Handle);
glBindBuffer(GL_ARRAY_BUFFER, VBO_Handle);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)this->m_vboLayout.positionDataOffset);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBO_Index_Handle);
glBindVertexArray(0);
...later
glBindVertexArray(VAO_Handle);
static bool doOnce = true;
if(doOnce)
{
doOnce = false;
glGenBuffers(1, &TBO_Buffer_Handle);
glBindBuffer(GL_TEXTURE_BUFFER, VBO_Index);
float data[4] = {1.0, 0.0, 1.0, 1.0};
glBufferData(GL_TEXTURE_BUFFER, sizeof(float)*4, data, GL_STATIC_DRAW);
glGenTextures(1, &TBO_Texture_Handle);
glBindTexture(GL_TEXTURE_BUFFER, Texture_Index );
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, VBO_Index);
}
glActiveTexture(GL_TEXTURE11);
glBindBuffer(GL_TEXTURE_BUFFER, VBO_Index);
glBindTexture(GL_TEXTURE_BUFFER, Texture_Index);
glDrawElementsInstanced(GL_TRIANGLES, meshToRender->num_faces*3, GL_UNSIGNED_INT, 0, instanceCount)
GLSL
vec4 Color = texelFetch(instanceMatrixBuffer, 0);