View Full Version : Passing values f32 values [-1 to 1] to my FS via texture obj

08-23-2015, 06:45 AM
I want to pass a large array ( of length 5100) of Float32 type numbers, values ranging [-1 ~ 1] into my Fragment shader via a texture.
I've created my texture for this purpose like below ,

glBindTexture(GL_TEXTURE_2D, texID);
glTexImage2D(GL_TEXTURE_2D,0,GL_R32F,wd,ht,0,GL_RE D,GL_FLOAT,NULL);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, wd, ht, GL_RED, GL_FLOAT, data);

glTexParameteri(pTexObj.texTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(pTexObj.texTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(pTexObj.texTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(pTexObj.texTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

But when I'm trying to fetch those values from the texture handle( Sampler2D variable created inside FS) using the following call,

I suspect that all values I'm getting all those floating values clamped into [0~1].

Plz advise me how can I get the actual values of my array of float32 values, what I fed inside texture object.