• Advertisement

Archived

This topic is now archived and is closed to further replies.

Can anyone with experiance using Allegro Help??

This topic is 6219 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, Ive been using allegro for a short time now and one thing thats bugging the hell out of my and cant seem to find a solution to is the strange thing that happens when i draw bitmaps to the screen...The first bitmap comes out fine..but every other bitmap after that''s color is all distorted...I will include a short source (50 lines or so) to see what if you can spot what im doing wrong,it''d be ideal if you could edit this source so that it will work properly and not only display the 1st image correctly and post it up so i can see the error of my ways Note: all bitmaps loaded into WizardSprite are 256 color ****************Begin source******************* #include BITMAP *DoubleBuffer; BITMAP *WizardSprite; RGB pal[256]; int PosX,PosY; void main(void) { allegro_init(); install_timer(); install_keyboard(); set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); DoubleBuffer=(create_bitmap(640,480)); WizardSprite=load_bmp("wizlookdown.bmp",pal); PosX = (SCREEN_W - WizardSprite->w)/2; PosY = (SCREEN_H - WizardSprite->h)/2; set_palette(pal); set_color_depth(8); /* The Main Loop,The first Bitmap loaded into WizardSprite Comes out fine,however any Bitmap after that comes out different colors than they ought to be.*/ while (!key[KEY_ESC]) { clear_to_color(DoubleBuffer,115); draw_sprite(DoubleBuffer,WizardSprite,PosX,PosY); blit(DoubleBuffer,screen,0,0,0,0, DoubleBuffer->w, DoubleBuffer->h); if( (key[ KEY_LEFT]) && (PosX > 0) ) { WizardSprite=load_bmp("wizlookleft.bmp",pal); PosX--; } if( (key[ KEY_RIGHT]) && (PosX + WizardSprite->w < SCREEN_W) ) { WizardSprite=load_bmp("wizlookright.bmp",pal); PosX++; } if( (key[ KEY_UP]) && (PosY > 0) ) { WizardSprite=load_bmp("wizlookup.bmp",pal); PosY--; } if( (key[ KEY_DOWN]) && (PosY + WizardSprite->h < SCREEN_H) ) { WizardSprite=load_bmp("wizlookdown.bmp",pal); PosY++; } } destroy_bitmap(WizardSprite); destroy_bitmap(DoubleBuffer); allegro_exit(); } **************************** Yesterday we Obeyed kings & bent our necks before emperors,but today we kneel only to the truth. ****************************

Share this post


Link to post
Share on other sites
Advertisement
Before you post your question yet another time, you might want to look up the nature of 256 color display modes and palettes. A quick fix (though rather useless) would be to set_palette after each load_bmp. A better way would be to make sure each bitmap uses the same palette (PSP and Photoshop have tools to help you do this, and there are several shareware and freeware tools too)

Micah

Share this post


Link to post
Share on other sites
Erm thanks,I realise now it was a stupid question...I had thought that allegro Builds a palette from the 1st bitmap you load,and then uses it for all others with the thought that they all have the same palette...This it does,But my Pallette saving/loading Prog must really suck because it turns out only two of the Bitmaps had the Same Pallette all along,i just never bothered to check,it was the last thing that crossed my mind.

Share this post


Link to post
Share on other sites

  • Advertisement