SFML community forums

Help => Graphics => Topic started by: Dinocool on August 26, 2009, 09:52:39 am

Title: image tearing???
Post by: Dinocool on August 26, 2009, 09:52:39 am
my game's sprites at time's tear

as seen here: (note his head)

(http://img38.imageshack.us/img38/3433/squeebscreen1.png)

the tearing only occurs when he is standing still. also note that the head sprite does not change (the head is a different sprite). what could be the cause of this? i was wondering if was to do with float point decimal positions. i.e x = 3.5 or something
Title: VSync fixes Tearing
Post by: OniLinkPlus on August 27, 2009, 12:41:41 am
Tearing is usually caused by the Game trying to update the screen while the screen is already updating. Try enabling VSync through the Window Class.
Title: image tearing???
Post by: Dinocool on August 27, 2009, 09:03:38 am
VSYNC is on, as is frame limit 60 fps

i tried disabling vsync, then frame limit, and then frame limit AND vsync to no avail
Title: image tearing???
Post by: OniLinkPlus on August 28, 2009, 03:15:10 am
Quote from: "Dinocool"
VSYNC is on, as is frame limit 60 fps

i tried disabling vsync, then frame limit, and then frame limit AND vsync to no avail
You can't have both Framerate Limit and VSync on at the same time.
Title: image tearing???
Post by: Jaenis on August 28, 2009, 04:44:41 am
That could just be scaling and those decimal coordinates you mentioned.
Try setting Image.SetSmooth(false); for images and see if it does anything. (if I remember correctly that was set to true by default)
Title: image tearing???
Post by: Dinocool on August 28, 2009, 05:24:45 am
If you havent realised, there is no image smoothing.

and you why cant i have frame limit AND vsync?
Title: image tearing???
Post by: Core Xii on August 28, 2009, 11:33:04 am
To my understanding you can't vsync a windowed application, it has to be fullscreen.
Title: image tearing???
Post by: Ceylo on August 28, 2009, 01:13:46 pm
For sure you can.

But the problem with enabling both synchronisation and framerate limit is that you may lose much FPS.

Imagine your screen has a refresh rate of 60Hz. You set the framerate limit to 60. If everything goes very well, the screen will be refreshed 60 times per second. But if your app comes to late for the next frame, it'll skiped, but you app must wait for the next screen update. You missed one frame, meanning one frame out of 2 with 60 supposed frames per second => 30 FPS. And if your program is again too slow, it goes to 15 FPS, 7.5 FPS, etc.

Actually this will happen even if you don't set any framerate limit. But if you disable vertical synchronisation, these "steps", you can have FPS between 30 and 60 for example.
Title: image tearing???
Post by: Dinocool on August 28, 2009, 01:29:11 pm
thanks for that tip, and i've now disabled vsync, but alas there still is the issue of tearing...
Title: image tearing???
Post by: Ceylo on August 28, 2009, 01:35:13 pm
Did you have the tearing with vertical synchronisation enabled ?
Title: image tearing???
Post by: Dinocool on August 28, 2009, 01:42:04 pm
yeppers, plus a massive ammount of cpu usage.

would switching to the latest 2.0 beta help?
Title: image tearing???
Post by: Ceylo on August 28, 2009, 01:59:50 pm
I don't think so. If you have tearing even with vertical synchronisation enabled, it is not normal. Is it possible to get the sources to try out your program ?
Title: image tearing???
Post by: Dinocool on August 28, 2009, 02:00:52 pm
i dont really wanna release the source, as it contains passwords .ect

if you want you can try the game out at http://squeebs.coderzilla.com/game/squeebsrev3.rar
Title: image tearing???
Post by: Ceylo on August 28, 2009, 02:02:53 pm
I'm using Mac OS X. If you don't want to release your sources, release the sources for a minimal program reproducing the problem.
Title: image tearing???
Post by: Dinocool on August 28, 2009, 02:09:43 pm
aww ok, well do you think it could be that the x and y are at decimal positions?
Title: image tearing???
Post by: Laurent on August 28, 2009, 02:21:56 pm
Hi

You can try the SVN version (either trunk of sfml2), I made a fix for that.

Otherwise if you don't mind disabling bilinear filtering, you can use image.SetSmooth(false).
Title: image tearing???
Post by: Dinocool on August 28, 2009, 06:38:45 pm
Ok, will do laurent

just a heads up though, i dont use image smoothing, its FUGLY. specially for a sprite based pixel game. anyways i'll see what the sfml2 does for me
Title: image tearing???
Post by: Dinocool on August 29, 2009, 12:15:35 am
ok, this fixed the problem. but on another random note, my background which is 1px wide and 800 high, when stretched chages its origin by 100px, odd