Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Anti-aliasing, not working correctly  (Read 6513 times)

0 Members and 1 Guest are viewing this topic.

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Anti-aliasing, not working correctly
« on: October 02, 2009, 10:55:51 pm »
Hi all, just started using SFML as i needed a simple API capable of creating multimedia applications (such as games) quickly and so far im very impressed.

But im in a spot of trouble here. When i create a png image with anti-aliasing in my image editor and then use it in SFML its not quite as smooth as it was in the image editor.. to give you better idea of what i mean, heres an image of my troubles. On the left we have a screen shot of a ball print screened from my application and on the right is the same ball in my image editor.



Ive tried changing the anti-aliasing settings in the WindowSettings class when creating my window and have also tried to sf::Image::SetSmooth but nothing..

Whats going on here?

Thanks in advance! :D


EDIT: ... Nevermind, seemed as though i needed to sf::Image::SetSmooth( false ), hmm thats going to be annoying... anywho sweet API thanks laurent :D

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Anti-aliasing, not working correctly
« Reply #1 on: October 03, 2009, 01:16:30 pm »
Quote
hmm thats going to be annoying

Why? If your image is already anti-aliased then you don't want SFML to smooth it more. That sounds perfectly ok to me.
Laurent Gomila - SFML developer

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Anti-aliasing, not working correctly
« Reply #2 on: October 03, 2009, 07:18:43 pm »
Because I would rather not have to turn off the smoothing each time I load an image, it just tedious. If i want an image anti-aliased i will do it in my editor, same thing goes for my aliased graphics.

I would prefer it if sf::Image::myIsSmooth is false by default because as far as i can see im not going to need the APIs "smoothing" capabilties.

Thats why. :)


EDIT: By the way, have you noticed SFML starts slowly for about 1/2 - 1 second, try creating a simple application which starts an sf::Sprite moving in some way (rotating, scaling, translating) and pay particular attention to the start of the program and the speed at which the sprite transforms.

Most of the time, this isnt going to be problem though it still should be fixed if this is a bug.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Anti-aliasing, not working correctly
« Reply #3 on: October 03, 2009, 07:49:22 pm »
Quote
Because I would rather not have to turn off the smoothing each time I load an image, it just tedious

Quote
I would prefer it if sf::Image::myIsSmooth is false by default because as far as i can see im not going to need the APIs "smoothing" capabilties.

Hum... did you notice that I'm not developing SFML just for you? ;)

Quote
By the way, have you noticed SFML starts slowly for about 1/2 - 1 second

No. Can you show me a piece of code that reproduces this bug, so that I can try myself?
Laurent Gomila - SFML developer

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Anti-aliasing, not working correctly
« Reply #4 on: October 03, 2009, 08:17:41 pm »
Quote from: "Laurent"
Hum... did you notice that I'm not developing SFML just for you? ;)


Well of you're course not, you asked me why I felt that smoothing set to true by default is annoying and i explained. I dont expect you to change it for me, i could do that myself if i could be bothered.

Quote
No. Can you show me a piece of code that reproduces this bug, so that I can try myself?


Code: [Select]
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nShowCmd )
{
sf::RenderWindow Window( sf::VideoMode( 800, 600, 32 ), "Slow Start Application" );

sf::Shape Rectangle = sf::Shape::Rectangle( 0, 0, 200, 100, sf::Color( 255, 50, 50 ) );
Rectangle.SetCenter( 100, 50 );
Rectangle.Move( Window.GetWidth( ) / 2, Window.GetHeight( ) / 2 );


sf::Event Event;
while ( Window.IsOpened( ) )
{
while ( Window.GetEvent( Event ) )
{
if ( Event.Type == sf::Event::Closed )
Window.Close( );

if ( Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape )
Window.Close( );
}

Window.Clear( );

Rectangle.Rotate( 0.1f );
Window.Draw( Rectangle );

Window.Display( );
}
}

Yeah so, when you run this piece of code, the rectangle rotates slowly for half a second, and then picks up speed and everything runs normally, as ive said its not a major problem (its only a slight speed increase in this demo) but it is there, and it may just be my computer, but I never noticed this while working with DirectX and GDI/GDI+. The problem is more apparent in my Bouncing Ball Demo whiped up yesterday to test SFML but maybe because theres more than one sprite in that demo.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Anti-aliasing, not working correctly
« Reply #5 on: October 03, 2009, 08:29:21 pm »
Quote
Yeah so, when you run this piece of code, the rectangle rotates slowly for half a second, and then picks up speed and everything runs normally

This example runs fine on my computer, I don't notice any slowdown at startup.

Quote
it may just be my computer, but I never noticed this while working with DirectX and GDI/GDI+

SFML uses OpenGL :)
So you should try to run other OpenGL applications. You can also update your graphics drivers.
Laurent Gomila - SFML developer

CodeCriminal

  • Newbie
  • *
  • Posts: 18
    • View Profile
    • Email
Anti-aliasing, not working correctly
« Reply #6 on: October 03, 2009, 09:28:35 pm »
So yeah, i updated my drivers (thanks for reminding me) and ran the samepl posted above again and i still get the same problem.

Also i ran the opengl sample provided with SFML and that seems to run fine, no slow downs at the start. Call me crazy, but im deffinatly seeing a slowstart / speedup within 1/2 of a second of that sample application.


EDIT: Ooooh, sorry my bad.. the slowstart only happens when running the application from within my IDE ( duh! *feels stupid* ), sorry about that man, anyway keep up the good work :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Anti-aliasing, not working correctly
« Reply #7 on: October 03, 2009, 09:37:01 pm »
:wink:
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Anti-aliasing, not working correctly
« Reply #8 on: October 04, 2009, 01:08:03 pm »
Quote from: "CodeCriminal"
Because I would rather not have to turn off the smoothing each time I load an image, it just tedious.
I don't know how others see this, but for many cases one has to deactivate image smoothing in order to get proper results. I agree you in this respect.

However, you can write a loading function, which simplifies that. Other things like exceptions are easier to handle with this approach as well.
Code: [Select]
void LoadImage(sf::Image& Image, const std::string& FileName)
{
    if (!Image.LoadFromFile(FileName))
        throw AnyException(...);
    Image.SetSmooth(false);
}
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything