PDA

View Full Version : Mipmapping with integer texture



Media
08-31-2010, 11:58 AM
Hello everyone,

I cannot customize mipmap generation with integer texture, e.g. GL_RGBA32UI_EXT.

In the EXT_texture_integer document, it mentions that:
the internalformat is integer, TEXTURE_MAG_FILTER must be NEAREST and TEXTURE_MIN_FILTER must be NEAREST or NEAREST_MIPMAP_NEAREST.

I can customize mipmap generation with floating-point texture.
Here is the sample code from EXT_framebuffer_object document (Example #5)



glBindTexture(GL_TEXTURE_2D, 0);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color_tex, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);

<1. draw to the base level of the color texture>

// custom-generate successive mipmap levels
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
glBindTexture(GL_TEXTURE_2D, color_tex);
foreach (level > 0, in order of increasing values of level)
{
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,GL_TEXTURE_2D, color_tex, level);
glTexParameteri(TEXTURE_2D, TEXTURE_BASE_LEVEL, level-1);
glTexParameteri(TEXTURE_2D, TEXTURE_MAX_LEVEL, level-1);

<2. draw to level>
}
glTexParameteri(TEXTURE_2D, TEXTURE_BASE_LEVEL, 0);
glTexParameteri(TEXTURE_2D, TEXTURE_MAX_LEVEL, max);

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);

<3. draw to the window, reading from the color texture>



The base level, step 1, is always rendered correctly. Instead of step 2, glGenerateMipmapEXT() is used. Then at step 3 the whole texture levels can be viewed. It works but the content of each level is the same. It seems that glGenerateMipmapEXT does nothing except copying data from base level to the others in case of integer format texture.
If I enable step 2 to manually draw each level then the texture becomes blank even the base level.

Does anybody know this problem?

Thanks,