rocksndiamonds-2.0.1
[rocksndiamonds.git] / src / libgame / system.c
index 51b38c16862237ef181c707aacdc6e1a4eb19785..b4ac9ce4e83a3b8bb4e49a954e78f071a6ab4391 100644 (file)
@@ -375,7 +375,7 @@ inline void DrawSimpleWhiteLine(Bitmap *bitmap, int from_x, int from_y,
                                int to_x, int to_y)
 {
 #ifdef TARGET_SDL
-  SDLDrawSimpleLine(bitmap->surface, from_x, from_y, to_x, to_y, 0xffffff);
+  SDLDrawSimpleLine(bitmap, from_x, from_y, to_x, to_y, 0xffffff);
 #else
   XSetForeground(display, bitmap->gc, WhitePixel(display, screen));
   XDrawLine(display, bitmap->drawable, bitmap->gc, from_x, from_y, to_x, to_y);
@@ -403,8 +403,8 @@ inline void DrawLine(Bitmap *bitmap, int from_x, int from_y,
        continue;
 
 #if defined(TARGET_SDL)
-      sge_Line(bitmap->surface,
-              from_x + dx, from_y + dy, to_x + dx, to_y + dy, pixel);
+      SDLDrawLine(bitmap,
+                 from_x + dx, from_y + dy, to_x + dx, to_y + dy, pixel);
 #elif defined(TARGET_ALLEGRO)
       AllegroDrawLine(bitmap->drawable, from_x + dx, from_y + dy,
                      to_x + dx, to_y + dy, pixel);
@@ -438,6 +438,26 @@ inline void DrawLines(Bitmap *bitmap, struct XY *points, int num_points,
 #endif
 }
 
+inline Pixel GetPixel(Bitmap *bitmap, int x, int y)
+{
+#if defined(TARGET_SDL)
+  return SDLGetPixel(bitmap, x, y);
+#elif defined(TARGET_ALLEGRO)
+  return AllegroGetPixel(bitmap->drawable, x, y);
+#else
+  unsigned long pixel_value;
+  XImage *pixel_image;
+
+  pixel_image = XGetImage(display, bitmap->drawable, x, y, 1, 1,
+                         AllPlanes, ZPixmap);
+  pixel_value = XGetPixel(pixel_image, 0, 0);
+
+  XDestroyImage(pixel_image);
+
+  return pixel_value;
+#endif
+}
+
 inline Pixel GetPixelFromRGB(Bitmap *bitmap, unsigned int color_r,
                             unsigned int color_g, unsigned int color_b)
 {
@@ -653,7 +673,7 @@ inline boolean PendingEvent(void)
 inline void NextEvent(Event *event)
 {
 #ifdef TARGET_SDL
-  SDL_WaitEvent(event);
+  SDLNextEvent(event);
 #else
   XNextEvent(display, event);
 #endif