I want to downsample a texture, in my case textures from framebuffer objects, to 1/2 or 1/4 their size or even down to just 1x1. In theory, this should be easy by letting OpenGL trigger mip map generation for the texture, at least that’s the info you find everywhere on the subject. However, I could not find specific information on how to implement it and I can’t seem to get it to work :(.
What I do is this:
• bind the texture
• call glGenerateMipmap()
• bind an fbo with e.g. a 1x1 sized texture
• resize the viewport to 1x1
• create an ortho projection with a 1x1 size
• render the texture on to a (off-)screen sized quad
The fbo texture should now contain the 1x1 version of the original texture, or not? However, I always only seem to get downsampled versions without interpolation. I.e. in case of the 1x1 texture, only the fragment in the center of the original image. Or in case of the 1/4 sized version, I see flickering.
What am I doing wrong here? What did I misunderstand?
I wanted to implement the HDR/bloom/tonemapping pipeline from here: http://msdn.microsoft.com/en-us/library/ee417769(v=VS.85).aspx
But instead of doing the tedious task of downsampling the texture with multiple passes and custom shaders, I thought that it’s more efficient to take advantage of hardware mipmapping?