program sdltest01;

{$IFDEF FPC}
  {$MODE DELPHI}
{$ENDIF}

uses SDL;

var
  Screen : PSDL_Surface; 
  Image  : PSDL_Surface; 
  Temp   : PSDL_Surface; 
begin
  WriteLn('Starting');
  if (SDL_Init(SDL_INIT_VIDEO) <> 0) then begin 
    WriteLn('Unable to initialize SDL: ', SDL_GetError()); 
	halt(1); 
  end;
  WriteLn('SDL: Init video done');
  
  try
    Screen := SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
    if not Assigned(Screen) then begin 
      WriteLn('Unable to set video mode: ', SDL_GetError()); 
	  halt(1);
    end;
	WriteLn('SDL: Set video mode done');
	
    Temp := SDL_LoadBMP('ip_bship.bmp'); 
	if not Assigned(temp) then begin
      WriteLn('Unable to load bitmap: ', SDL_GetError()); 
	  halt(1);
	end;
	WriteLn('SDL: Set video mode done');
	
    Image := SDL_DisplayFormat(Temp); 
	SDL_FreeSurface(Temp);
	WriteLn('SDL: Surface convert to display format');
	
	SDL_BlitSurface(Image, nil, Screen, nil); 
	WriteLn('SDL: Bit to screen done');
	
	SDL_Flip(Screen);
	WriteLn('SDL: Flip screen done');

    SDL_Delay(2500);

    SDL_FreeSurface(Image); 
  finally
    SDL_Quit();
	WriteLn('closing');
  end;
end.