Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » color depth under linux

This thread is locked; no one can reply to it. rss feed Print
color depth under linux
Marco Aurelio
Member #2,847
October 2002
avatar

I try to set any resolution under linux
32bpp, 24bpp, 16bpp and 8bpp but Allegro
do not return error with set_gfx function.

My linux is run vesa frame buffer with
16bpp at 640x480 bits. I compile under console.

All my bmps are 32bpp in depth and
set color depth before calling set_gfx.

If I set gfx with same resolution of frame
buffer (16bpp) it's ok, the color of bmp stays
the same but if I try to set allegro resolution of 32bpp under 16bpp frame buffer,
Allegro do not complain, program runs nice but
all bmp colors changes, like if I use
8bpp and do not set correct palette.

Where is my mistake? ::)

Thomas Fjellstrom
Member #476
June 2000
avatar

The default VESA framebufer driver cannot change modes after boot. (IIRC)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Marco Aurelio
Member #2,847
October 2002
avatar

How could I know what color depth is linux
configured from Allegro program?
In Dos and Windows this works fine.

1 /*
2 * TRY 32 bpp
3 */
4 COLOR_DEPTH = 32;
5 set_color_depth(COLOR_DEPTH);
6 if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) == 0) {}
7 else {
8 /*
9 * TRY 24 bpp
10 */
11 COLOR_DEPTH = 24;
12 set_color_depth(COLOR_DEPTH);
13 if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) == 0) {}
14 else {
15 /*
16 * TRY 16 bpp
17 */
18 COLOR_DEPTH = 16;
19 set_color_depth(COLOR_DEPTH);
20 if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) == 0) {}
21 else {
22 /*
23 * TRY 8 bpp
24 */
25 COLOR_DEPTH = 8;
26 set_color_depth(COLOR_DEPTH);
27 if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) == 0) {}
28 else {
29 /*
30 * return with no graphics set.
31 */
32 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
33 allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
34 return 1;
35 }
36 }
37 }
38 }

Thomas Fjellstrom
Member #476
June 2000
avatar

Im not sure, It sounds like the fbcon allegro drivers are allowing you to set a color depth that it doesn't support, like the windowed modes in X and Windows...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Marco Aurelio
Member #2,847
October 2002
avatar

I don't know how to fix this in Allegro
library. What point of code I begin to
find and fix?

???

Thomas Fjellstrom
Member #476
June 2000
avatar

Its not really an allegro problem... Im not sure what the best method to use is...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Evert
Member #794
November 2000
avatar

The code you posted should work properly, from the looks of it.
Haveyou tried any other drivers?

Wer fu
Member #1,084
March 2001
avatar

The FrameBuffer isn't really reliable, as it let you do graphics but it cannot change of colour depth (and I don't remember if you can change resolution).

Although it may be interesting for low-end computer, nowadays X is getting MUCH more popular than the console. Only a bunch of people who know how it work can use it. More newbies are now interested by Linux or using it without even knowing it's not Windows (some people just don't make the difference!), just look at the success of Mandrake! So if you want to catch more people, go for X.

ICQ:71667703 or Email&MSN: werfu_dx@yahoo.fr
Werfu was here

guilt
Member #2,553
July 2002
avatar

Yeah ,I have tried this thing out .I figured that
if you set_color_depth() and then load_bmp()
,you don't have (m)any palette problems .Also ,if
using both PCXs and BMPs in the game ,this palette
problem gets solved .I don't know how : It's just
a rule of thumb !

Hein Zelle
Member #217
April 2000

Wer Fu>

There is no such thing as "Just go for X" when you're programming an allegro game, it depends on the user (allegro configuration) which graphics mode is used. That is, assuming you properly request GFX_AUTODETECT in your game.

The framebuffer console can handle only one colordepth, the one it was configured for at startup. It cannot change while running (at least not with the fbcon driver). You can select smaller resolutions (they will only use the centre part of the screen) but not larger, as the resolution cannot change either. Again, only for fbcon, some of the brand-specific framebuffer drivers do support this.

If you want to play a game (or develop one) using a framebuffer console, in general make sure you use the same color depth for both, and preferably also the same resolution. The easiest option is to set a truecolor framebuffer, and allow 15,16,24 or 32 bpp in your game. If you give your game a configuration file with the color depth in it, or a command line option, you can select the proper colordepth (matching the framebuffer) when starting the game.

Oh, and finally: often it does make a big difference in speed if you use the framebuffer instead of X; for fullscreen action games it can be well worth the "trouble" of getting them to run in a framebuffer.

Go to: