/*  call-seq:
 *     update()
 *     update(rect)
 *     update(x,y,w,h)
 *
 *  Updates (refreshes) all or part of the Rubygame window, revealing to the 
 *  user any changes that have been made since the last update. If you're using
 *  a double-buffered display (see Display.set_mode), you should use
 *  Screen#flip instead.
 *
 *  This method takes these arguments:
 *  rect:: a Rubygame::Rect representing the area of the screen to update.
 *         Can also be an length-4 Array, or given as 4 separate arguments.
 *         If omitted or nil, the entire screen is updated.
 */
VALUE rbgm_screen_update(int argc, VALUE *argv, VALUE self)
{
  int x,y,w,h;
  SDL_Surface *screen;
  Data_Get_Struct(self,SDL_Surface,screen);

  switch(argc)
        {
        case 0:
          x = y = w = h = 0;
          break;
        case 1:
          if(argv[0]==Qnil)                    /* nil */
                x = y = w = h = 0;
          else                                         /* Array/Rect */
                {
                  x = NUM2INT(rb_ary_entry(argv[0],0));
                  y = NUM2INT(rb_ary_entry(argv[0],1));
                  w = NUM2INT(rb_ary_entry(argv[0],2));
                  h = NUM2INT(rb_ary_entry(argv[0],3));
                }
          break;
        case 4:
          x = NUM2INT(argv[0]);
          y = NUM2INT(argv[1]);
          w = NUM2INT(argv[2]);
          h = NUM2INT(argv[3]);
          break;
        default:
          rb_raise(rb_eArgError,"wrong number of args to update (%d for 0)",argc);
          break;
        }

  SDL_UpdateRect(screen,x,y,w,h);
  return self;
}