SFML community forums

Help => Graphics => Topic started by: Austech on January 02, 2011, 11:31:06 pm

Title: sf::RenderImage Anti aliasing not working?
Post by: Austech on January 02, 2011, 11:31:06 pm
I'm trying to draw objects to a RenderImage, and draw the RenderImage to the window.

The problem is that if I were to draw something to a render image, and draw the sprite of the render image to the window, there's no Anti aliasing.

If I were to draw the objects directly to the window, it has Anti aliasing. But it would really be a struggle with my class structure to do this, plus it would be a lot easier to do things with a render image.

Here's an example I made up with this happening:

Code: [Select]
int main(int argc,const char *argv[])
{
sf::ContextSettings cs;
cs.AntialiasingLevel = 12;
sf::RenderWindow window(sf::VideoMode(800,600), "Test",sf::Style::Close,cs);
window.SetFramerateLimit(60);

sf::RenderImage rimg;
rimg.Create(800,600);
rimg.Clear();
rimg.Draw(sf::Shape::Circle(100,100,50,sf::Color(255,255,255)));
rimg.Display();
sf::Sprite spr;
spr.SetImage(rimg.GetImage());
while(window.IsOpened())
{
while(window.GetEvent(event))
{
if(event.Type == sf::Event::Closed)
{
window.Close();
}
}
window.Clear();
window.Draw(spr);
window.Draw(sf::Shape::Circle(100,400,50,sf::Color(255,255,255)));
window.Display();
}
}


Here's what I get:
(http://i51.tinypic.com/zj6s77.jpg)

Any help is appreciated, and thanks a lot in advance. : )
Title: sf::RenderImage Anti aliasing not working?
Post by: Laurent on January 02, 2011, 11:34:06 pm
Well, you can get texture smoothing with rimg.SetSmooth(true). This is not anti-aliasing but the result should the close enough.
Title: sf::RenderImage Anti aliasing not working?
Post by: tntexplosivesltd on January 03, 2011, 09:37:27 am
12 is an odd number for anti-aliasing. Try using 4x and 8x, and see if it changes anything.
Title: sf::RenderImage Anti aliasing not working?
Post by: Laurent on January 03, 2011, 10:44:50 am
Quote
12 is an odd number for anti-aliasing. Try using 4x and 8x, and see if it changes anything.

It won't change anything because:
1. SFML finds the closest valid anti-aliasing level anyway
2. setting up anti-aliasing on the window won't help, he wants anti-aliasing on the render-image
Title: sf::RenderImage Anti aliasing not working?
Post by: tntexplosivesltd on January 03, 2011, 10:54:06 am
Right, that makes sense. I wasn't sure.