Count me in. I have a lot of 2D OpenGL experience (if I may say so
myself
:). I would only be interested in this if it were to be built into SDL
itself though. An auxilliary library like SDL_opengl2d would just not do
for
me.
That’s what I have in mind too. Making OpenGL a backend (or target) just
like X11, svgalib or fbcon.
Well SDL itself chooses between those backends. The OpenGL ‘backend’ should
be
somthing that the programmer will choose. Why? Well SDL can’t know
beforehand
whether you are doing 2d blits along with actual pixel access or just 2d
blits.
The former would be a lot faster in X11, DX, etc., the latter would be much
better
off in OpenGL. So I think the current SDL_SetVideoMode( width, height, bpp,
SDL_OPENGL | moreflags ) interface should remain intact.
So when an OpenGL display mode gets initialized, all SDL hardware
surfaces
should be created as 2D textures and blits would be done with textured
quads. Software surfaces should stay in system memory and be copyed into
textures when blitting.
Exactly. You could also take advantage of accelerated alpha-blending, or
apply anti-aliasing to the final rendered image. Needless to say how
fast it will be with a good video card.
Yes, this is what I am doing in one of my unfinished games. I get over 700
fps
on my system with lots of sprites with alpha blending and rotation and
everything.
If this idea makes it into SDL 1.3, I can’t imagine how awesome it would be.
In a non-OpenGL display mode everything should of course function as
normal,
with DirectDraw / X11 / and the rest.
Right. Problems might occur if the programmer uses OpenGL functions
along with the OpenGL backend, maybe. But I’m not even sure myself.
If the OpenGL ‘backend’ is implemented as I said above, then it would not
interfere. The progammer just has to make sure the 3d stuff is rendered
first
followed by the blits. The otherway around could have some unwanted results.
(Especially depth buffer issuess I’d reckon.) However, if it is really a
backend like X11 and such, then it might interfere drastically.
But perhaps such a system is already planned for SDL 1.3?
No idea. I don’t even know whether plans for 1.3 started or not. Anyone?
According to the SDL General FAQ, “SDL 1.3 will be a near full rewrite of
the SDL functionality, based on what we’ve learned over the past four
years.”
David Olofson once made a quick hack to use OpenGL rendering within SDL
for his Kobo Deluxe game. It’s not exactly a backend, as it’s included
with Kobo sources and redefines some SDL functions in practise. But it
worth a look anyway. You can get Kobo source at
http://olofson.net/skobo/. Then try ./configure --help for the args to
pass to use the hack. (SDL must be built with OpenGL capability of
course). He mentions it here:
http://www.libsdl.org/pipermail/sdl/2001-December/040562.html (the rest
of the thread is quite interesting, too)
Interesting. I’ll have to give this a look.
If we could start hacking this around, it would be nice. Would be better
if we could have someone who knows a bit SDL’s internal structure, as
it’s not documented as far as I know. And we’d have to mess with SDL’s
guts to make it a backend.
Well I’ve already been reading through the SDL source a lot, but as the
FAQ states, “SDL 1.3 will be a near full rewrite” so the architecture could
change a lot.
But Sam Lantinga, the author of SDL, hangs around this mailinglist as well,
so he’s bound to join the discussion sometime.
So, interested?
Yep, said so before.
Dirk Gerrits