Mail Archives: djgpp/1999/08/15/13:32:34
Al Morgan wrote:
>
> I've gotten some basic stuff to work using allegro, Mode-X graphics (i still
> haven't gotten that to work without using a 3rd party library, grrr...) ,
> keyboard, mouse, and I've been able to load bitmaps and draw them on the
> screen. The problem is when I tried to set the palette, beacuse my picture
> was turning out all wrong colors, but when I did, it gave an error (copied
> below my program). Is it me, or is it my computer that has a problem?
>
> #include <allegro.h>
> #include <conio.h>
>
> void main()
> {
> allegro_init();
> install_keyboard();
> install_mouse();
>
> set_gfx_mode(GFX_MODEX, 320, 240, 320, 480);
>
> PALETTE *p;
It's usually easier to not use pointers with palletes in Allegro.
> BITMAP *belive = load_bmp("c:\\belive.bmp", *p); // mulder's "I want to
> belive" poster
For example, here you are passing trash from an uninitialized pointer to
load_bmp, intead of a pointer variable. Just do this:
PALLETE pal;
BITMAP *bmp=load_bmp("bmp.bmp",pal);
> set_palette(*p); // HERE'S WHERE THE PROBLEM IS
set_pallete(pal);
>
> draw_sprite(screen, belive, 0, 0);
>
> getch();
>
> destroy_bitmap(belive);
> allegro_exit(); // i know i don't need it, but i'm paranoid
> }
Btw, you can use pointers with palletes, though I find that it usually
isn't worth the trouble. Especially since the minimum block size in
DJGPP is something like 4k (?) so you will be wasting memory when you
malloc a chunk.
Bbtw, it's "believe" :)
-Mike
- Raw text -