What I’m saying is, simply suggesting OpenGL for anything but the
most
basic 2D rendering isn’t very helpful. It works for anything but
Windows - which means people on a tight budget, doing anything
other
than retro style and/or low bandwidth games, have to go with
Direct3D
for rendering.
So for SDL 1.3, would an equivalent SDL_DIRECT3D flag to match
SDL_OPENGL be useful?
Yes - that, and maybe some “semi private” interfaces to allow add-on
libs to integrate better with the backends. I’m thinking “backend
plugins” that can hook into the SDL API calls, wrapping or replacing
some of the backend calls.
For example, say the SDL 1.3 API doesn’t have rotation and you want to
implement an add-on lib/backend plugin that adds that feature. You’d
hook into the backend calls that are used for SDL_BlitSurface() and
add implementations that implement rotation. You could do it for
OpenGL only, and/or Direct3D and/or software - the extension should
only be activated when a supported backend is used, modulo some
optional “slow but correct” software fallback, perhaps. Then you add
some custom calls to set up the rotation parameters.
Of course, it’s possible to do this with an application level wrapper
(ie use SDL_MyBlitSurface() instead of SDL_BlitSurface()), but that
means you can’t directly have add-on libs (SFont, for example) render
through your feature extended calls.
You’re definitely going to end up with an #ifdef
WINDOWS somewhere in your app if you use it, of course, but if you
need to get at Direct3D functionality for all the reasons that game
developers already write multiple renderer codepaths, it might be
useful (and save you a lot of the D3D boiler plate initialization
code).
Also, if add-on libs in the form of backend extensions/replacements
are supported, you can keep the #ifdef WINDOWS mess in reusable
modules.
Maybe something like this “Advanced2D” I’m talking about will
eventually become the defacto standard way of doing “almost 3D” in a
portable way with SDL. (Add-on library with software, OpenGL and
Direct3D backends.) It’s there if it does what you need, no bloat in
the SDL core, and you can use something else, or use Direct3D and/or
OpenGL directly if you prefer.
An “Advanced2D” API could (and some would probably suggest that it
should) be built into SDL - but there are many ways to design such
an API, but no single, obviously correct way. Should it be usable
with 2D-only acceleration? Is “fast” software rendering a
requirement? Subpixel accuracy? Antialiazing? How many features until
everyone goes “Just use OpenGL!”?
If it’s a separate project (or several projects with different goals),
you can use it as is, modify it, hack your own, use somebody else’s
hacked or independent version, or whatever. Some developers might
want to go all the way to a full blown 3D API, eliminating the need
for Direct3D + OpenGL support for most 2D and 3D applications. Others
might just want plain fast zoom and rotation with h/w acceleration
where available. Same thing; just a matter of feature set.
I don’t think it’s reasonable to even think about a total
abstraction of GL vs D3D inside SDL…both APIs are massive and
stand on their own.
Right; that would be a massive project, and then there’s the learning
curve, the “But I already know OpenGL/Direct3D/whatever” factor
etc… Lots of work, and not very likely to become widely used.
But it might be nice to have the option to write your own Direct3D
path in your app and otherwise use the SDL event queue, joystick
support, etc, regardless of what API (OpenGL, Direct3D, or SDL’s 2D
API) gets the bits to the framebuffer for a given run. Behind the
scenes of the 2D API, SDL 1.3 already uses Direct3D if appropriate,
so it’s just a question of exposing it to the application layer.
Yes, exactly.
Not sure if that’s evil or not. Just wanted to throw the idea
out there.
Well, as far as the “hardware acceleration required” applications go,
the evil originates from a certain company. The correct solution for
these applications is OpenGL - but it doesn’t quite work that way.
I’m sure it will result in apps that people are excited to find “use
SDL” and then find they don’t compile on Linux or Mac OS X, because
it’s just a mass of Direct3D code under the hood.
I’m hoping that something like “Advanced2D” might eliminate the
majority of such cases. After all, most of these applications just
want some accelerated alpha, additive blending and scaling. Moving
all the way from the nice and simple SDL 2D API to native Direct3D
just to add that is something I believe most developers would like to
avoid if possible.
Then again, I’m not sure playing API nanny is really our job,
either.
I don’t think that’s an option anyway, as it is. I’ve seen quite a few
posts from independent game developers that would like to use
something like SDL and some nice scripting language, but finding that
it’s not really an option. Telling these people they can’t use
Direct3D just means they won’t use SDL at all.
//David Olofson - Programmer, Composer, Open Source Advocate
.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Thursday 02 August 2007, Ryan C. Gordon wrote: