[SDL] X window creation bug fix.

Lee Haywood sdl at ksl2.freeserve.co.uk
Mon Aug 27 07:56:01 PDT 2001


On Monday 13 August 2001 22:22, William Kendrick wrote:
> > Gamma is a hardware feature of the RAMDAC of most modern video cards.
> > (One hardware LUT right before each DAC.) SDL can use it if the
> > underlying target provides an API for it. (No idea about the support
> > status, though.)
>
> Sorry for the dumb question, but what exactly does this give you?
> A simulated 'indexed-mode' screen?  (Whenever I hear the term 'gamma,'
> I think of lightness (brightness?) of the display.)

The normal use for these tables is to manipulate the light and color 
dynamics. Normally, each gamma table would contain a linear ramp from 0 
through 255, resulting in a 1:1 relation between the R bits in the pixel 
data, and the R bits actually fed to the DAC. To reduce the contrast, 
you'd compress this ramp a little. To increase light, you'd adjust it's 
DC offset. If you want to emphasize contrast for dark colors, you could 
expand the lower half of the table, and compress the upper half - or for 
a smoother effect; use an inverse exponential curve instead of a linear 
curve.


> Can you, for example, have a little multicharactered sprite which has
> one set of colors (say, blues and greens and yellows) and then
> on-the-fly change it (without storing additional Surface bitmaps) to a
> different color (say, reds and oranges)....  I'm thinking of MegaMan
> and SuperMarioBros from NES :) )

Something like that, yes. Whereas an 8 bit indexed color display indexes 
a 256 element table of RGB colors, an RGB 8:8:8 display indexes three 
individual 256 element tables; one for each color channel. The R bits 
select an R output value from the R table, the G bits select from the G 
table etc.

So, to emulate a palettized mode, use gray level as index (R = G = B = 
index; so that all three gamma tables will be indexed by the same value), 
and then program the gamma tables as if they were a hardware palette.

To use this "palette emulation" together with RGB mode, you could split 
the dynamic range in half. For example, use R/G/B levels 0..127 for 
normal RGB color and 128..255 (R, G and B must be equal here!) as palette 
indexes. Then program the first 128 levels of the gamma tables with a 
range from 0 through 255, and use the last 128 levels as a 128 color 
indexed color palette.

Various other tricks are possible, of course, but it might not be a good 
idea to rely too heavily on this method - not all targets and cards 
support it.


//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 |
`--------------------------------------> david at linuxdj.com -'




More information about the SDL mailing list