[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OpenGL vs. SDL for 2D

> Vesselin Peev wrote:

> I'd like to ask if it is possible to achieve better 2D performance
> in plain sprite blitting by using OpenGL/Mesa instead of using SDL
> on a decent 3D  graphics card?

Yes...easily.  If you load your sprites as textures (preferably packing
lots of them into large textures to avoid texture switching) and you'll
be able to push pixels hundreds of times faster than you can with the CPU
alone.  You'll get scaling, antialiasing, rotation and transparency for free
and you can also use the Z buffer to allow sprites to move behind foreground
layers without the need to worry about the rendering order.

This is nice because at the same time as getting all of these speedups and
quality improvements, your CPU is actually doing *LESS* work - so you have
more time for AI, music, etc.

> I know the inconvenience of using special dimensions for the sprites under
> OpenGL/DirectX...

Not really.  For sprites, pack as many as you can into large maps.  The large
maps have to be even powers of two - but the sprites *within* the map can be
any size you like.  (Modern nVidia graphics cards can actually do non-power-of-two
maps too - although there are some restrictions, they shouldn't affect sprites).

> but it does not really matter these days, does it? Also, older hardware
> would not be supported, but if a considerable performance boost is possible,
> that wouldn't matter, too.

Indeed.  I think it's been a reasonable decision to presume the existance of
fast 3D hardware for at least a year now.  There will be some hold-outs who
still have antique hardware - but they won't seriously reduce the size of your

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net