if(LIGHTMAP_DIV == 1)
{
int bpp = screen->format->BytesPerPixel;
+ if(SDL_MUSTLOCK(screen))
+ {
+ SDL_LockSurface(screen);
+ }
Uint8 *pixel = (Uint8 *) screen->pixels;
int loc = 0;
for(int y = 0;y < height;y++) {
}
pixel += screen->pitch - width * bpp;
}
+ if(SDL_MUSTLOCK(screen))
+ {
+ SDL_UnlockSurface(screen);
+ }
}
else
{
int bpp = screen->format->BytesPerPixel;
+ if(SDL_MUSTLOCK(screen))
+ {
+ SDL_LockSurface(screen);
+ }
Uint8 *div_pixel = (Uint8 *) screen->pixels;
int loc = 0;
for(int y = 0;y < height;y++) {
}
div_pixel += (screen->pitch - width * bpp) * LIGHTMAP_DIV;
}
+ if(SDL_MUSTLOCK(screen))
+ {
+ SDL_UnlockSurface(screen);
+ }
}
}
int blit_width = src_rect->w / LIGHTMAP_DIV;
int blit_height = src_rect->h / LIGHTMAP_DIV;
int bpp = src->format->BytesPerPixel;
+ if(SDL_MUSTLOCK(src))
+ {
+ SDL_LockSurface(src);
+ }
Uint8 *pixel = (Uint8 *) src->pixels + srcy * src->pitch + srcx * bpp;
int loc = dsty * width + dstx;
for(int y = 0;y < blit_height;y++) {
pixel += (src->pitch - blit_width * bpp) * LIGHTMAP_DIV;
loc += width - blit_width;
}
+ if(SDL_MUSTLOCK(src))
+ {
+ SDL_UnlockSurface(src);
+ }
}
/*void Lightmap::light_blit(SDL_Surface *src, SDL_Rect *src_rect, int dstx, int dsty)
{
int bpp = src->format->BytesPerPixel;
- Uint8 *pixel = (Uint8 *) src->pixels + src_rect->y * src->pitch + src_rect->x * bpp;
+ if(SDL_MUSTLOCK(src))
+ {
+ SDL_LockSurface(src);
+ }
+ Uint8 *pixel = (Uint8 *) src->pixels + src_rect->y * src->pitch + src_rect->x * bpp;
int loc = dsty * width + dstx;
for(int y = 0;y < src_rect->h;y++) {
for(int x = 0;x < src_rect->w;x++, pixel += bpp, loc++) {
pixel += src->pitch - src_rect->w * bpp;
loc += width - src_rect->w;
}
+ if(SDL_MUSTLOCK(src))
+ {
+ SDL_UnlockSurface(src);
+ }
}*/
void