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...
Your help is welcomed !
Here's the code :
Buffer filling (the glGen functions are made somewhere else)
Code :glEnable(GL_TEXTURE_BUFFER); m_Data = new float[m_BaseGrid.size()*2]; for(int i=0; i<m_BaseGrid.size() ; i++){ m_Data[2*i]=m_BaseGrid[i].x; m_Data[2*i+1]=m_BaseGrid[i].y; } glActiveTexture(GL_TEXTURE0+m_texId); glBindTexture(GL_TEXTURE_BUFFER, m_texId); glBindBuffer(GL_TEXTURE_BUFFER, m_texId); glBufferData(GL_TEXTURE_BUFFER, m_BaseGrid.size()*2*sizeof(float), m_Data, GL_STATIC_DRAW); glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, m_texId); glBindTexture(GL_TEXTURE_BUFFER, m_texId); glDisable(GL_TEXTURE_BUFFER);
In my Display function
Code :glActiveTexture(GL_TEXTURE0+renderer.m_texId); glBindTexture(GL_TEXTURE_2D, renderer.m_texId); GLint texLoc = glGetUniformLocation(program, "texture"); glUniform1i(texLoc, renderer.m_texId); glActiveTexture(GL_TEXTURE0+warping->m_texId); glBindTexture(GL_TEXTURE_BUFFER, warping->m_texId); GLint datLoc = glGetUniformLocation(program, "data"); glUniform1i(datLoc, warping->m_texId); GLint nbPointsLoc = glGetUniformLocation(program, "nbPoints"); glUniform1i(nbPointsLoc, warping->m_NbPtsH*warping->m_NbPtsV);
My fragment shader
Code :#extension GL_EXT_gpu_shader4 : enable uniform samplerBuffer data; uniform int nbPoints; float readBuffer(int i){ float value = texelFetchBuffer(data, i*nbPoints).r; return value; } //****************************************************************************** //MAIN //****************************************************************************** void main(){ gl_FragColor = vec4(readBuffer(46),readBuffer(47),readBuffer(48),0); }
Thank you for your help.



