[cairo] SVG Spacewar
Nigel Tao
nigel.tao at myrealbox.com
Thu Mar 31 05:05:35 PST 2005
Hello all. I've been playing around with Cairo lately, and have made a
little re-make of the classic Spacewar game, but with SVG-like graphics.
It's more of a proof-of-concept at this stage than a full-fledged game,
but I think that it's quite playable.
I put up a home page at the only publicly available web space that I
currently have (under the sourceforge page of another project of mine):
http://browserbookapp.sourceforge.net/svgspacewar/
but I would love to see this live in the cairo-demo module in CVS, if
the powers that be are happy with that (it's pretty small, just 1100
lines of C and a Makefile). Otherwise, I'll get around to setting up a
new SF project.
Feedback most welcome. This is my first venture with Cairo, and I am
not 100% confident with C either, so I might be making simple mistakes.
In particular, like all game programmers, I would like it to run as fast
as possible, and that means employing glitz. But how do I know if I'm
running glitz (I downloaded the snapshot and I think it's installed, but
my CPU seems to be rather busy)? If I'm not, how do I switch to glitz?
If it matters, I am running Fedora Core 3 with nVidia binary drivers.
But also, scaling the whole thing by a small-ish factor (x1.25, try
pressing "[" or "]" when playing) or enlarging the app's window seems to
bring it to its knees (100% CPU use, and "top" just reports the culprit
as 99% "X") - certainly it doesn't seem like an O(N^2) kind of thing.
Any hints on how to profile, or what I'm doing wrong?
Animation is done using gtkcairo, and I have just done the simplest
thing (like the sproing demo) and set up a g_timeout_add to
gtk_widget_queue_draw every 25ms - but is there a better way? One that
will allow higher (or maximum?) frame rates, and without artifacts like
shearing?
Source code released under the GPL. Built against the cairo 0.4.0
snapshot.
tia,
Nigel.
More information about the cairo
mailing list