LaurentGomila/SFML — Issue #123: Add support for mipmaps
Author: luiscubal
Created: 2011-11-11 20:38:56+00:00
State: open

Currently, drawing a sprite with a low zoom(inferior to 1), so that the texture is "zoomed out", gives a very bad result, even if Smooth is set.
Although there are ways to force mipmaps to be created using SFML's Bind() and OpenGL commands, this is still worse than having proper support in SFML.

I propose the following solutions(any will do):

1. Have a bool parameter in the Texture constructor telling SFML to generate mipmaps, and automatically enable them with Smooth=true(or a separate property useMipmapsIfSmooth)
2. Have some function to enable mipmap support.
3. Have mipmap support always enabled(perhaps not recommended since it will cause problems for images with Smooth=false)

Mipmaps seem to be available since OpenGL 1.4 (although there seem to have been some changes to how mipmaps are created in OpenGL 3.0), so I don't think this would cause problems to anyone. If compatibility is a problem, then some static method to detect mipmap support could be added(similar to how SFML handles shaders?)

As far as I know, adding mipmap support should be as simple as adding the following lines of code:

glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);

See also: http://sfml-dev.org/forum/viewtopic.php?t=6266