Advertisement Jump to content
Sign in to follow this  

generate mip-mapped texture from framebuffer (Solved)

This topic is 4968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have a multipass rendering that first renders the scene with a reflected camera to the framebuffer, then copies it to a texture with glCopyTexImage2D, and then renders the scene adressing this texture (with projective mapping, but no matter). This works fine, but the problem is that I want to generate a mip-mapped version of this texture : I tried to use glPixelZoom, but my code doesn't work. Here is the kind of code that I use to copy the texture :
  // copy the texture
   glBindTexture(GL_TEXTURE_2D, m_uRefractionTexture);
   int iZoom = 1;
   int iSize = 512;
   for (int i = 0 ; i < 9 ; i++)
      glPixelZoom(iZoom, iZoom);
      glCopyTexImage2D(GL_TEXTURE_2D, i, GL_RGB, 0, 0, iSize, iSize, 0);

Even when I disable glPixelZoom my mip maps are black, but it should contain something copied by glCopyTexImage2D even if it's not the good pixels. Any ideas ? [Edited by - ptl on June 15, 2005 6:16:41 PM]

Share this post

Link to post
Share on other sites
you could use the SGI automatic mipmap generation or if you have the FBO extension use its mipmap generation function, both of which take the top level image and generate a complete mipmap layout for it.

Share this post

Link to post
Share on other sites
I've found one bug : i should go from 0 to to 10, not to 9, otherwise the last level is missing. Now my textures aren't black any more but they still not contain the good pixels.
_the_phantom_ : that's what I was looking for, thanks a lot :) I thought this wasn't working with glCopyTexImage2D, but it seems to work fine now.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!