[英]How can I get float values using glReadPixels? [Android NDK es3.0]
c++ code: C ++代码:
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. 现在,我想读回值“ 2.22”,但是现在我得到的是一些长浮点值。 (the output is like -188856716075009999660373357998301511680.000000, not I want). (输出就像-188856716075009999660373357998301511680.000000,不是我想要的)。
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. 我还尝试使用GLubyte作为结果数组的类型,并获得了颜色值(result [0]是R值,result [1]是G值,result [2]是B值,result [3]是A值),不是我想要的
Questions: 问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.