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(){
    
    ofEnableDepthTest();
    ofDisableArbTex();
    
    img.load("earth.jpg");
    mesh = ofMesh::sphere(300,100);
    cam.setVFlip(true);
    cam.setPosition(100, ofGetHeight()/4, 0);
    cam.lookAt(ofVec3f(ofGetWidth()/2, ofGetHeight()/2, 0));
    
}

//--------------------------------------------------------------
void ofApp::draw(){

    cam.begin();
    img.bind();
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 0);
    mesh.draw();
    img.unbind();
    cam.end();
}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

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

And Here’s a link to the test image
[http://paulbourke.net/geometry/transformationprojection/earth.jpg]

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:

tex.setTextureMinMagFilter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);

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: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glTexParameter.xml

1 Like

Perfect! Thank you!