ofFbo enable mipmap

@tgfrerer has done an awesome job getting mipmaps to work with ofTexture.

just wanted to open up a discussion on how mipmapping can work with ofFbo.

this issue first came up on the OF github,
https://github.com/openframeworks/openFrameworks/pull/3146

1 Like

ive tried a few different things to get mip mapping working with ofFbo but with no result. the below code was my best hope, to create a ofTexture outside the ofFbo with mip mapping enabled, and then attach the ofTexture to the ofFbo. unfortunately i currently don’t have too much time to dig into the ofFbo internals, so just stabbing in the dark for the moment.

@tgfrerer atm im working on a project where i need to create a bunch of floating images (ofFbo’s) which shrink into the distance… without mip mapping this looks horrible. can you recommend a method for adding a mip mapped enabled ofTexture as a backing texture to a ofFbo?

ofFbo * fbo = new ofFbo();
fbo->allocate(w, h, GL_RGBA);

ofTexture fboTexture;
ofDisableArbTex();
fboTexture.enableMipmap();
ofEnableArbTex();
fboTexture.allocate(w, h, GL_RGBA);

fbo->bind();
fbo->attachTexture(fboTexture, fboTexture.getTextureData().glTypeInternal, 0);
fbo->unbind();

Hey mate,

It should work for fbo’s the same as a normal texture, except you have to enable midmaps after every begin/draw/end for fbo. I’m not familiar with the new enableMipmap() methods that were added, but the raw gl calls work. Here’s a sample… https://gist.github.com/trentbrooks/fed01ddaa48591dbd50d

hey @trentbrooks, thanks for the pointers.
ive played around with it some more today and got it working.
here is how you can do it just with the OF api

ofDisableArbTex();
fbo.allocate(w, h, GL_RGBA);
ofEnableArbTex();

fbo.begin();

ofClear(255, 255);
// draw something.

fbo.end();

ofTexture & fboTexture = fbo.getTextureReference();
fboTexture.enableMipmap();
fboTexture.generateMipmap();
fboTexture.setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);