Page 1 of 1

"lightmap" question

PostPosted: Dec 9, 2008 @ 6:17pm
by Kak
Hi!

I'm trying to move some of my old code (working with pocketHAL, I had to do everything manually - which I loved ;) ) to EDGELIB to test some things for iPhone (and maybe ppc & smartphone too).

I had a kind of custom "blitLightmap" where I had a gray texture, ranging from 0 to 255, and I used it to produce shadows in 2d backgrounds, kind of 3d lightmap multitexturing but (obviously) in 2d.

128 meant "keep the background color as is", the closer to 0 the darker the background color changed, and closer to 255 would mean to put some light (usually @ 255 it was saturated with white color)

I'm terrible explaining this kind of things, I hope you understood it :)


I loved this method because I used no mults (just shifts & ands to get the R,G,B and a lookup table), and it was pretty fast, but which should be the correct way to do that in EDGELIB? Should I directly use an alpha blit, or is there any way I can make this kind of function run faster?

TIA
Kak

PostPosted: Dec 10, 2008 @ 11:27am
by edge
Hi,

For iPhone we recommend using OpenGL, hardware acceleration makes a big difference for this device. You can use the EDGELIB wrappers to draw 2D graphics in OpenGL.

If you can't use OpenGL you can program your routine manually by locking surfaces.

For your example you can also use subtractive blending for the shadow, and additive blending for the lighting. In this case you need to have 2 different surfaces, one for the shadow and one for the light.

PostPosted: Apr 18, 2009 @ 10:38am
by Kak

PostPosted: Apr 18, 2009 @ 1:13pm
by edge