set color depth, paint, and mouse cursor
aadfo824

I'm working my way through Game Programming All in One, I'm up to Chapter 7. Between Chp 7 and Chp 5 I'm trying to figure out how to set the mouse pointer to a bmp I drew with paint. Paint can save as 24 bit, 16 bit, and 256 color (8 bit, right?). The image is a wite x(two lines) with a transparent background. If i save as 16 bit, black works as a transparent color. Pink doesn't work. I tried changing the color depth, but the screen turns blue if I change to 16 bit, and black on 24 bit. Although, on 24 bit the mouse with pink background displays fine. I'm thinking that I have a bad video card, even though the computer isn't that old. Can anybody help me out?

gnolam

Show us the code.

My guess is you're setting the color depth after setting a graphics mode or loading your bitmaps...

aadfo824

Here is the code

 allegro_init();
 set_color_depth(8); //What should I set as?
 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
 
 //some irrevelant(to mouse) such as declaring variables 

 install_mouse();
 
 BITMAP * mouse = load_bitmap("pointer.bmp", NULL);
 set_mouse_sprite(mouse);
 set_mouse_sprite_focus(0,0);
 show_mouse(screen);

Remember the MS Paint side of it too.

Onewing

What edition of the Game Programming All in One book are you using? Anyway, don't forget about allegro.cc's online manual. Look up set_color_depth if you want to know how it works exactly.

Get familiar with the manual. I've used the GPAiO book as well (2nd edition), but the manual completes the knowledge from that book.

aadfo824

I'm using the 2nd edition. I checked the manual, I'm doing everything right. Maybe I need to call set_color_conversion, but whenever I try, I get

error said:

variable or field `set_color_conversion' declared void

Evert
Quote:

set_color_depth(8); //What should I set as?

Whatever youwant to use for colour depth. 16 should be a sensible default value.

Anyway, post your bitmap.

Quote:

variable or field `set_color_conversion' declared void

No idea. Post some code that produces this error.

aadfo824

Hooray that fixes the mouse, but it causes me another problem. I have been using 0-15 for colors, and now They all display as black and blue. Well, I'll just have to fix it with makecol.

Thank you for all your help.

Thread #585581. Printed from Allegro.cc