程式語言 - Free Pascal - Simple DirectMedia Layer (SDL) v1.2 - Fill Color



參考資訊:
https://www.freepascal.org/
https://wiki.lazarus.freepascal.org/FPC_and_SDL
https://sourceforge.net/projects/freepascal/files/

main.pp

program app;
 
uses sdl;
 
var
    rt : SDL_Rect;
    screen : PSDL_Surface;
 
begin
    SDL_Init(SDL_INIT_VIDEO);
    screen := SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);
    SDL_FillRect(screen, @screen^.clip_rect, SDL_MapRGB(screen^.format, $ff, $00, $00));

    rt.x := 50;
    rt.y := 50;
    rt.w := 30;
    rt.h := 30;
    SDL_FillRect(screen, @rt, SDL_MapRGB(screen^.format, $00, $ff, $00));
 
    rt.x := 100;
    rt.y := 100;
    rt.w := 50;
    rt.h := 100;
    SDL_FillRect(screen, @rt, SDL_MapRGB(screen^.format, $00, $00, $ff));
 
    SDL_Flip(screen);
    SDL_Delay(3000);
    SDL_Quit;
end.

編譯、執行

$ fpc main.pp
$ ./main