How does the glGenerateMipmap
function create the mipmaps? Does it do some kind of interpolation, does it take the average of 4 pixels (this is what assume), or does it skip every second pixel in the next mipmap level?
And is there a way to influence its underlying algorithm? Or choose the way mipmaps are created?
The OpenGL Spec, Section 8.14.4 states about mipmap generation:
No particular filter algorithm is required, though a box filter is recommended as the default filter
It is not possible to modify the algorithm used by glGenerateMipmap
, but you can create mipmap levels on your own with any algorithm you like and then upload them to the texture using glTexImage2D(...)
with the appropriate level. Level 0 is the full resolution, Level 1 is the one with 1/2 of the original size and so on.