Mail Archives: djgpp/1999/01/10/13:45:36
--- Original Message ---
From: Malefactor <lslavoti AT mail DOT bcpl DOT net>
Time: Sat, 9 Jan 1999, 20:14:34
> When I try to use draw_lit_sprite or draw_gouraud_sprite in my
>program it crashes with a page fault or general protection fault.
>RHIDE's Call Frame Traceback window refer's to either of the sprite
>drawing functions. I'm using Allegro v3.1. I made a small program
>using just the draw_lit_sprite function, and snipped it here incase I
>left something important out. If anyone has any suggestions I'd like
>to here them. Let me know if more info is needed.
[snip]
Are you checking the return values of the functions? The code you used
just assumes that everything works correctly; this may be because it's
just a condensed sample.
For instance:
int main(void)
{
int result = 0;
/* Attempt to initialise Allegro */
result = allegro_init();
if(result)
{
printf("Error initialising Allegro: %s\n", allegro_error);
return result;
}
/* Attempt to set gfx mode */
result = set_gfx_mode(...);
if(result)
{
/* ... */
}
/* ... */
}
This way, the program fails with a useful error message anytime a call
to one of Allegro's functions fails. Note that you also need to check
that create_bitmap() and load_pcx() do not return NULL pointers, which
they do on failure.
HTH, and bye for now,
--
Laurence Withers, mailto:lwithers AT lwithers DOT demon DOT co DOT uk
Integrated Peripherals Operating System Project Leader || OPES Project
Projects' homepage is at: http://www.lwithers.demon.co.uk/ Leader
- Raw text -