?? And how exactly do you query the amount of grey pixels? And how do you read back the results? And what results?
For pixels read i use the size() command of a vector. Ok…that was very stupid by me as i understand the mistake now :P…
I mean i cant render the texture on screen like before, and i print 0 with the method i used before to print the values of the image. This method was like this:
void *pixels =(void *)malloc(sizeof(float)*size*size);
float* data = (float*)(pixels);
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, size, size,GL_RED,GL_UNSIGNED_SHORT,data);
and then just print data as a normal float array
Or:
unsigned char *pixelsRed = NULL;
pixelsRed = new unsigned char[size*size];
memset(pixelsRed, 0, sizeof(2*unsigned char)*size*size);
glReadPixels(0, 0, size, size,GL_RED,GL_UNSIGNED_SHORT,data);
and printed the data like this in the second case:
for (int i=0; i<size*size; i++) {
itoa(data[i], text, 10); // using itoa with base = 10
printf( "%d: %s
",i, text);
This way the first code gave me results unclamped, and the second clamped. But this was when i used the GL_UNSIGNED_BYTE earlier. I even reconstructed the picture in matlab and looked ok…
I suspect that maybe something is wrong with the whole binding of the textures.
<-Stupid inside. :mad: … I just forgot to put:
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
wehere i was creating the texture
Question is which is the best way to save the output?
You really should try to understand the different data types and the conversions e.g. if you allocate a float array (1 float = 4 bytes = 32 bit) then you’re using readpixels with GL_UNSIGNED_SHORT which means that you allocated twice the necessary amount because unsigned short = 2 bytes, not 4. And then you print the array as float? which means you print a 32 bit value which is than a combination of 2 unsigned short values? Try reading the spec on how data types are converted between internal and external formats.
Any articles i could look at?
Problem is i am under stress and cant really think positive…
Now is ok… I just read FLOAT back from the fbo and everything is ok:)… Thansk for all the help -nico-. I couldnt have done it without you.