def initialize( size, depth=0, flags=[] )
if( size.kind_of? SDL::Surface )
surf = size
if( surf.pointer.null? )
raise Rubygame::SDLError, "Surface cannot wrap NULL Surface!"
else
@struct = surf
end
return
end
unless size.kind_of? Array
raise TypeError, "Surface size is not an Array: #{size.inspect}"
end
unless size.length == 2 and size.all?{ |n| n.kind_of? Numeric }
raise ArgumentError, "Invalid Surface size: #{size.inspect}"
end
pixformat = nil
vs = SDL.GetVideoSurface()
unless( vs.pointer.null? )
pixformat = vs.format
else
if( Rubygame.init_video_system == 0 )
pixformat = SDL.GetVideoInfo().vfmt
else
raise(Rubygame::SDLError,
"Could not initialize SDL video subsystem.")
end
end
rmask = pixformat.Rmask
gmask = pixformat.Gmask
bmask = pixformat.Bmask
amask = pixformat.Amask
if( depth <= 0 )
depth = pixformat.BitsPerPixel
end
w, h = size
flags = Rubygame.collapse_flags(flags)
@struct = SDL.CreateRGBSurface(flags, w, h, depth,
rmask, gmask, bmask, amask)
end