I have to disagree with -NiCo-, because setting the base and max level will, as a matter of fact, should only generate the desired mip level (see below), but to display it, you’ll definitely need to tweak the LOD, as pointed out by execom_rt.
And then, I’ll disagree with jwatte (but maybe I didn’t understand completely what he meant), because you can completely specify glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE); after the texture datas have been uploaded in the first place. The mip levels will be generated each time something change in your base level.
I’ve been looking for a way to generate only the mip level I was interested in for some time now, and there’s no way to do that (actually, I didn’t found any, but maybe there are). So you have to specify base level at 0, and max level at your desired level.
Basically, the code looks like this :
// Bind target texture
glEnable(GL_TEXTURE_2D) ;
glBindTexture(GL_TEXTURE_2D, ScreenRenderTexture) ;
// Size of grab
float ScreenGrabXf, ScreenGrabYf ;
int ScreenGrabXi, ScreenGrabYi ;
float TexSize = 1024.0f ;
ScreenGrabXi = static_cast<int>(ScreenGrabXf = static_cast<float>(RenderViewWidth)) ;
ScreenGrabYi = static_cast<int>(ScreenGrabYf = static_cast<float>(RenderViewHeight)) ;
// Grab screen
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, ScreenGrabXi, ScreenGrabYi) ;
// Texture LOD bias
glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, BlurRate * MaxLODBias) ;
// draw quad
glBegin(GL_QUADS) ;
glTexCoord2f(ScreenGrabXf / TexSize, ScreenGrabYf / TexSize) ; glVertex2f(1.0f, 1.0f) ;
glTexCoord2f(0.0f, ScreenGrabYf / TexSize) ; glVertex2f(-1.0f, 1.0f) ;
glTexCoord2f(0.0f, 0.0f) ; glVertex2f(-1.0f, -1.0f) ;
glTexCoord2f(ScreenGrabXf / TexSize, 0.0f) ; glVertex2f(1.0f, -1.0f) ;
glEnd() ;
And now, I might be wrong … but this worked for me.
SeskaPeel.