Archived

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

2d Lighting

This topic is 5964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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