sdl_video

### Header File

The header file may include additional information sdl_video.hrl

### Exports

getSurface(Surface)

Args: Surface Ref
Returns: sdl_surface record
Desc:
Copies data pointed to by Surface to sdl_surface record.

getPixelFormat(Surface)

Args: PixelFormatRef
Returns: a sdl_pixelformat record
Desc:
Copies data pointed to by Surface to sdl_pixelformat record.

getPalette(Surface)

Args: SurfaceRef ref
Returns: a sdl_palette record
Desc:
Copies data pointed to by Surface to sdl_palette record.

getPixels(Surface, Size)

Args: Surface Ref, Size (a sdl_rectangle record)
Returns: A binary containing all pixles, size varies with pixel format
Desc:
Copies pixels (specified by Size) of Surface to a binary

setVideoMode(W, H, Bpp, Type)

Returns: a surface ref or the atom 'error'
C-API: SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags);

videoDriverName()

Returns: [Name] | []
C-API: char *SDL_VideoDriverName(char *namebuf, int maxlen);

getVideoSurface()

Returns: surface ref to the current display
C-API: SDL_Surface * SDL_GetVideoSurface(void);

videoModeOK(W, H, Bpp, Type)

Args: See sdl documentation
Returns: true | false (see sdl doc)
C-API: int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);

listModes({formatp, Ref}, Flags)

Args: PixelFormat (either as sdl_pixelformat record or a PixelFormat Ref or null) VideoFlags
Returns: [AvailableDimensions (in sdl_rect)] | all
C-API: SDL_Rect ** SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);

displayFormat(Surface)

Args: Surface Ref
Returns: Surface Ref
C-API: SDL_Surface * SDL_DisplayFormat(SDL_Surface *surface);

blitSurface(SSurf, SRect, DSurf, DRect)

Args: SrcSurfaceRef, SrcRect | null, DestSurfaceRef, DestRect | null
Returns: {ClippedSrcRect | null, ClippedDestRect | null} or {error, ErrorLevel} Where ErrorLevel = -1 | -2
C-API: int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);

fillRect(S, R, C)

Args: SurfaceRef, sdl_rectangle|null, color
Returns: true | false (on failure)
C-API: int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);

updateRect(S, X, Y, W, H)

Args: SurfaceRef, X, Y, W, H
Returns: ok
C-API: void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);

updateRects(S, R)

Args: SurfaceRef, [sdl_rect]
Returns: ok
C-API: void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects);

flip({surfacep, Ref})

Args: Surface Ref
Returns: true | false (if error)
C-API: int SDL_Flip(SDL_Surface *screen);

setColors(S, Colors, FirstColor, Ncolors)

Args: SurfaceRef, [ColorList], FirstColor, NoOfColors
Returns: true (when all colors where set) false (otherwise)
C-API: int SDL_SetColors(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);

setColorKey(Surface, Flag, Key)

Args: Surface Ref, Flag(int), Key(int)
Returns: true (on success) | false on failure
C-API: int SDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key);

mapRGB(Surface, R, G, B)

Args: Surface Ref, Int32, Int32, Int32
Returns: Int32
C-API: Uint32 SDL_MapRGB(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);

createRGBsurface(Flags, W, H, D, RM, GM, BM, AM)

Args: SurfaceFlags Width Height Depth Rmask:32 Gmask:32 Bmask:32 Amask:32
Returns: A surface ref
C-API: SDL_Surface *SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

createRGBsurfaceFrom(Pixels, W, H, D, P, RM, GM, BM, AM)

Args: Pixels(Binary) Width Height Depth Pitch Rmask:32 Gmask:32 Bmask:32 Amask:32
Returns: A surface ref
C-API: SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);

freeSurface(Surface)

Args: Surface Ref
Returns: ok
C-API: void SDL_FreeSurface(SDL_Surface *surface);

mustLock(Surface)

Args: surfaceRef
Returns: Bool
C-API: Macro

lockSurface(Surface)

Args: Surface Ref
Returns: true (if locked) false otherwise
C-API: int SDL_LockSurface(SDL_Surface *surface);

unlockSurface(Surface)

Args: Surface Ref
Returns: ok
C-API: void SDL_UnlockSurface(SDL_Surface *surface);

loadBMP(File)

Args: Name of the BMP file (string)
Returns: a surface ref or null
C-API: SDL_Surface * SDL_LoadBMP(char * file);

saveBMP(Surface, File)

Args: Name of the BMP file (string)
Returns: true or false (if it failed)
C-API: int SDL_SaveBMP(SDL_Surface *surface, char *file)

setAlpha(Surface, Flag, Alpha)

Args: SurfaceRef, Flag:32, Alpha:32
Returns: integer (undocumented in (my version of) SDL)
C-API: int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);

setClipping(Surface, Top, Left, Botton, Right)

Args: SurfaceRef, Top, Left, Botton, Right
Returns: ok
Desc:
Obsolete??

setGamma(Red,Green,Blue)

Args: red, green, blue
Returns: Bool
C-API: int SDL_SetGamma(float red, float green, float blue)

setGammaRamp(Red,Green,Blue)

Args: redList, greenList, blueList (where each list contains 256 16 bits value)
Returns: Bool
C-API: int SDL_SetGammaRamp(Uint16 red[256], Uint16 green[256], Uint16 blue[256])

getGammaRamp()

Args: none
Returns: {res, redList, greenList, blueList} (where each list contains 256 16 bits value)
C-API: int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue])
Desc:
If res is == true, the lists contain valid information

wm_setCaption(Title, IconTitle)

Args: Title List, IconTitleList
Returns: ok
C-API: void SDL_WM_SetCaption(const char *title, const char *icon);

wm_getCaption()

Returns: {TitleStr, IconTitleStr}
C-API: void SDL_WM_GetCaption(char **title, char **icon);

wm_setIcon(Icon, Mask)

Args: Icon (sdl_surface), Mask (list of bytes) | null
Returns: ok
C-API: void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);

wm_iconifyWindow()

Returns: ok
C-API: int SDL_WM_IconifyWindow(void);

wm_toggleFullScreen(Surface)

Args: SurfaceRef
Returns: true or false (on failure)
C-API: int SDL_WM_ToggleFullScreen(SDL_Surface *surface);

wm_grabInput(GrabMode)

Args: GrabMode (?SDL_GRAB_QUERY | ?SDL_GRAB_OFF | ?SDL_GRAB_ON)
Returns: GrabMode (?SDL_GRAB_OFF | ?SDL_GRAB_ON)
C-API: SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode);

wm_getInfo()

Returns: {SDLVersion = {Major, Minor, Patch}, OSSpecBinary}
Desc:
Only windows returns anything useful (window handle)

wm_isMaximized()

Returns: Boolean
Desc:
Only windows returns anything useful (window handle)

gl_setAttribute(Attr, Val)

Returns: ok
C-API: int SDL_GL_SetAttribute(SDL_GLattr attr, int value);

gl_getAttribute(Attr)

Returns: Attribute Value
C-API: int SDL_GL_GetAttribute(SDL_GLattr attr, int* value);

gl_swapBuffers()

Returns: A timestamp generated with SDL_GetTicks
C-API: void SDL_GL_SwapBuffers(void);