Jump to content
  • Advertisement

Archived

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

Nullio

2d Lighting

This topic is 6245 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

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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!