Jump to content
  • Advertisement
Sign in to follow this  

generate mip-mapped texture from framebuffer (Solved)

This topic is 4724 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
   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, m_uRefractionTexture);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   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);
      iZoom*=2
      iSize/=2;
   }
   glDisable(GL_TEXTURE_2D);



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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!