c++ code:
float* data = (float*)malloc(texWidth*texHeight*sizeof(float)); // or GLfloat
float* result = (float*)malloc(texWidth*texHeight*sizeof(float)); // or GLfloat
for (int i = 0; i < texWidth * texHeight; i++) {
data[i] = 2.22;
}
...
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
...
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
...
glReadPixels(0, 0, texWidth, texHeight, GL_RGBA, GL_UNSIGNED_BYTE, result);
for (int i = 0; i < 64; i++) {
LOGD("%f", result[i]);
}
Now I want to read the value "2.22" back, but now what I get are some long float values. (the output is like -188856716075009999660373357998301511680.000000, not I want).
I also tried using GLubyte as result array's type, and got the color values(result[0] is R value, result[1] is G value, result[2] is B value, result[3] is A value),which is not what I want.
Questions:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.