Set-up

  1. function SDL_Init(flags : UInt32) : Integer;

    You will need to use function SDL_Init to initialise the parts of SDL that you intend to use. An example of its use is

    if SDL_Init(SDL_INIT_VIDEO) = 0 then 
      begin
         //code to load images to surfaces and perform blitting 
      end;

    The flag SDL_INIT_VIDEO is necessary for the display of surfaces. A surface is a block of memory for storing a rectangular area of pixels.

    We have provided other examples of flags in the flags section: SDL_INIT_TIMER, SDL_INIT_AUDIO, SDL_INIT_CDROM and SDL_INIT_JOYSTICK.

  2. function SDL_SetVideoMode(width, height, bpp : Integer; flags : UInt32) : PSDL_Surface;

    This vital function sets up a video mode (as does InitGraph in the Graph unit). Flags are tabulated in the help file. Examples are SDL_SWSurface and SDL_HWSurface. The identifier bpp is used extensively in SDL to represent bits-per-pixel. (In some functions such as SDL_CreateRGBSurface the identifier depth is used instead of bpp).

    See programs SDL_ImageDemo1 and SDL_ImageDemo2 for the use of SDL_HWSurface and SDL_SWSurface, respectively.

  3. procedure SDL_WM_SetCaption(title, icon : PChar);

    This procedure sets the title-bar and icon name of the display window. (Use SDL_WM_SetIcon to display an icon). e.g. SDL_WM_SetCaption('Test Screen', nil);

  4. function SDL_ShowCursor(toggle : Integer) : Integer;

    The cursor starts off displayed. You can hide it with the code SDL_ShowCursor(SDL_DISABLE) and redisplay it with SDL_ShowCursor(SDL_ENABLE).

Programming - a skill for life!

Descriptions and demonstrations of SDL procedures and functions