So, quietly ignoring my issues with 1.2 crashing and 1.3 having problems
with keyboard input…
I’m looking for hints and tips to try to speed things up a little…
However the issues I’m facing could quite possibly be due to my own
naiveity… Long time C programmer here, but very new to SDL…
My little application (runs under Linux), opens a window, plots points,
draw lines and prints text from a bitmap font to the screen. Works great,
but it seems I have a choice of “fast” mode whereby I draw to the surface
then update it to the screen in “batch” mode, or “slow” mode whereby I
draw to the surface and update to the screen after every point/line…
e.g. this trivial bit of code to draw moire patterns:
Fast:
for (x = 0 ; x < 640 ; x += 3)
{
drawLine (320,240, x, 0) ;
drawLine (320,240, x, 479) ;
}
SDL_UpdateRect (myScreen, 0,0,0,0) ;
Slow:
for (y = 0 ; y < 480 ; y += 3)
{
drawLine (320,240, 639,y) ;
drawLine (320,240, 0,y) ;
SDL_UpdateRect (myScreen, 0,0,0,0) ;
}
Same for text and scrolling the screen - if I do an UpdateRect after every
character, it’s slow, but after every line it’s faster (although I
possibly could be much cleverer with characters and only update the box of
the actual character, however…)
Doing graphics like this on little embedded sytems is something I’ve been
doing for a very long time - and in these systems, poking pixels directly
into the hardware is usually the “done thing”, but this is my first time
with SDL and I’m wondering if I’m missing a trick or 2… Or maybe I’ve
just not looked hard enough yet…
My initialisation is:
if ((myScreen = SDL_SetVideoMode (screenWidth, screenHeight, 32, SDL_HWSURFACE)) == NULL)
… etc.
it seems my hardware doesn’t support HWSURFACE, so it defaults to
SWSURFACE anyway.
I suspect my application is somewhat different from most applications -
I’m drawing/updating a tiny bit of the screen at a time and want it
visible ASAP without waiting for a vertical refresh/UpdateRect which is
slowing things down somewhat, rather than re-rendering large patches of it
and I appreciate issues with vertical refresh and tearing, however for now
I’m not letting them concern me…
So any hints or tips would be appreciated, even if it’s nothing more than
"that’s the way it is".
Thanks,
Gordon