Well, unless there are even more issues we’ve not yet brought up, I
think I’m starting to see the outline of a solution here; what should
and shouldn’t be in the SDL 1.3/2.0 core, how to deal with “advanced
2D” rendering (scaling, rotation, free form polygons etc), how to
deal with the Direct3D vs OpenGL issue etc.
The basic structure:
* SDL video stays focused on setting up the display
and implementing accelerated and software blits.
* More advanced 2D rendering is left to add-on
libraries that should support both OpenGL and
Direct3D, and preferably also implement software
rendering.
* 3D is handled by means of the applications
directly using OpenGL and/or Direct3D. (Direct3D
for large user base with minimal effort, OpenGL for
portability, both for maximizing the user base.)
* A nice and clean portable 3D API that runs
everywhere might be another nice project, that can
be implemented in pretty much the same way as an
advanced 2D add-on library, as long as SDL allows
add-on libs to access both OpenGL and Direct3D.
It seems like using Direct3D together with SDL is entirely doable with
SDL 1.2 already, so I forsee no major issues there. So, I think we
could in fact have the Advanced3D add-on lib work with SDL 1.2 as
well as SDL 1.3/2.0 with little extra work.
As to the API and feature set, I’m thinking OpenGL minus all things
strictly 3D related. Matrix based transformations? I dunno… Nice
and handy (if you know your way around the maths, at least), but
maybe overkill for 2D graphics in general? Anyway, something like
this:-----------------------------------------------------
/* Primitives for A2D_Begin() */
typedef enum
{
A2D_POINTS,
A2D_LINES,
A2D_LINE_LOOP,
A2D_LINE_STRIP,
A2D_TRIANGLES,
A2D_TRIANGLE_STRIP,
A2D_TRIANGLE_FAN,
A2D_QUADS,
A2D_QUAD_STRIP,
A2D_POLYGON
} A2D_Primitives;
/* Modes for A2D_FilterMode() */
typedef enum
{
A2D_NEAREST,
A2D_NEAREST_MIPMAP,
A2D_LINEAR,
A2D_LINEAR_MIPMAP,
A2D_CUBIC,
A2D_CUBIC_MIPMAP
} A2D_FilterModes;
/* Modes for A2D_BlendMode() /
typedef enum
{
A2D_OPAQUE, / Opaque rendering /
A2D_MASK, / Copy if src alpha > 0 /
A2D_SRCALPHA, / Source alpha blending /
A2D_DSTALPHA, / Destination alpha blending /
A2D_ADD, / Additive blending /
A2D_SUBTRACT, / Subtractive blending /
A2D_MODULATE / Modulation (multiplication) */
} A2D_BlendModes;
/*
- Select target surface for subsequent rendering.
*/
void A2D_Target(SDL_Surface *target);
/*
- Select texture for subsequent rendering.
- Pass 0 for ‘texid’ to disable texturing, for
- same results as using an opaque white texture.
*/
void A2D_Texture(SDL_TextureID texid);
/*
- Set texture filtering mode.
*/
void A2D_FilterMode(A2D_FilterModes fm);
/*
- Set rendering blend function.
*/
void A2D_BlendMode(A2D_BlendModes mode);
/* Rendering functions */
void A2D_Begin(A2D_Primitives prim);
void A2D_Vertex(float x, float y);
void A2D_TexCoord(float x, float y);
void A2D_ColorRGB(Uint8 r, Uint8 g, Uint8 b);
void A2D_ColorRGBA(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
void A2D_End(void);
/*
- Ensure that changes to the current target surface are
- made visible.
*/
void A2D_Update(void);
/*
- Quickly fill the current target surface with the
- specified color.
*/
void A2D_Clear(float r, float g, float b, float a);
//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 --’