2

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?

4

1 回答 1

5

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.

于 2020-01-30T18:22:09.973 回答