[QUOTE=GClements;1259514]You’re aware that RGBA32UI is 32 bits per component, so 128 bits (16 bytes) per pixel, right? I’ve seen people assume that it meant 32 bits per pixel.
This should work. You could also try binding the texture level to a framebuffer then using glReadPixels().[/QUOTE]
Thanks for replying. I know that RGBA32UI is 32 bits per component. I have tried the glReadPixels(), and it neither give me the result…
When I change the texture to RGBA32F, it works on everything and I can read back every mipmap level by using both glGetTexImage() andglReadPixels(). However, for RGBA32UI, it only works on level 0.
Does any people come across this problem?
Here is my code:
RGBA32 version
float data = (float ) malloc(3232sizeof(float)4);
for(int i = 0 ; i < 3232*4; i++){
data[i] = 10.0;
}
GLuint texMM;
glGenTextures(1, &texMM);
glBindTexture(GL_TEXTURE_2D, texMM);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, 32, 32, 0, GL_RGBA, GL_FLOAT, data);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_2D, texMM);
float myImage = (float ) malloc(3232sizeof(float)*4);
glGetTexImage(GL_TEXTURE_2D, 1, GL_RGBA, GL_FLOAT, myImage); // read back level 1
FILE fp = fopen(“image.raw”, “wb”);
for (int i = 0; i < 3232; i++) {
fprintf(fp, "%f %f %f %f
", myImage[i*4], myImage[i*4+1], myImage[i*4+2], myImage[i*4+3]);
}
fclose(fp);
glBindTexture(GL_TEXTURE_2D, 0);
exit(0);
image.raw is filled with 10.
RGBA32UI version
unsigned int data = (unsigned int ) malloc(3232sizeof(unsigned int)4);
for(int i = 0 ; i < 3232*4; i++){
data[i] = 10;
}
GLuint texMM;
glGenTextures(1, &texMM);
glBindTexture(GL_TEXTURE_2D, texMM);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI, 32, 32, 0, GL_RGBA_INTEGER, GL_UNSIGNED_INT, data);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, 0);
glBindTexture(GL_TEXTURE_2D, texMM);
unsigned int myImage = (unsigned int ) malloc(3232sizeof(unsigned int)*4);
glGetTexImage(GL_TEXTURE_2D, 1, GL_RGBA_INTEGER, GL_UNSIGNED_INT, myImage); // read back level 1
FILE fp = fopen(“image.raw”, “wb”);
for (int i = 0; i < 3232; i++) {
fprintf(fp, "%u %u %u %u
", myImage[i*4], myImage[i*4+1], myImage[i*4+2], myImage[i*4+3]);
}
fclose(fp);
glBindTexture(GL_TEXTURE_2D, 0);
exit(0);
image.raw is filled with 3452816845…