7
8:- module(sdl_surface, [
9 sdl_destroysurface/1,
10 sdl_createsurfacefrom/6
11]). 12
13:- use_module(library(sdl/foreign), [
14 sdl_createsurfacefrom_/6,
15 sdl_destroysurface/1,
16 sdl_surface_blob_portray/2
17]). 18:- reexport(library(sdl/foreign), [sdl_destroysurface/1]). 19:- use_module(library(sdl/pixels), [sdl_pixel_format/2]). 20:- use_module(library(ptr)). 21
22:- multifile error:has_type/2. 23error:has_type(sdl_surface_blob, X) :- blob(X, sdl_surface_blob).
24
25:- multifile prolog:error_message//1. 26prolog:error_message(type_error(sdl_surface_blob, Culprit)) -->
27 [ 'sdl_surface_blob, found ~q'-[Culprit] ].
28
29user:portray(Surface) :-
30 blob(Surface, sdl_surface_blob), !,
31 sdl_surface_blob_portray(current_output, Surface).
50sdl_createsurfacefrom(Surface, Width, Height, Format, Pixels, Pitch) :-
51 must_be(var, Surface),
52 must_be(positive_integer, Width),
53 must_be(positive_integer, Height),
54 must_be(sdl_pixel_format, Format),
55 must_be(ptr_blob, Pixels),
56 must_be(integer, Pitch),
57 sdl_pixel_format(Format, IntFormat),
58 sdl_createsurfacefrom_(Surface, Width, Height, IntFormat, Pixels, Pitch)