Hello again,
In the isometric engine I’m working on I want to have a simple degree
of something like dynamical lightning - that is darkening the tiles
used depending on the distance from the lightsource. What would be
the best approach in SDL to do that? I thought about making new
instances of the given tile on the fly and modyfing each of their
pixels. Is there a better way to handle that?
regards,
Kornel Kisielewicz
Of course using an alpha channel would make this very easy.
Just laying down a black tile with varying alpha levels to make
it darker. After working with OpenGL in 2D for awhile now,
I don’t know how I’d go back. Using alpha with OpenGL in 2D
costs almost nothing in performance.
Without OpenGL I would pre-process all of your tiles, not “on
the fly” as you say but before the action in your game takes place.
Also, only a few shades like bright, normal, dark, black. You’ll
still get a pretty good effect and that’s only 4 times as much
memory. 
If you try to modify the pixels each time you draw a tile you are
looking at major slowdown.
You’ll find this is true with any approach, not just SDL.
So, unless this turns to actual implementation examples, it’s
probably a bit off topic.
Hello again,
In the isometric engine I’m working on I want to have a simple degree of
something like dynamical lightning - that is darkening the tiles used
depending on the distance from the lightsource. What would be the best
approach in SDL to do that? I thought about making new instances of the
given tile on the fly and modyfing each of their pixels. Is there a better
way to handle that?
regards,
Kornel Kisielewicz
Kornel Kisieleiwcz wrote:
Hello again,
In the isometric engine I’m working on I want to have a simple degree of
something like dynamical lightning - that is darkening the tiles used
depending on the distance from the lightsource. What would be the best
approach in SDL to do that? I thought about making new instances of the
given tile on the fly and modyfing each of their pixels. Is there a better
way to handle that?
You could draw a black transparent rectangle on top of each tile to
darken it. Using different alpha values, you might achieve the desired
result.
However, that’ll be slower because alpha is expensive.
Stephane