參考資訊:
https://www.libsdl.org/release/SDL-1.2.15/docs/html/index.html
main.c
#include <stdio.h> #include <stdlib.h> #include <SDL.h> int main(int argc, char **argv) { SDL_Surface *screen = NULL; SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(320, 240, 16, SDL_HWSURFACE); int x = 0; int y = 0; uint16_t *d = screen->pixels; for (y = 0; y < screen->h; y++) { for (x = 0; x < screen->w; x++) { *d++ = 0xf800; } } SDL_Flip(screen); SDL_Delay(3000); SDL_Quit(); return 0; }
編譯、執行
$ gcc main.c -o main -lSDL -I/usr/include/SDL $ ./main