As an update to this - I have blended on the fly and dropped my fps from 110 to 15 so now I am going to try the prerendoring during map load and see if that speeds the FPS back up to a decent amount. Will post progress once that is done and I am happy with it. EDIT: Also if anyone can think of a way to help make this code work faster it would be appreciated!
Code:
void OnTheFlyLighting()
{
int cx,cy;
int tr,tg,tb;
cx = 48 + (tmpObj->GetX()/2) + (tmpObj->GetMapX()*32);
cy = 48 + (tmpObj->GetY()/2) + (tmpObj->GetMapY()*32);
for(int LCVY = cy-tmpObj->GetBrightness(); LCVY < cy+tmpObj->GetBrightness();LCVY++)
{
for(int LCVX = cx-tmpObj->GetBrightness(); LCVX < cx+tmpObj->GetBrightness();LCVX++)
{
if(LCVY < 0 || LCVX < 0 || LCVY > scry || LCVX > scrx)
{
}
else
{
for(int grade = 0;grade < 8;grade++)
{
int shade = tmpObj->GetBrightness()/8;
if( ((LCVX - cx)*(LCVX - cx) +(LCVY - cy)*(LCVY - cy) <= (tmpObj->GetBrightness() - (grade*shade))*(tmpObj->GetBrightness() - (grade*shade)))
&&
((LCVX - cx)*(LCVX - cx) +(LCVY - cy)*(LCVY - cy) > (tmpObj->GetBrightness() - ((grade+1)*shade))*(tmpObj->GetBrightness() - ((grade+1)*shade)))
)
{
int c = getpixel(BUFFER,LCVX,LCVY);
int alpha = (grade*8);//to upgrade the strength of the light
tr=((tmpObj->GetR()*alpha)+((getr32(c)*(255-alpha))))/256;
tg=((tmpObj->GetG()*alpha)+((getg32(c)*(255-alpha))))/256;
tb=((tmpObj->GetB()*alpha)+((getb32(c)*(255-alpha))))/256;
putpixel(BUFFER,LCVX,LCVY,makecol(tr,tg,tb));
break;
}
}
}
}
}
}