OpenGL filtering parameters and mipmap

bluefireoly :

When calling both

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

and

glGenerateMipmap(GL_TEXTURE_2D);

in the texture loading process in OpenGL, what will happen? What predominates, or what can I imagine what is going on in the background?

Rabbid76 :

If you want to use mipmapping, then the texture minifying function has to be GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR:
(See glTexParameter)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glGenerateMipmap(GL_TEXTURE_2D);

Note, glGenerateMipmap generates the mipmaps anyway. If the texture minifying is GL_NEAREST or GL_LINEAR, then the mipmaps are "ignored" on texture lookup.

If the minifying function is GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR or GL_LINEAR_MIPMAP_LINEAR and no mipmaps are generated, then the texture is not mipmap complete and texture access will return (0.0, 0.0, 0.0, 1.0), in the shader program.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=417036&siteId=1