Pallette style effects on 32bit surfaces

Hi All,
Did I read somewhere that SDL supports palette style effects ( fire
etc ) in other in Bit Depths other than 8BPP? If this is possible could
someone supply a small code example.

Thanks

Dominique.
http://www.DelphiGamer.com

Dominique Louis wrote:

Did I read somewhere that SDL supports palette style effects ( fire
etc ) in other in Bit Depths other than 8BPP? If this is possible could
someone supply a small code example.

SDL does not support >8bpp indexed modes since these are so rare
(I have encountered 12bpp PseudoColor visuals on some HP hardware but
that’s all). However you can play some games with the gamma ramps which
can give you similar effects

You can always transform a 8bpp image with palette effects to a
greyscale 24-bit image (each pixel has equal R, G, B) and the gamma
ramps, but you can also do other interesting things

> You can always transform a 8bpp image with palette effects to a > greyscale 24-bit image (each pixel has equal R, G, B) and the gamma > ramps, but you can also do other interesting things

One thing to realize when doing “palette-effect”-style effects is that
true palette effects are much quicker, since the graphics hardware is
doing all of the index look-ups as it draws the pixels.

Duplicating effects like these using, say, 24bit truecolor mode means
redrawing every changed pixel every frame, which can be dog-slow on older
hardware.

Unless there’s something I’m missing. :slight_smile: I’m no PC expert.

-bill!
(just back from Classic Gaming Expo in Las Vegas! Whee!)On Sun, Aug 12, 2001 at 11:47:01PM +0200, Mattias Engdeg?rd 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.)

//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 -'On Monday 13 August 2001 21:44, William Kendrick wrote:

On Sun, Aug 12, 2001 at 11:47:01PM +0200, Mattias Engdeg?rd wrote:

You can always transform a 8bpp image with palette effects to a
greyscale 24-bit image (each pixel has equal R, G, B) and the gamma
ramps, but you can also do other interesting things

One thing to realize when doing “palette-effect”-style effects is that
true palette effects are much quicker, since the graphics hardware is
doing all of the index look-ups as it draws the pixels.

Duplicating effects like these using, say, 24bit truecolor mode means
redrawing every changed pixel every frame, which can be dog-slow on
older hardware.

Unless there’s something I’m missing. :slight_smile: I’m no PC expert.

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.)

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 :slight_smile: )

-bill!

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 :slight_smile: )

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 -'On Monday 13 August 2001 22:22, William Kendrick wrote:

William Kendrick wrote:

One thing to realize when doing “palette-effect”-style effects is that
true palette effects are much quicker, since the graphics hardware is
doing all of the index look-ups as it draws the pixels.

The “gamma ramps” are simply translation tables for each of the RGB
components (so if a pixel has the components {r, g, b}, the colour
actually displayed will be {reds[r], greens[g], blues[b]}).

Ordinarily these tables are identity-mapped (so reds[r] = r for
r=0…255 etc), but changing them can give you interesting effects.
In X11 this visual class is called DirectColor.

Unless there’s something I’m missing. :slight_smile: I’m no PC expert.

This is nothing PC-specific - it has been around on Real Computers
for decades, though it is probably a novelty in the PC world

Hehe… Well, coming from the Atari 8-bit world, I’m pretty familiar with
normal palette stuff, but this gamma stuff is a brave new world for me.

I’ll need to play with it. Thx! :slight_smile:

-bill!On Tue, Aug 14, 2001 at 11:32:17AM +0200, Mattias Engdeg?rd wrote:

This is nothing PC-specific - it has been around on Real Computers
for decades, though it is probably a novelty in the PC world

Lost the original email… But I just solved a similar problem but
keeping an array(was time constrained) of the keys currently pressed down.
Each cycle through the logic it’d take care of all the keys in the array.
I’d recommend doing it with a list but just didn’t have time. I can
forward the code to the list if this sounds of interest.

Matthew Allen
Vice-President
Zendragon Software
Slowly and surely the unix crept up on the Nintendo user …