Steward
分享是一種喜悅、更是一種幸福
微電腦 - SHARP Zaurus SL-C860 - Debian - C/C++ - Framebuffer
main.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <linux/fb.h> #include <sys/ioctl.h> #include <SDL.h> int main ( int argc, char ** argv) { uint32_t cnt = 0; SDL_Surface * screen = NULL ; uint32_t col[] = { 0xf800, 0x7e0, 0x001f }; int zero = 0, fd = open ( "/dev/fb0" , O_RDWR ); SDL_Init ( SDL_INIT_VIDEO ); screen = SDL_SetVideoMode (320, 240, 16, SDL_SWSURFACE | SDL_DOUBLEBUF ); while (cnt < 300) { cnt += 1; SDL_FillRect (screen, &screen->clip_rect, col[cnt % 3]); SDL_Flip (screen); ioctl (fd, FBIO_WAITFORVSYNC , &zero); } SDL_Quit (); close (fd); return 0; } |