3

Assuming mipmapping is desirable:

I call glGenerateMipmapEXT(GL_TEXTURE_2D); when I first allocate the render target for my FBO. Do I have to call this again when I've completed rendering to it to correctly populate all the mipmapping levels, or do subsequent render calls render to all levels simultaneously?

I have an example where one of my object is fading to <0,0,0,0> when the min filter (GL_LINEAR_MIPMAP_LINEAR) kicks in, and I'm assuming that not re-mipmapping after rendering is causing this.

I've looked through a few examples, and have found a couple where subsequent glGenerateMipmap calls are made, but more where they aren't.

Opinions?

Chad Mourning
  • 608
  • 2
  • 12
  • 25
  • The way the documentation is phrased makes me believe that you *do* need to regenerate mipmaps with new render calls: "glGenerateMipmap generates mipmaps for the texture attached to target of the active texture unit." Maybe you could make a small test unit that validates this? – Victor Zamanian Mar 13 '11 at 20:36
  • Well, I'll put it this way. If I don't do it, it doesn't work. If I do do it, it does work. I just wasn't sure, if I was doing something else wrong, or if there was a better way to go about it. – Chad Mourning Mar 13 '11 at 21:57
  • 1
    You don't necessarily _have to_ do it, but if you don't then it probably won't work the way you expect. EXT_framebuffer_object is quite clear about it in the spec: mipmaps are built when, and only when, you tell OpenGL to do it, other than with the (deprecated) GL_GENERATE_MIPMAP texture object state. The reason is that with a texture rendered to from a FBO, there is no single good way of knowing when to do it, as there is with simply a texture. So, if you don't call glGenerateMipmap, then it will still "work" (it will render just fine and it won't crash), but ... – Damon Mar 14 '11 at 10:32
  • 1
    ... but it won't automagically update the other mip levels. That is usually not what one wants, of course (though in some special cases, it might be). This is better than any other solution, though. Otherwise, since OpenGL cannot know when to or when not to update mip-maps, it would have to do it after every single draw call just to be on the safe side. That would be terrible for performance. – Damon Mar 14 '11 at 10:32
  • generate mipmaps for currently bound texture for a given target.. Damon comments should be the answer , so I upvote the comments :D (both!) – CoffeDeveloper Jan 01 '15 at 19:02

1 Answers1

7

glGenerateMipmap will fill levels [1,..,n] based on the level[0]. So yes, you should call it whenever your level[0] changes.

kvark
  • 5,291
  • 2
  • 24
  • 33