Re : sfml comment: Was: 2D graphics with OpenGL

What do you mean by “idle capabilities”, was it working for nothing ?

— En date de?: Ven 19.6.09, mattmatteh at mac.com a ?crit?:de: mattmatteh at mac.com
Objet: [SDL] sfml comment: Was: 2D graphics with OpenGL
?: “A list for developers using the SDL library. (includes SDL-announce)”
Date: Vendredi 19 Juin 2009, 16h06

I have used sfml once, not that bad, needs work, not as mature as sdl.

In particular, its lacking idle capabilities.? Cpu was always maxed.

matt

On Fri, 19 Jun 2009, Zolt?n K?csi wrote:

there seem to be a great competitor in the arena of OpenGL based
libraries with general purpose multimedia functions, called SFML.

Yes, but SDL is C, while SFML is C++. It’s relatively easy to use C
functions from C++, but it’s not that simple the other way around.

Zoltan
-----La pi?ce jointe associ?e suit-----


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

What do you mean by “idle capabilities”?

It lacks an equivalent to SDL_WaitEvent.

(I don’t consider this to be a big drawback for games)

Stefan

Heh, I just ran a search and found a simple benchmark that the SFML author used:

It doesn’t work with the latest version from Debian repos, so I just
commented some of the broken parts and fixed a couple of things (like
how it always says “SFML is X% faster” even is it is slower…):
http://pubpages.unh.edu/~jmb97/bench-sdl-sfml-j.zip

Sorry, no Makefile, but the library stuff is listed in the ‘com.pile’ file.

Though this was done in mid '07, here are my results. At the time of
the discussion about this benchmark, the author had not much clue
about how to use SDL, so I figure there’s some stuff to improve on in
the code… Especially since he pits hardware-accelerated SFML
against software SDL (!). Due to that, the last two tests are very
telling… Plus, he uses SDL_gfx’s rotations instead of SGE, which is
faster. At any rate, I think you guys are asking for a rematch with
SDL 1.3.

1/ Test : sprites
SDL displayed 7 frames
SFML displayed 50 frames
–> SFML is 714% as fast as SDL

2/ Test : alpha-blended sprites
SDL displayed 4 frames
SFML displayed 51 frames
–> SFML is 1275% as fast as SDL

3/ Test : rotating sprites
SDL displayed 2 frames
SFML displayed 128 frames
–> SFML is 6400% as fast as SDL

4/ Test : static text
SDL displayed 1346 frames
SFML displayed 1001 frames
–> SFML is 74% as fast as SDL

5/ Test : dynamic text
SDL displayed 904 frames
SFML displayed 856 frames
–> SFML is 94% as fast as SDL

Jonny D

*I should also point out the granularity of the comparisons: 2 frames
vs 128 frames gives awful precision.

Jonny D

What do you mean by “idle capabilities”?
It lacks an equivalent to SDL_WaitEvent.

(I don’t consider this to be a big drawback for games)

That is a huge drawback for any and all applications. If an app or
game needs it, fine use all the cpu.

Sometimes I work on my laptop, I would rather not waste the battery life for a lazy
coded game. And I hate it when the fan goes on.

And now that computers are finally attempting to be efficient, the
application should be too when possible.

Think about netbook, cell phone, pandora handheld. This is not just for
at home with the hot energy wasting x86.

mattOn Fri, 19 Jun 2009, Stefan Monov wrote:

It lacks an equivalent to SDL_WaitEvent.

(I don’t consider this to be a big drawback for games)

That is a huge drawback for any and all applications. ? If an app or game
needs it, fine use all the cpu.
No one says use all CPU.
Insert carefully timed sleeps at every frame to ensure constant
framerate, and voila, you’re using no more and no less than the CPU
time you need.

This assumes a fairly complex game that does need to redraw and
recompute logic constantly. If you’re writing solitaire, then by all
means use something that has blocking wait functionality…

Stefan.

Insert carefully timed sleeps at every frame to ensure constant
framerate, and voila, you’re using no more and no less than the CPU
time you need.

And then you get uneven latency. For the local case, it’s okay,
because they’re not going to see the intermediate steps in-between
frames, but with a networked multiplayer game, that’s basically
building in extra lag…

