Mail Archives: djgpp/1999/10/04/11:45:19
Stefan Viljoen writes:
> it seems that if you use the VESA1 driver in set_gfx_mode for
> Allegro
It is usually a bad idea to use any specific graphics drivers
in your call to set_gfx_mode(), because that's a sure way to
make sure that your program won't work on other machines that
need to use some other driver. Pass GFX_AUTODETECT, and then
if you need to override the default on your particular machine,
do that by editing your local copy of allegro.cfg rather than
your program source code.
> and use the 640x480x16 bit color depth, and want to use RLE
> sprites, DO NOT load the datafile before attempting to set
> the gfx mode!
Yup. It actually tells you this in allegro.txt:
DATAFILE *load_datafile(char *filename);
Loads a datafile into memory, and returns a pointer to it, or NULL on
error. If the datafile has been encrypted, you must first use the
packfile_password() function to set the appropriate key. See grabber.txt
for more information. If the datafile contains truecolor graphics, you
must set the video mode or call set_color_conversion() before loading it.
> allegro_init();
> install_*();
> foo = load_datafile("foo.dat");
> Then I attempt to display an RLE sprite in the DATAFILE - causes
> crash of whole system (95 goes down too) with no traceback
That's because you were still in a 256 color mode when you
loaded the datafile, so your sprites were converted into a
256 color format. But then you try to draw them onto a 16 bit
screen, which is an unsupported operation, so all sorts of
bad things might happen (in this case it probably runs past
the end of the RLE sprite data, because that is in the wrong
format so it doesn't notice the end marker, and goes off
corrupting memory).
If you don't want automatic conversion of the image formats,
call set_color_conversion() to disable it. But you usually
do want it, because truecolor pixel formats can be different
on each video card, so if you don't set the mode before
loading the graphics, they are extremely unlikely to end up
in the right format for displaying on your screen.
Shawn Hargreaves.
- Raw text -