snv ignore version.h, add includes for gcc 4.3.3.
[supertux.git] / src / video / sdl_lightmap.cpp
index 040189c..595da53 100644 (file)
@@ -48,8 +48,13 @@ namespace SDL
   {
     screen = SDL_GetVideoSurface();
 
-    float xfactor = (float) config->screenwidth / SCREEN_WIDTH;
-    float yfactor = (float) config->screenheight / SCREEN_HEIGHT;
+    //float xfactor = 1.0f; // FIXME: (float) config->screenwidth / SCREEN_WIDTH;
+    //float yfactor = 1.0f; // FIXME: (float) config->screenheight / SCREEN_HEIGHT;
+
+    numerator = 1;
+    denominator = 1;
+
+    /* FIXME:
     if(xfactor < yfactor)
     {
       numerator = config->screenwidth;
@@ -60,6 +65,7 @@ namespace SDL
       numerator = config->screenheight;
       denominator = SCREEN_HEIGHT;
     }
+    */
 
     LIGHTMAP_DIV = 8 * numerator / denominator;
 
@@ -112,6 +118,10 @@ namespace SDL
     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++) {
@@ -174,10 +184,18 @@ namespace SDL
         }
         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++) {
@@ -281,6 +299,10 @@ namespace SDL
         }
         div_pixel += (screen->pitch - width * bpp) * LIGHTMAP_DIV;
       }
+      if(SDL_MUSTLOCK(screen))
+      {
+        SDL_UnlockSurface(screen);
+      }
     }
   }
 
@@ -293,6 +315,10 @@ namespace SDL
     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++) {
@@ -351,12 +377,20 @@ namespace SDL
       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++) {
@@ -414,6 +448,10 @@ namespace SDL
       pixel += src->pitch - src_rect->w * bpp;
       loc += width - src_rect->w;
     }
+    if(SDL_MUSTLOCK(src))
+    {
+      SDL_UnlockSurface(src);
+    }
   }*/
 
   void
@@ -438,7 +476,7 @@ namespace SDL
     if (transform == 0) {
       std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
       return;
-    }  
+    }
 
     SDL_Rect *src_rect = surface_data->get_src_rect(effect);
     int dstx = (int) request.pos.x * numerator / denominator;
@@ -464,7 +502,7 @@ namespace SDL
     if (transform == 0) {
       std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
       return;
-    }  
+    }
 
     int ox, oy;
     if (effect == HORIZONTAL_FLIP)
@@ -530,15 +568,6 @@ namespace SDL
   }
 
   void
-  Lightmap::draw_text(const DrawingRequest& /*request*/)
-  {
-    //const TextRequest* textrequest = (TextRequest*) request.request_data;
-
-    //textrequest->font->draw(textrequest->text, request.pos,
-    //    textrequest->alignment, request.drawing_effect, request.alpha);
-  }
-
-  void
   Lightmap::draw_filled_rect(const DrawingRequest& request)
   {
     const FillRectRequest* fillrectrequest