Archived

This topic is now archived and is closed to further replies.

Nullio

2d Lighting

Recommended Posts

Does anyone know a good method or even a good article on how do do lighting effects in an tile basic directdraw engine?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
code for 640x480x32bit
first,lock surface, get pointer(pb)
(the surface shall be in system memory!!!)
then BYTE *pl=(BYTE *)&LightTable[0];
(u can init the LightTable like this:

LightTable=new unsigned char [307200];
for (int i=0;i<640;i++)
for (int j=0;j<480;j++)
{
LightTable[i+j*640]=sqrt((i-320)*(i-320)+(j-240)*(j-240)*4)*160/577;
})

and u can use the code below now.
(ur cpu should support MMX!!!)
__asm
{
mov ecx,153600;
mov edi,pb;
mov esi,pl;
_loop:
movq mm0,[edi];
movq mm1,[esi];
punpckhbw mm1,mm1;
punpckhbw mm1,mm1;
psubusb mm0,mm1;
movq [edi],mm0;
add edi,8;
add esi,2;
dec ecx;
jnz _loop;
emms;
}
haha, enjoy it!!!

Share this post


Link to post
Share on other sites