![](/img/trans.png)
[英]How to add bitmap/image texture to a surface in Android OpenGL ES3.0?
[英]How can I get float values using glReadPixels? [Android NDK es3.0]
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]);
}
現在,我想讀回值“ 2.22”,但是現在我得到的是一些長浮點值。 (輸出就像-188856716075009999660373357998301511680.000000,不是我想要的)。
我還嘗試使用GLubyte作為結果數組的類型,並獲得了顏色值(result [0]是R值,result [1]是G值,result [2]是B值,result [3]是A值),不是我想要的
問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.