[AD] [Alleg5][GFX] Format specification

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I'd like to propose an alternative way of specifying bitmap formats in the new graphics API.

Currently, we have a bunch of enums ORed together:

 * Allegro supports several color spaces. The color space is
 * specified by the following flags in the format parameter:
 *   - AL_RGBA
 *   - AL_RGB
 *   - AL_PALETTE
 *   - AL_YUV
 *   - AL_LUMINANCE
 *
 * These flags select the color space but not the color depth. The depth
 * is selected via one of the following flags, which are combined with
 * a binary OR (|) with the previous ones:
 *   - AL_COLOR_8
 *   - AL_COLOR_8_8_I
 *   - AL_COLOR_5_5_5       (==  AL_COLOR_15?)
 *   - AL_COLOR_5_6_5       (==  AL_COLOR_16?)
 *   - AL_COLOR_8_8_8       (==  AL_COLOR_24?)
 *   - AL_COLOR_8_8_8_8     (==  AL_COLOR_32?)
 *   - AL_COLOR_10_10_10
 *   - AL_COLOR_10_10_10_2
 *   - AL_COLOR_16_16_16
 *   - AL_COLOR_16_16_16_16
 *   - AL_COLOR_32_32_32
 *   - AL_COLOR_32_32_32_32 (== AL_COLOR_128?)
 *
* The color depth specification can be augmented by the following flags, which
 * are combined with a binray OR (|) with the previous ones:
 *   - AL_COLOR_INTEGER
 *   - AL_COLOR_FLOAT


Instead, I'd like to move towards a more OpenGL-like system: There ought to be 3 separate format identifiers: <internalformat>, <format> and <type>.

When creating a bitmap, users specify only an <internalformat>, which is essentially a hint to Allegro as to what format to actually pick. The list of internalformats is much more contrained than all the possibilities available above. For example: AL_RGBA8, AL_RGB5_A1, or AL_RGB32F, or even AL_YUV_422.

However, when data supplied directly by the user needs to be provided to Allegro (ie: through al_bitmap_write*() and al_bitmap_read*()), then separate <format> and <type> parameters can be queried so that users can know how to provide the necessary information to Allegro.

For example, AL_RGB32F bitmaps would return a format of AL_RGB and a type of AL_FLOAT32. Or perhaps a format of AL_BGR, on platforms where the component ordering is reversed.

Writing the bitmap one pixel at a time, through al_put_pixel() / al_make_rgb*() would still not need to know the bitmap format, from the users' perspective.

I think the benefit here is reducing parameter validation complexity, and format explosion.

Thoughts?








Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/