SFML community forums
Help => Graphics => Topic started by: slotdev on January 12, 2012, 04:34:28 pm
-
Hi,
I've got this wierd bug with a graphic. I display an image of a "star" which I then scale up to 300% and back to 100% over 60 frames (@30fps).
When it's over about 150% I start to see these white lines at the edge of the star image. Have a look at this graphic - white lines are highlighed in green.
(http://dl.dropbox.com/u/17968394/whitelines.jpg)
The source image is on a tile and is 112x112 in size.
Any help is much appreciated :)
Ed
-
Which version of SFML?
-
Sorry, forgot to say, SFML 2 from the 9th November 2011
-
Have you tried to turn texture smoothing off?
-
Is the star on a tilemap? That is, you are using a subrect off a texture? In that case you have 2 options;
Dont use floats for positioning
OR, cache all the tiles into separate textures at startup, and use those textures instead.
I went with the second one. A lot of people seem to have this issue, second one works best for me.
BTW Laurent; you couldn't work out something to make this issue disappear? I've seen it a lot of times on these forums now :S I understand if its a tough nut to crack, but might some internal caching system work, with parameters you could set through methods?
-
BTW Laurent; you couldn't work out something to make this issue disappear? I've seen it a lot of times on these forums now :S I understand if its a tough nut to crack, but might some internal caching system work, with parameters you could set through methods?
An internal caching system? What do you mean?
-
An internal caching system? What do you mean?
Something like sf::Texture/Sprite::CacheSubrects(bool b, sf::Uint32 limit = 48mb), and if b is true, the texture/sprite will automatically cache previously used subrects into new textures and store them, with a limit on either memorysize or texturecount, and use them when available/appropriate, instead of just drawing a part of a texture. Dont know if this would be beneficial enough to be usable (regarding performance, overhead etc), but it sure is a solution to the problem.
-
Something like sf::Texture/Sprite::CacheSubrects(bool b, sf::Uint32 limit = 48mb), and if b is true, the texture/sprite will automatically cache previously used subrects into new textures and store them, with a limit on either memorysize or texturecount, and use them when available/appropriate, instead of just drawing a part of a texture. Dont know if this would be beneficial enough to be usable (regarding performance, overhead etc), but it sure is a solution to the problem.
It's not a clean solution to the problem. Gathering several sprites into a single texture is an important optimization, it would make no sense to split textures internally.
-
It's not a clean solution to the problem. Gathering several sprites into a single texture is an important optimization, it would make no sense to split textures internally.
Indeed, hence the Texture / Sprite. Anyway, it would be 1 solution even though I'm sure there are better ones. Also I find it rather important to find one for this problem, regarding the count of independent posts on this issue.
-
I'm afraid there's no solution. Changing the behaviour would create other issues.
-
I'm afraid there's no solution. Changing the behaviour would create other issues.
Actually it's more like adding to the behaviour, and it would be optional. Think of it as a std::vector<sf::Texture> SubTextures; in sf::Texture, wich would be unused if you dont want to use it, and if you use it, stores pixeldata contained inside a subrect of the original texture.
-
That would definitely not be a good solution.
But before going further, let's wait for the answer to the first question that you asked:
Is the star on a tilemap? That is, you are using a subrect off a texture?
-
Yes, I'm using a sub rect from a larger texture.
I don't use floats for positioning, too :-)
-
I don't use floats for positioning, too
Yeah, but if you scale it will most likely end up at float coordinates anyway ;)
A quick and dirty solution would be to add a 1-pixel margin around your sprite in the texture, the same color as the border.
What about this other question?
Have you tried to turn texture smoothing off?
-
Putting a 1 pixel gap around fixed it, thanks!
Turning off texture shading isn't really an option. The user will notice the dramatic drop in quality, and it'll be reported as a "major" bug :(