I went back to the start trying to get the most simple shader to run, I was partially successful but now I got a problem that’s even weirder.
This is my shader:
#version 120
#extension GL_EXT_gpu_shader4 : enable
uniform samplerBuffer lightRGB;
uniform sampler2D tex;
void main()
{
int index = int(clamp(gl_TexCoord[0].s, 0, 32.0));
vec4 light = texelFetchBuffer(lightRGB, index);
vec4 texel = texture2D(tex, gl_TexCoord[0].st);
gl_FragColor = texel*2.0 + light/20.0;
}
But I can’t seem to get the data from both samplers. Using only one is fine and I get the proper data for both as long as the other one is not accessed.
But as soon as I try to get data from both the one from the first sampler is just ignored. In the code above I only get the regular textures but if I switch the 2 lines of code around I only get the data from the texture buffer. I also tried to use #pragma optimize but that makes no difference.
Here’s the code that sets up the texture buffer. This seems to work fine as I can get the data out of this if I don’t try to access the other texture:
glGenBuffers(1, &idbuffer);
glBindBuffer(GL_TEXTURE_BUFFER, idbuffer);
static unsigned char testdata[] = {
255,255,255,0,
255, 0, 0,0,
0,255, 0,0,
0, 0,255,0,
255,255, 0,0,
0,255,255,0,
255, 0,255,0,
255,255,255,0,
255, 0, 0,0,
0,255, 0,0,
0, 0,255,0,
255,255, 0,0,
0,255,255,0,
255, 0,255,0,
255,255,255,0,
255, 0, 0,0,
0,255, 0,0,
0, 0,255,0,
255,255, 0,0,
0,255,255,0,
255, 0,255,0,
255,255,255,0,
255, 0, 0,0,
0,255, 0,0,
0, 0,255,0,
255,255, 0,0,
0,255,255,0,
255, 0,255,0,
128, 64, 0,0,
64, 32, 0,0,
0,128,255,0,
0, 64,128,0,
};
glBufferData(GL_TEXTURE_BUFFER, 128, &testdata[0], GL_STREAM_DRAW);
glGenTextures(1, &idtexture);
glBindTexture(GL_TEXTURE_BUFFER, idtexture);
glTexBufferARB(GL_TEXTURE_BUFFER, GL_RGBA8, idbuffer);
glActiveTexture(GL_TEXTURE14);
glBindTexture(GL_TEXTURE_BUFFER, idtexture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
I am using NVidia’s latest beta driver which I installed in the hope that the crash I had yesterday would go away but it didn’t help there.