Re: [AD] to prefix or not to prefix (part 2) |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Peter Wang wrote:
> I like this second approach very much, but I like Laurence's naming
> better, i.e. al_set_palette6 instead of al_set_palette_old.
I agree, `6' is better than `old'.
\begin{swapping source and dest args for sprite drawing}
> - *blit* and *sprite* are on my list. The ordering of the source and
> destination takes a while to learn, and is kinda ugly.
True, this is a (slight) pain and I too still get it wrong every now and
then. Here are two suggestions for how this can be done. The routines
that I'm now talking about are draw_sprite(),
draw_[lit|trans|goraud]_sprite(), draw_sprite_[v|h|vh]_flip(),
draw_character(), and stretch_sprite() (I'll discuss rotation routines
and rle/compiled sprites later).
(I) Keep the routines as they are, except swapping the two
first arguments. One problem here is that upgrading old
code will be painful because it gives you one more thing
to keep in mind. And the compiler will not give any
warnings if you use the function the wrong way. This can
be partially solved in at least two ways:
(a) Write a tool that replaces draw_sprite(a,b,c,d) by
al_draw_sprite(b,a,c,d)
(b) Provide a macro:
#define al_draw_sprite_backwards(d,s,x,y) \
al_draw_sprite(s,d,x,y)
(II) Replace the routines entirely by routines that also take
the extra source_x,source_y,width,height arguments, as
in blit() and masked_blit(). This will probably not give
the same problems as (I), because the compiler will give
an error if you use the routines the old way. It might
require somewhat bigger changes in Allegro, but the
low-level routines apparently support this already because
they support sub-bitmaps and clipping.
I think I would personally vote for (II) because it seems to give a more
consistent API.
As for the rotation routines, I'm not sure how useful it will be to
specify the source area, and it might be quite a bit confusing to figure
out how to interpret it along with the rotations.
I think we can safely swap the arguments of RLE and compiled sprite
drawing routines, because it will give compiler errors to people who do
it the wrong way around.
\end{swapping source and dest args for sprite drawing}
Oh, and one more thing: why do `bmp_[read|write][_line|8|16|24|32]()'
use unsigned longs, and not pointers, when pointers is what they use
logically? It seems to be for historical reasons, because you give
unsigned longs to djgpp's _farnspeek*() and _farnspoke*() routines (see
aldjgpp.h, ~line 65). Unless someone knows any other reason why this
should be so, perhaps we could make them use pointers, because that's
more logical and a lot of code already has to convert it to a pointer?
If some future platform has sizeof(long)!=sizeof(void*), Allegro will
not work properly there.
> Based on the input so far (thanks everyone), this is a follow up
> proposal. Let's hope I'm not pushing my luck :-)
Excellent! I'd personally prefer 5.2a, to avoid the extra work. I think
writing the 6-bit palette functions in terms of the 8-bit palette
functions is trivial enough that we don't need to bother removing them,
and the same goes for the old vs. new sprite routines if we ever bother
changing them. But anyway, it now seems to me that we have a working
plan and can actually get to work with this prefixing stuff as soon as
4.0 is out. Good work!
Sven