# File lib/rubygame/screen.rb, line 207
  def initialize(  size, depth=0, flags=[Rubygame::SWSURFACE] )

    # Cheating a bit. First arg can be a SDL::Surface to wrap it.
    #
    if( size.kind_of? SDL::Surface )
      surf = size
      if( surf.pointer.null? )
        raise Rubygame::SDLError, "Screen cannot wrap NULL Surface!"
      elsif( surf.pointer != SDL.GetVideoSurface().pointer )
        raise Rubygame::SDLError, "Screen can only wrap the video Surface!"
      else
        @struct = surf
      end
      return
    end


    w,h = size
    flags = Rubygame.collapse_flags(flags)

    @struct = SDL.SetVideoMode( w, h, depth, flags )

    if( @struct.pointer.null? )
      @struct = nil
      raise( Rubygame::SDLError,
             "Couldn't set [%d x %d] %d bpp video mode: %s"%\
             [w, h, depth, SDL.GetError()] )
    end

  end