Or you could SDL_WaitEventTimeout, and get it all: low CPU usage,
constant framerate and good latency.On Fri, Jun 19, 2009 at 1:27 PM, Stefan Monov wrote:


http://pphaneuf.livejournal.com/

Pierre Phaneuf schrieb:> On Fri, Jun 19, 2009 at 1:27 PM, Stefan Monov wrote:

Insert carefully timed sleeps at every frame to ensure constant
framerate, and voila, you’re using no more and no less than the CPU
time you need.

And then you get uneven latency. For the local case, it’s okay,
because they’re not going to see the intermediate steps in-between
frames, but with a networked multiplayer game, that’s basically
building in extra lag…

Or you could SDL_WaitEventTimeout, and get it all: low CPU usage,
constant framerate and good latency.

SDL_WaitEventTimeout() sounds like a very good idea !
(I am currently using the “timed sleep” approach to have an idle()
callback in my GUI)

which SDL version implements this ? (it doesn’t seem to be in 1.2.13 so
I guess it’s in the 1.3 branch?)

Greetings,
Bastian

(…and hey, I think this is my first post here so Hello Everyone! :))

Hello!

Welcome to the list. But… SDL 1.3 “branch”? My friend, SDL 1.3 is the trunk :slight_smile:

And yes, SDL_WaitEventTimeout() is in 1.3:

http://svn.libsdl.org/trunk/SDL/include/SDL_events.hOn Fri, Jun 19, 2009 at 7:10 PM, Bastian Spiegel wrote:

SDL_WaitEventTimeout() sounds like a very good idea !
(I am currently using the “timed sleep” approach to have an idle() callback
in my GUI)

which SDL version implements this ? (it doesn’t seem to be in 1.2.13 so I
guess it’s in the 1.3 branch?)

Greetings,
Bastian

(…and hey, I think this is my first post here so Hello Everyone! :))

Note: the current implementation of both SDL_WaitEvent and
SDL_WaitEventTimeout doesn’t actually perform a blocking wait.
Instead, it polls in a loop every 10ms until an event is received. I’m
not sure why this is; it always seemed suboptimal.

Stefan

Note: the current implementation of both SDL_WaitEvent and
SDL_WaitEventTimeout doesn’t actually perform a blocking wait.
Instead, it polls in a loop every 10ms until an event is received. I’m
not sure why this is; it always seemed suboptimal.

Yeah, I had started a patch to fix this, but my hard drive committed
suicide not long ago… Should have used git-svn!On Sat, Jun 20, 2009 at 12:44 PM, Stefan Monov wrote:


http://pphaneuf.livejournal.com/

Pierre Phaneuf schrieb:> On Sat, Jun 20, 2009 at 12:44 PM, Stefan Monov wrote:

Note: the current implementation of both SDL_WaitEvent and
SDL_WaitEventTimeout doesn’t actually perform a blocking wait.
Instead, it polls in a loop every 10ms until an event is received. I’m
not sure why this is; it always seemed suboptimal.

Yeah, I had started a patch to fix this, but my hard drive committed
suicide not long ago… Should have used git-svn!

Pierre: I hope you will then have a backup of that svn server :*)

I like to keep around frequent snapshots of my entire sourcetree (on hd,
usb stick, dvd).
…when it comes to your own source codes you just cannot be paranoid
enough…

on topic: getting SDL_WaitEvenTimeout() implemented efficiently would be
really nice to have.
…using usleep() or Sleep() /SDL_Delay() sure is suboptimal
although…in practice it works very well already, at least on current
x86 pcs…
(probably not so good on “slow” devices where context switching takes a
considerable amount of time)

Pierre: I hope you will then have a backup of that svn server :*)

There’s usually a “good” server backing the Subversion repositories,
and when I use git-svn, I replicate between my workstations/laptops
fairly naturally, as I work on all of them.

on topic: getting SDL_WaitEvenTimeout() implemented efficiently would be
really nice to have.
…using usleep() or Sleep() /SDL_Delay() sure is suboptimal
although…in practice it works very well already, at least on current x86
pcs…

Even on a relatively fast x86 machine, you can totally see the uneven
latency in event handling with the small test program I posted a while
ago (as an attachment):

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2008-May/065067.htmlOn Sat, Jun 20, 2009 at 10:51 PM, Bastian Spiegel wrote:


http://pphaneuf.livejournal.com/