I hope this doesn’t sound too much of an obvious/pathetic question,
I’ve got a surface that has a whole load of characters in it, for
putting text onto the screen.
Depending on the message, I want the colors to be different. But asides
from change the palette of the entire surface to the desired color, is
there a better way?
I happen to be hacking on just that kind of thing right now, for the
"conemu" library.
So you get an idea, right now I’m doing,
void setFontColor(int red, int green, int blue)
{
SDL_Color colors[16];
for (int i = 0 ; i < 16 ; i++)
{
colors[i].r = red;
colors[i].g = green;
colors[i].b = blue;
}
SDL_SetPalette(globals.font, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 16);
}
which works, but is probably not the best way of doing things.
Any suggestions?
Well, in a quick hack SDL program (not “conemu”), I just forced SDL to
use 24 bpp RGB (which results in s/w emulation, if such a mode cannot be
set). Then I used an 8 bpp grayscale font, stored as 24 bit RGB. Finally,
I hacked a custom s/w blitter that combined each pixel of the font with
(IIRC) two masks using logic operations, before writing to the screen.
This gave antialiased printing with individually selectable background
and foreground colors from an impressive palette of the 8 fundamental RGB
colors!
It’s possible to implement more sophisticated things, of course, but
short of creating and colorizing new fonts as needed, I can’t really see
how you could do it without hacking your own blitter.
//David Olofson — Programmer, Reologica Instruments AB
.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |
-------------------------------------> http://olofson.net -'On Friday 08 March 2002 13:48, Sweeney, Steven (FNB) wrote: