How to properly generate mipmap?

Hi, I’m trying to toggle applying mipmap texture so I can see the difference.
But I don’t see any difference when I call ofTexture::generateMipmap();

Is there any way that I can toggle between enabling/disabling mipmap in realtime so I can compare?

Here’s my test code below.

ofImage img;
ofMesh mesh;
ofCamera cam;

void ofApp::setup(){
    mesh = ofMesh::sphere(300,100);
    cam.setPosition(100, ofGetHeight()/4, 0);
    cam.lookAt(ofVec3f(ofGetWidth()/2, ofGetHeight()/2, 0));

void ofApp::draw(){

    ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);

void ofApp::keyPressed(int key){

    img.getTexture().generateMipmap(); // this has no effect.

And Here’s a link to the test image

generating the mipmaps is not enough to use them, to actually tell opengl to use the mipmaps you need to change the filter mode of the texture like:


or to disable them:

tex.setTextureMinMagFilter(GL_LINEAR, GL_LINEAR);

take into account that mipmaps only work when looking things from far away ir somehow zooming out or scaling them down, not when zooming it which is what it seems you are doing in your image

1 Like

Thank you so much @arturo :slight_smile:

I could clearly see the difference when I zoomed out like you said.

So, “GL_LINEAR, GL_LINEAR” is the default setting of textureMinMagFilter right?

I only knew about GL_LINEAR(smoothed) and GL_NEAREST(unsmoothed) for the filter option.

Could you please teach me if there’s any other important filter option other than these?

this is standard opengl:

1 Like

Perfect! Thank you!