Send a texture buffer to a shader

Hello everyone.

I'm trying to send a texture buffer to my fragment shader. This texture buffer contains the coordinates of control points to make a Bézier interpolation in my shader.
These coordinates are float included in [0;1]

The buffer is correctly filled with the data because if I do a glGetBufferSubData just before my glUniform1i, I get the correct coordinates of my control points.

Right now, my shader just picks up 3 values of that buffer and put it in the gl_FragColor to see if it's empty in the shader.

My problem is that it is empty and I have a black screen. I hardly see if it comes from the sending of the data in my C++ program of if it comes from the reading of the data in my shader...

That's not how you set up a buffer texture. glTexBuffer takes the buffer object, not the texture object. It associates the given buffer object with whatever texture is bound to GL_TEXTURE_BUFFER.

Also, your fragment shader logic is... nonsensical. Your buffer texture uses GL_RGBA32F format. Which means every read will read four values. A texture coordinate of 3 refers to the 13th float in the array you uploaded to the buffer object. And yet, your `readBuffer` function discards the GBA part of the image, returning only one value. And then you do 3 sequential reads.

If you wanted to fetch 4 values from the texture, you should actually keep the RGBA components, rather than only keeping R the way you do.

So I searched in forums and found the first method. It was working for the guy using it and the fact is that as I said, my texture buffer was correctly filled with coordinates with this method...

I'm surely making a mistake with the proper method but can't find where.

II ) FORMAT

Yep sorry, I tried several things to check why my buffer was filled with 0 and changing format was one of them. I forgot to set it back to GL_R32F.
As the data I want to send is a 1 dimension array of floats, my readBuffer function is ok with GL_R32F, right ?

No. You're adding a texture object name to GL_TEXTURE0. That never makes sense.

Please stop copy-and-paste coding; it's not helping anyone. Try to understand what these functions actually do. If something isn't working, you shouldn't just fiddle around with it until it does. You need to understand why it doesn't work, and then understand why your change makes it work.