[SDL] SDL performance over OpenGL performance.

Ryan C. Gordon icculus at icculus.org
Sat Jun 2 21:52:57 PDT 2007


> So if I want my 2D game to go fast, I need to use OpenGL hardware surface?
> It sound quite a heavy solution.
> To rewrite a full SDL only game to an OpenGL-SDL it takes a lot of 
> rewrite no?

Depends on the game. In most cases, the 2D path is fast enough, though, 
and some small optimizations can handle any problems you're currently 
having.

> Why doesn't SDL have hardware acceleration implemented in itself? (I 
> haven't seen this question in the FAQS).

It does, but most video targets don't support it. You can get hardware 
surfaces from, say, DirectX, and as long as everything is in a hardware 
surface, you can blit between them with hardware acceleration.

> It would be great since on some platform, SDL is port but not OpenGL (so 
> if there isn't OpenGL ... no hardware acceleration).
> 
> I've always though of OpenGL for 3D and SDL for 2D ...

Increasingly, OpenGL and Direct3D are going to be the best way for 2D, 
too. The "hardware accelerated" 2D interfaces don't exist in most 
targets (including Mac OS X and Linux), and on Windows, DirectDraw has 
been deprecated for literally years now. Apple and Microsoft both 
recommend you use the 3D interfaces, even for 2D work, if you can.

In SDL 1.3, we can use Direct3D or OpenGL behind the scenes with the 
current 2D SDL APIs (and fall back to a software renderer when we 
can't). In 1.2 there's a patch floating around called "glSDL" if you 
want to experiment.

But again, for most 2D software, you can still make it usable. Usually 
you just have to make sure you preconvert your surfaces, and one or two 
other minor things, to remove most reasonable bottlenecks.

--ryan.




More information about the SDL mailing list