I’m having trouble setting up a GL_TEXTURE_BUFFER
I have written a simple program to draw a cube at the origin and then have it’s position offset by data stored in a 1D texture.
I initially tried this:
float position[4]={1.0f, 1.0f, 0, 0};
glActiveTexture(GL_TEXTURE0);
//Create a TBO For position
glGenBuffers(1, &m_tbo);
glBindBuffer(GL_TEXTURE_BUFFER, m_tbo);
glBufferData(GL_TEXTURE_BUFFER, sizeof(float)*4, position, GL_STATIC_DRAW);
glGenTextures(1, &m_texID);
glBindTexture(GL_TEXTURE_BUFFER, m_texID);
glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, m_tbo);
in my initialization code, and it doesn’t work,
but if replace it with this:
float position[4]={1.0f, 1.0f, 0, 0};
glActiveTexture(GL_TEXTURE0);
//create TextureID
glGenTextures(1, &m_texID);
glBindTexture(GL_TEXTURE_1D,m_texID);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 1, 0, GL_RGBA, GL_FLOAT, position);
the exact same code works fine.
I am using a simple vertex shader with texelFetch to get the position data from the sampler. This is all running on OpenGL 3.3 and a gtx460 (258.96 drivers). I am not using any other textures in the program.
If someone could please point out where i am going wrong it’d be a big help