Mail Archives: djgpp/1998/10/16/01:12:43
Arthur wrote:
> > PALETTE *pal;
> ^^^^^^^^^^^^
>
> Does pal need to be a pointer? I havn't done anything with palettised
> displays for ages, but ISTRT I had this problem, and fixed it by removing
> the *.
A look at the relevant typedefs will help. We have something akin to:
typedef struct { int r, g, b; } RGB;
typedef RGB PALETTE[256];
So an RGB is one triple, and a PALETTE is 256 of them. Thus, if you
declare a `PALETTE *', you'll need to allocate a memory block as big as
`sizeof(PALETTE)' for it to point to. In most cases it will be simpler
to declare a `PALETTE' directly. Also note that most (all?) Allegro
functions simply take a `PALETTE' as an arg, since passing an array
decomposes into a pointer (`RGB *', in this case).
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -