From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro True Color Date: Tue, 3 Mar 1998 23:45:02 +0000 Organization: None Message-ID: References: <01bd40ae$8a128a80$871e89ce AT rosenbrock DOT parlorcity DOT com> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 61 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk A Bester writes: >I've set_color_depth(15) and set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0). >How many palette registers should I have? Strictly speaking, none. In a truecolor mode the video hardware stores each pixel color directly, so there is no need for a palette. Allegro does actually maintain an internal 256 color palette that is used when drawing 256 color memory bitmaps onto a truecolor destination, and any of the normal palette functions can be used to alter this table, but it doesn't affect the video hardware in any way. A few cards have the neat ability to use a 15 bit truecolor resolution and paletted colors at the same time, by setting the unsed top bit and then storing a palette index in the low byte of some pixels. But unfortunately this feature isn't widely available, and there is no standard way to access it. >Specifically, I'm trying to set up a screen that I can treat as 256x256 >with 512 palettes. Have I gone wrong here? A few of the Allegro functions (notably blit() and draw_sprite(), but see the "converting between color formats" section in the docs for details) are able to draw 256 images directly onto a truecolor surface, so as long as you make sure to store all your source images in a 256 color format (you will probably need to use the set_color_conversion() routine to prevent them being expanded into truecolor while they are loaded), you could just select a different palette before drawing each sprite onto the screen. >And how many bits per r, g, or b do I have? That depends on the color depth! In a 15 bit mode you have 15 bits total (5 per component), etc... >Is the answer to create my own registers in an array, and then use >line[x][y]=makecol15(palette[reg]->r, palette[reg]->g, palette[reg]->b) >as the parameter? That would work, but not very efficiently. Since there are only 256 possible values of reg, you can optimise it a great deal by precomputing an array of 256 ints holding the result of makecol15() for each color in the palette. You can then use this instead of the original palette by just looking up "table[reg]" instead of repeating the conversion for every single pixel. nb. The VGA palette registers range from 0-63, while makecol() takes parameters from 0-255, so you will need to scale up by a factor of four when going from one to the other. nbb. The line[x][y] value is a char, so you can't assign a 16 bit pixel directly to it. Try something like ((short *)line[x])[y] = char. -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa