### Header File

The header file may include additional information sdl_util.hrl

### Exports

alloc(Size0, Type)

Args: Size and type (?GL_UNSIGNED_INT, ...)
Returns: A reference to the memory area
Desc:
Allocates Size unit memory of Type, where Type is one of the opengl types described in gl.hrl. The memory will be garbage-collected away as any other Erlang term; thus there is no need to worry about freeing the memory.

getBin(#sdlmem{bin=Bin})

Args: References to a memory area allocated by alloc/2.
Returns: The memory allocated as a binary.
Desc:
Returns all of an allocated memory area as a binary. Note that if you do any write operation to the memory, the contents of the returned binary will change. CAVEAT PROGRAMMOR.

malloc(Size, Type)

Args: Size and type (?GL_UNSIGNED_INT, ...)
Returns: A reference to the memory area
Desc:
Obsolete name. Use alloc/2 instead.

free(_Ref)

Args: Ref to memory
Desc:
Obsolete function. Does nothing as memory blocks allocated by alloc/2 are garbage-collected.

read(#sdlmem{type=Type,bin=Bin}, Size)

Args: MemoryRef, Size
Returns: A list/Binary of Size elements of type Type
Desc:
Read allocated memory

write(#sdlmem{type=Type,size=Size,bin=Dest}, Data)

Args: MemoryRef, List|Binary
Returns: ok
Desc:
Write to data memory

write(#sdlmem{type=Type,size=Size0,bin=Dest0}, Offset, Data)

Args: MemoryRef, Offset, List|Binary
Returns: ok
Desc:
Write to memory, starting Offset unit into it.

term2bin(Bin, _, _)

Args: ListOfNumbers (or tuple), MaxNo, Type
Returns: Deep list
Desc:
Converts the first MaxNo numbers of ListOfNumbers to a binary of the type Type. Where Type is GL_TYPE existing in gl.hrl (e.g. ?GL_DOUBLE)

tuplelist2bin(2,Type,List)

Args: [TupleSize,] Type, List
Returns: Binary
Desc:
Converts a tupleList [{X,Y,..}..] to binary.

bin2list(undefined, Type, Bin)

Args: No, Type, Binary
Returns: ListOfNumbers
Desc:
Converts the first 'No' of numbers in the binary Binary to a list of numbers of type Type.

copySdlImage2GLArray(Image, Mem, Bpp)

Args: SdlImageRef, malloced Mem, BytesPerPixel
Returns: ok or exits
Desc:
Converts sdl_surface data to a byte RGB(A) buffer. sdl_surfaces are BGR and upside/down.

debug(L)

Args: Level (0 is off)
Returns: ok
Desc:
Set ESDL debug level