Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » colours changes after graphics mode!

Credits go to Kitty Cat for helping out!
This thread is locked; no one can reply to it. rss feed Print
colours changes after graphics mode!
Maikol
Member #4,997
September 2004
avatar

Hi all! In my program I read from a config file colours and settings and then I start graphics system. After a deep debug I've noticed colours made before graphics system are changed red and blue! see:

{
...
// for example
colour = makecol24(255,0,0);
...
allegro_init();
set_color_depth(24);
set_gfx_mode(...);
...
al_trace("%d %d %d",getr24(color),getg24(color),getb24(color));
}

and now colour is (0,0,255). I've tried to call set_color_depth() before makecol24() with no success. Do you know why this happens or how to solve it? Don't want to make a function to interchange red and blue, neither use 3 ints instead of 1 to keep rgb and then create colour. Thanks indeed!

El sabio no dice todo lo que piensa, pero siempre piensa todo lo que dice
Aristóteles

Kitty Cat
Member #2,815
October 2002
avatar

Allegro doesn't know the color ordering of a graphics mode before the mode is set, so it guesses some defaults. After setting the graphics mode, the color ordering is properly read from the system, which may be different from before setting the mode.

Also, any particular reason for 24-bit? 32-bit is generally faster. :)

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Maikol
Member #4,997
September 2004
avatar

I use 24 bit because my graphic card isn't able to load 32 bit at high resolutions and because I like using only rgb, no more parameters.

All told I must set graphics and then create colours. Then I'll have to use 3 ints... but maybe one day I'd like to use 32 bits! Pfff okay, I'll manage. Thanks!!

El sabio no dice todo lo que piensa, pero siempre piensa todo lo que dice
Aristóteles

Kikaru
Member #7,616
August 2006
avatar

32-bit runs the same as 24-bit, it just allows for fullscreen and takes a little more room. I don't believe allegro uses the last 8 bits at all in 32-bit mode. ;)

Evert
Member #794
November 2000
avatar

Quote:

I don't believe allegro uses the last 8 bits at all in 32-bit mode.

You've never heard of an alpha channel, have you?

EDIT: also, 24 or 32 bit has nothing to do with being able to run in Windowed mode or not. That said, Allegro will always run in the desktop colourdepth if you're using a window, so setting the colourdepth to something else forces colour conversions at each update.

Go to: