Sign in to follow this  

Manual MipMap Generation

Recommended Posts

I am trying to manually render my own Mip Map chain using a framebuffer object.  It works on the first pass (for the first level of mipmaps), but doesn't output anything on subsequent passes.  I set it up like:

	glBindFramebuffer(GL_FRAMEBUFFER, fboID);
	glBindTexture(GL_TEXTURE_2D, texID);

	for(unsigned int i = 1; i < 10; i++)
		unsigned int Dim = (512 >> i);
		glViewport(0, 0, Dim, Dim);
		glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texID, i);

		// <-- Render Quad -->

So when I look at my texture, Level 0 is the source texture I expect, and level 1 has the correct 1st mipmap rendered... but every level from 2 on up is blank.  It's as if the render never happened and the program never ran.  If I modify the loop to start at 2, or 3, etc., then I see that mipmap level rendered correctly.  What gives?


Share this post

Link to post
Share on other sites

Bind (or unbind and rebind) the framebuffer each time you modify it.

Set the viewport after the binding.


Also, not sure what your purposes are, but you will not be satisfied with the quality of the mipmaps you get using this approach.  At the very least you need to always sample the next mipmap up with this approach, although even that will not give you satisfactory results.



L. Spiro

Edited by L. Spiro

Share this post

Link to post
Share on other sites

I tried that, along with setting everything during each iteration of the loop.  It still gives me the same result, level 1 works and the rest don't even seem to run.  And I'm not even sampling the source texture at this point; I'm setting the output to red, and I still only see it on level 1.  It's like it refuses to run/render on anything but the first iteration of the loop.

Edited by Funkymunky

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this