www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/16/01:12:43

Sender: nate AT cartsys DOT com
Message-ID: <3626C287.138BD268@cartsys.com>
Date: Thu, 15 Oct 1998 20:50:31 -0700
From: Nate Eldredge <nate AT cartsys DOT com>
X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.35 i486)
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Allegro mode 13h
References: <000001bdf84d$bd6dc5a0$594e08c3 AT arthur>
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019