Re: [AD] New mode selector, or get_gfx_mode_list(), broken [djgpp, possibly others] |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: <conductors@xxxxxxxxxx>
- Subject: Re: [AD] New mode selector, or get_gfx_mode_list(), broken [djgpp, possibly others]
- From: "Henrik Stokseth" <hstokset@xxxxxxxxxx>
- Date: Wed, 19 Sep 2001 14:22:25 -0700
Peter Wang <tjaden@xxxxxxxxxx> wrote:
> I just don't like it returning through a global. It should be like
> the bitmap interface.
>
> GFX_MODE_LIST *list;
>
> list = get_gfx_mode_list(GFX_FOO);
> if (list) {
> /* work with list */
> destroy_gfx_mode_list(list);
> }
>
> If it is really necessary to know if the call failed or not
> supported, an optional parameter:
>
> list = get_gfx_mode_list(GFX_FOO, &error);
the failed vs. supported will be useful on for example the VBE/AF driver,
where fetch_mode_list will be supported and but the lowlevel FreeBe/AF
driver cannot be loaded from disk.
if you think it matters i could rewrite it to return a pointer to a a
GFX_MODE_LIST struct like this:
---
typedef struct GFX_MODE {
int width, height, bpp;
}
typedef struct GFX_MODE_LIST {
int error; /* 0 = ok, negative for errors */
int modes; /* number of gfx modes */
int malloced; /* malloc'ed or hardcoded? */
GFX_MODE *mode; /* pointer to the actual mode list array */
} GFX_MODE_LIST;
GFX_MODE_LIST *get_gfx_mode_list(int card);
int destroy_gfx_mode_list(GFX_MODE_LIST *mode_list);
and remove the global variables.
---
> I also think an array is the right choice here, rather than a linked
> list, but I'm not sure why.
i am sure why. it's simpler and more error-safe to use an array than a
linked list. tons of pointers only has it with giving the programmer
debugging headaches. the modeselector already seems to have a bug somewhere
and that's my #1 priority. perhaps the proposed rewrite will help though?
:o)
Sincerely Henrik Stokseth.
-----------------------------------------------------------------------
E-mail: hstokset@xxxxxxxxxx Homepage: http://hstokset.n3.net