As you might have noticed, Kobo Deluxe 0.3 contains a half finished hack
that makes it possible to transparently make the SDL 2D calls use
"native" OpenGL for rendering. There are some problems that I’ll fix
sooner or later, but as the game is quite playable with SDL 2D even on a
Win95/P-133 machine (in 320x240 mode, of course…), it’s not top priority.
Anyway, the major reason for using an OpenGL rendering layer or backend
for 2D is performance. Many SDL targets are incapable of using busmaster
DMA for system memory to VRAM blits, and some can’t even accelerate
VRAM->VRAM blits. AFAIK, no alpha blending acceleration is supported.
This makes SDL 2D rendering very slow on those targets, compared to what
you get with for example SDL on DirectX/Win32.
Just to make things even worse, you’re practically forced to use at
least 640x480 these days, as resolutions like 320x240 are considered
exotic and/or obsolete by many users and distro packagers. Getting
320x240 to run full screen on XFree86 usually requires manual hacking of
XF86Config.
Meanwhile, many of the targets with those problems do support
accelerated OpenGL. Using OpenGL for rendering not only means you get
much faster rendering, but also gives you accelerated alpha blending at
little extra cost.
Performance example: SDL ‘testsprite’ runs at 60 fps with 2000 sprites in
640x480x16 on my P-III 933 + Matrox G400 MAX; Linux with XFree86 4.1.x.
On average, OpenGL rendering is about 3 times faster than SDL software
rendering on that machine.
Now, those of you who believe this is more interesting than nicer menues,
scrolling radar screen and a real highscore table in Kobo Deluxe, tell
me, and I might reorder the TODO file a little.
Or just go fix the bugs…! The code is in Kobo Deluxe - just
’./configure --enable-opengl’, and you have an addictive test suite.
Info for hackers follows.
—8<-------------------------------------------------------------------
1) Rip the files glSDL.h and glSDL.c from Kobo Deluxe 0.3.
2) Include glSDL.h instead of SDL.h.
3) Make sure that glSDL.c is compiled and linked, and that
you link with OpenGL. Of course, your SDL library needs
to have OpenGL support compiled in!
4) Add SDL_GLSDL to the flags argument of SDL_SetVideoMode(),
to enable 2D-on-OpenGL mode.
5) If you get SDL_Surfaces from *any* code that isn't compiled
with glSDL.h instead of SDL.h, you *must* "fix" those with
the GLSDL_FIX_SURFACE() macro!
Note that blitting from the screen is not implemented (which does not
mean that alpha blending is disabled - it’s done in h/w instead), and
that the current version of the hack won’t work on platforms with 64 bit
pointers. Also note that blitting from sub-rectangles of surfaces to the
screen is broken (silly math bug, I think), and that something weird is
going on when manipulating off-screen surfaces (might have to do with
surface locking).
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -’