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

Author Topic: resized window: how to smooth graphics ? (resampling)  (Read 4333 times)

0 Members and 1 Guest are viewing this topic.

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
resized window: how to smooth graphics ? (resampling)
« on: October 31, 2014, 01:04:20 pm »
Hi

I have a SFML window, when i maximize it, the graphics are scaled to fit the screen with the nearest neighbor algorithm, which looks very bad when desktop resolution isnt a multiple of the window's native size.

Is there a way to force a better quality resampling? (like the one used for textures with smooth enabled?)
« Last Edit: October 31, 2014, 01:08:33 pm by ratatax »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: resized window: how to smooth graphics ? (resampling)
« Reply #1 on: October 31, 2014, 02:45:08 pm »
Quote
the graphics are scaled to fit the screen with the nearest neighbor algorithm
What graphics?

There are two things that you can smooth:
- textures, with bilinear filtering (see Texture::setSmooth)
- geometry, with anti-aliasing (see ContextSettings::antialiasingLevel when you create the window)
Laurent Gomila - SFML developer

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: resized window: how to smooth graphics ? (resampling)
« Reply #2 on: October 31, 2014, 06:05:43 pm »
i'd like the whole screen to be anti-aliased when i maximize the window. just like when you resize a picture in photoshop/gimp.

Texture smoothing seems to do the job but the problem is that it breaks transparent color in textures (displays some artifacts...a bit of the transp color is displayed). I'd like to use the texture without smoothing, but to smooth the renderer (all render to the screen normally then resize and anti-alias the whole thing). Is it possible ?

I tried AA with contextSettings (value to 8 ) but it doesn't smooth, it seems it justs add some artifacts
« Last Edit: October 31, 2014, 06:07:30 pm by ratatax »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: resized window: how to smooth graphics ? (resampling)
« Reply #3 on: October 31, 2014, 06:26:01 pm »
Some easy solutions:
Create different assets for different resolutions. Or catch resize events and scale your assets yourself.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: resized window: how to smooth graphics ? (resampling)
« Reply #4 on: October 31, 2014, 06:27:01 pm »
You can draw to a fixed-size sf::RenderTexture and draw it to the window smoothed with a sprite.
Laurent Gomila - SFML developer

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: resized window: how to smooth graphics ? (resampling)
« Reply #5 on: November 04, 2014, 09:10:33 pm »
You can draw to a fixed-size sf::RenderTexture and draw it to the window smoothed with a sprite.

Thank you that did the job perfectly

 

anything