[SDL] Follow up (more details, test results, replies)

Scott Harper lareon at comcast.net
Tue Apr 17 23:54:20 PDT 2007


On Apr 17, 2007, at 9:25 PM, Leon Marrick wrote:

>                     For starters, I didn't explain why using OpenGL  
> is flat out for my
> project.  OpenGL is a large, complex graphics library that  
> virtually everyone
> likely to modify my code is 1) not going to have, 2) not going to  
> know much
> about, and 3) not going to spend the considerable amount of time  
> needed to set
> up and understand unless no other alternative exists.  Because  
> multiple
> alternatives /do/ exist, discussion of OpenGL has no bearing.
>      I ask people who post OpenGL solutions on this - not an OpenGL  
> mailing
> list - to remember why a lot of us come to SDL.  Not to find a  
> wrapper around
> any other library, but to find a Simple, Direct, Multimedia library  
> that we
> hope will be a complete (or nearly complete) solution for most  
> simple cross-
> platform 2D projects, thus freeing us from having to juggle any  
> other library.
>
>      SDL isn't a complete solution for me and my project.  The  
> major reason is
> speed.  To attain anything close to the performance of the several  
> single-
> platform ports of my project (Mac, X11, and Win32 being three), I  
> must solve
> at least one of two problems:  Get text onto the application SDL  
> surface
> faster, or figure out why SDL_Update_Rects is so bloody slow on all  
> tested
> machines and using all tested drivers.

The reason SDL is so slow, I think, is very simple.  It's not using  
your video card.  Correct me if I'm wrong, but I believe that because  
not all systems can be assumed to have video cards (especially in the  
realm of handheld devices, an area which while perhaps not initially  
intended for, SDL has left itself open to porting to), SDL does not  
default to using your video card.  All of the blitting, drawing,  
blending, etc... are done on your processor and ONLY your processor.   
That's why everyone was suggesting OpenGL as an addition to direct SDL.

While I understand the desire to keep things as simple as possible, I  
feel like I should point out that SDL is in essence a "wrapper"  
around a bunch of very system specific libraries to accomplish the  
goal that you can write one piece of code and it runs basically the  
same on many different setups.  I'm sure you realize the difference  
and just phrased it mistakenly, but in your usage the problem is that  
OpenGL is the only thing which I WOULDN'T call a wrapper.  OpenGL is  
as cryptic as is it because it gets down and dirty with the video  
hardware, and was not written to be elegant to understand, but rather  
FAST, which is what you're asking for.

OpenGL will not run on absolutely all systems, especially mobile  
ones, where the idea of a graphics accelerator is so obscure as to  
pass into the realm of the absurd.  SDL, however, by not relying on  
having a video card or OpenGL, can still be run just as effectively  
on many handheld/mobile systems.

So it seems to me, though I'm not by ANY means an expert in this  
area, that you may well have reached the maximum of performance at  
the limitations you've set for yourself.  AFAIK, when writing text  
you either have to have the text pre-rendered to a file and draw  
that, or have all your characters stored as small images and then  
access them according to whichever character you need, for all  
characters which might need displaying that frame.  If you have a lot  
of characters, as you've discovered I think, that can involve a LOT  
of function calls, and when drawing with the processor, that can take  
a while.  ("a while" being relative here)

The only suggestion, which I hope you will take as an apology for  
what has probably been a rather blunt and perhaps a bit offensive- 
sounding (though I assure you none was intended) email is that you  
may be able to save yourself some time in drawing at the expense of  
memory.  You could pre/cache the text you need drawn, once drawn the  
first time, into images stored in memory.  That way when you need to  
redraw the text, you can simply draw the cached image without need to  
redraw every last character every frame, and I think that could save  
you some time between frames.  Though your initial draw may well take  
as much time as every redraw you're doing now.  I'm not an expert at  
this as I've said before.  I generally use OpenGL, and have SDL as my  
backend for user input, sound, and simply setting up a drawing area  
for my projects.

>
>      The source provided makes it easy to determine what problem is  
> more
> important.  Or not, as you will see below.
>
>
> Kein-Hong Man,

-- Scott


More information about the SDL mailing list