module Draw: sig
.. end
Extra functions: font, bitmap, scaling and pixel operations
exception TGA_failure of string
failure loading TGA file
exception Sfont_failure of string
Failure using SFont functions
type
sfont = {
}
SFont texturemapped fonts based on the specifications at http://www.linux-games.com/sfont/
A font consists of a 32bpp RGBA surface with ASCII characters from 33 to 127. The first line in
the texturemap serves as a character delineator using the colour pink (255 0 255 255) to indicate
the space between each character rectangle.
type
filter =
| |
BOX of int |
| |
TRIANGLE of int |
| |
BELL of int |
| |
BSPLINE of int |
| |
HERMITE of int |
| |
MITCHELL of int |
| |
LANCZOS3 of int |
Filters to be used in scaling bitmaps. Currently only box, triangle and lanczos3 filters have been implemented
val box : filter
val triangle : filter
val bell : filter
val bspline : filter
val hermite : filter
val mitchell : filter
val lanczos3 : filter
val put_pixel : Sdl.Video.surface -> int -> int -> int32 -> unit
put_pixel surface x y pixel
puts an int32 rgb(a) pixel, such as output of map_rgb(a)
, on surface surface
at location (x,y)
val get_pixel : Sdl.Video.surface -> int -> int -> int32
get_pixel surface x y -> pixel
gets an int32 rgb(a) pixel, from surface surface
at location (x,y)
val scale : Sdl.Video.surface -> float -> filter -> Sdl.Video.surface
scale surface factor filter -> surface
Scales a surface by the given scale factor
, using the given filter
, and returning a new scaled surface
val scale_to : Sdl.Video.surface -> int -> int -> filter -> Sdl.Video.surface
scale_to surface new_width new_height filter -> surface
Scales a surface to the new width and height given, using the given filter
, and returning a new scaled surface
type
tga_orientation =
| |
From_upper_left |
| |
From_lower_left |
read_tga file -> width * height * bitsperpixel * pixel-data
Targa TGA image file reader, based on the specs at http://astronomy.swin.edu.au/~pbourke/dataformats/tga/
Takes as parameter the file name and returns a tuple containing the image width, height, bytes-per-pixel
a string containing the image data in BGR(A) format, and the image orientation.
Reads 15, 16, 24 and 32 bit-per-pixel raw and RLE-compressed images.
Throws TGA_exception when anything goes wrong.
val read_tga : string -> int * int * int * string * tga_orientation
val load_tga : string -> Sdl.Video.surface
load_tga file -> surface
Loads a TGA file and returns a surface with the image data
val make_sfont : Sdl.Video.surface -> sfont
make_sfont Surface_containing_loaded_RGBA_texture_map_with_font_characters -> sfont
Takes a surface containing a texture-mapped font (see http://www.linux-games.com/sfont/)
and returns an sfont structure
val sfont_print : string -> int -> int -> sfont -> Sdl.Video.surface -> unit
sfont_print string_to_print x_position y_position sfont surface_to_draw_text_on
val make_mipmaps : Sdl.Video.surface -> filter -> Sdl.Video.surface array
make_mipmaps surface_bitmap scale_filter_type -> array of mipmaps down to 1x1
Makes mipmaps suitable for use in OpenGL, by generating an array of mipmaps down to 1x1.
The side of each mipmap is a power of two; if the sides of the original surface are powers of two then that
surface will be used as the first mipmap in the array, otherwise it will be scaled to the nearest power of two
and the result will be used as the first mipmap.