RE: [AD] Proposed changes for Allegro 5 (6?)

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


Title: RE: [AD] Proposed changes for Allegro 5 (6?)

Bob writes:
>>>  - `bmp_read8()' & co currently use longs instead of pointers.
>>
>> The thinking behind using longs is that this makes the pointers
>> opaque, ie. can't be dereferenced directly by the user
>
> Those functions are of the fairly advanced level, so I don't
> see users who haven't understood pointers use them :)

The problem is not so much programmer ignorance, as portability.

On Windows or Unix, it would work fine if I was to write:

      unsigned char *address = (unsigned char *)bmp_write_line(bmp, y);
      bmp_select(bmp);
        address[x] = color;
      bmp_unwrite_line(bmp);

But this code will fail miserably on any platform where the
bitmap memory is not part of your standard address space.
Currently I think DOS is the only such platform supported
by Allegro, but this is also true for many embedded systems,
consoles, etc, so it would be a shame to lose the portability
of always accessing vram using the read/write macros.

Even a very experienced programmer, when presented with a
char * that references video memory, is likely to use *ptr
as a way to access this memory, and when this works for them,
will assume that this access method is correct. They will
then be unpleasantly surprised when this code fails to work
on other platforms.

If the address is not a pointer type, this makes it far more
obvious that it must be accessed in a special way, so people
are more likely to produce correct and portable code.



--
Shawn



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