ofxFBOTexture and mipmaps

Gentlemen,

I have struggled with this now for 3 days, so I guess it’s time to call in the big guns. I am trying to render to an FBO on every frame and generate a full set of mipmaps before rendering out my FBO texture. Examples online make it look so simple. The only trouble is that when I render out my FBO texture, I can see the crossfade to the first mipmap level because the mipmap was never generated – it’s just black! Check it out!

So, what am I doing to get here? First of all, I initialize my FBO to a power of two square and use texData.textureTarget = GL_TEXTURE_2D (default) since, I believe, GL_TEXTURE_RECTANGLE_ARB does not support mipmapping. Note here the insertion of “false &&” to my GLEE_ARB_texture_rectangle check for testing purposes to maintain the default GL_TEXTURE_2D:

  
  
allocate(){  
  
       ...  
  
#ifndef TARGET_OPENGLES	  
    if (false && GLEE_ARB_texture_rectangle){  
        texData.tex_w = w;  
        texData.tex_h = h;  
        texData.textureTarget = GL_TEXTURE_RECTANGLE_ARB;  
    } else  
#endif	  
	{	  
        texData.tex_w = ofNextPow2(w);  
        texData.tex_h = ofNextPow2(h);  
    }  
	  
#ifndef TARGET_OPENGLES	  
	if (false && GLEE_ARB_texture_rectangle){  
		texData.tex_t = w;  
		texData.tex_u = h;  
	} else  
#endif	  
	{  
		texData.tex_t = w/texData.tex_w;  
		texData.tex_u = h/texData.tex_h;  
	}  
  

Then, later in allocate()…

  
  
	glTexParameterf(texData.textureTarget, GL_TEXTURE_WRAP_S, GL_REPEAT);//);  
	glTexParameterf(texData.textureTarget, GL_TEXTURE_WRAP_T, GL_REPEAT);  
	glTexParameterf(texData.textureTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  
	glTexParameterf(texData.textureTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);		//GL_LINEAR  
	glTexImage2D(texData.textureTarget, 0, texData.glTypeInternal , texData.tex_w, texData.tex_h, 0, texData.glType, texData.pixelType, 0);  
	  
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);  
	glGenerateMipmapEXT(texData.textureTarget);  //Allocate necessary space for mipmaps  
  

The only thing left to do should be to call glGenerateMipmapEXT after I draw to my FBO:

  
  
swapOut(){  
	...  
	  
	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, oldFramebuffer);  
  
	glBindTexture(texData.textureTarget, (GLuint)texData.textureName);  
	glGenerateMipmapEXT(texData.textureTarget);  
	glBindTexture(GL_TEXTURE_2D, 0);  
}  
  

And I get the fadeout you see in the image above. I can move the point of view back from the texture on screen and the whole thing fades to black.

This code, as far as I can tell, exactly mimics every FBO mipmap sample I can find, especially this one, which I have reviewed in detail:

http://www.songho.ca/opengl/gl-fbo.html

Someone suggested that although glGetString(GL_VERSION) reports 3.2.0, maybe my code isn’t creating a true OGL 3 profile? I don’t really know what that means, or how to check or fix it. There’s not much to see in ofAppGlutWindow::setupOpenGL().

I’m using an nVidia Quadro 4800, Window7, VS2008.

Any thoughts? Ideas? Thanks in advance!

I just went searching for a solution to this question again and this post turned up. It took me a minute to realize that it was a question from ME from 7 years ago. Anyway, for anyone else who comes looking, there’s a solution at the end of this thread: