Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » AllegroGL: How to make textures from datafile-bitmaps?

This thread is locked; no one can reply to it. rss feed Print
AllegroGL: How to make textures from datafile-bitmaps?
maxx.t
Member #8,210
January 2007

I have the following question: Why does

texture_id = allegro_gl_make_texture ((BITMAP *)dat[SOME_BITMAP].dat);

results in a very dark (almost black) texture whereas

bmp = load_bitmap("some_bitmap.pcx",pal);
texture_id = allegro_gl_make_texture (bmp);

works fine although dat[SOME_BITMAP] is the grabbed file "some_bitmap.pcx".
What am i missing?

gnolam
Member #2,030
March 2002
avatar

Have you set color depth, graphics mode, color conversion etc. before loading the datafile?

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

maxx.t
Member #8,210
January 2007

I loaded the datafile before setting up the graphic mode.

Loading the datafile after the graphics setup results in the right intensitiy
of the texture. However, now the wrong palette is used for drawing. This holds for the texture and also if I use the loaded bitmap for blitting in allegro mode.

Changing the color depth to the one of the bitmap (8 bit) or using set_palette()
with the related palette of the bitmap does not help.

Neil Walker
Member #210
April 2000
avatar

why not just save the image as an rgb rather than paletted image?

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

gnolam
Member #2,030
March 2002
avatar

Due to the way 8-bit images are stored in datafiles, you'll have to load and set the proper palette before loading the datafile. So:

  1. Set color depth and graphics mode.

  2. Load the proper palette with load_datafile_object() and set it.

</li>

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

maxx.t
Member #8,210
January 2007

Thank you very much!
Both solutions are working fine.

Go to: