LaurentGomila/SFML — pull request #498 by wintertime (2013-11-29 15:58:59+00:00)
Title: Add mipmaps to sf::Texture

I think not having mipmaps in SFML is something that needs to be changed, because it helps when using setScale and when putting a larger texture onto a smaller sized shape.
As I liked to have it myself I added this to sf::Texture and it should also fix Issue #123 .
I made it such that its backwards compatible and keeps deactivated until used. When not used it just adds a check of a status variable on some method calls. Its possible to use all underlying modes in combination with the smooth setting.
This uses the texture parameter to generate the mipmaps.
It looks like its working for me, but you would probably want to test it before applying.

PS:
I also put some effort into adding code for using the newer glGenerateMipmapExt and glGenerateMipmap and making mipmaps available for the internal texture of sf::RenderTexture. You can view those other commits in my forked repository at https://github.com/wintertime/SFML/tree/mipmaps .
I did not include those here, because I get graphical glitches sometimes although other times it looks like it works. I think there is either something wrong with the order of calls to the OpenGL functions or I experienced the driver bug mentioned on http://www.opengl.org/wiki/Common_Mistakes#Automatic_mipmap_generation .

Here is a small test program for trying it out, you can change a few parameters in the code and then look at a larger area of the texture squeezed into the window by pressing Numpad6 so you can watch the effect of mipmaps:

```C++
#include "SFML/Graphics.hpp"
#include

int32_t windowx(512);
int32_t windowy(512);
bool fullscreen(false);

void CreateTexture(sf::Texture& tex,int sz,int w,int b) {
std::vector pix;
pix.resize(sz*sz*4);
for(int y(0);y