From e4308eaa3fbd475f5e7fc8c1a541ed07c782efc0 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 6 Dec 2008 17:06:05 +0000 Subject: [PATCH] added sdl-bare files git-svn-id: svn://anubis/misc/sdl-bare@83 bd8a9e45-a331-0410-811e-c64571078777 --- Makefile | 5 +++++ bare.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Makefile create mode 100644 bare.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9062af9 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +all: + gcc bare.c -o bare `sdl-config --cflags --libs` + +clean: + -rm -f *~ *.o bare diff --git a/bare.c b/bare.c new file mode 100644 index 0000000..b82432b --- /dev/null +++ b/bare.c @@ -0,0 +1,37 @@ +// Author: Josh Holtrop +// Date: 11/10/05 +// Purpose: barebones SDL program + +#include "SDL/SDL.h" +#include "stdio.h" + +int main() +{ + SDL_Surface *screen; + SDL_Event event; + + if (SDL_Init(SDL_INIT_VIDEO)) + { + printf("Failed to initialize SDL!\n"); + return 1; + } + + atexit(SDL_Quit); + + if (!(screen = SDL_SetVideoMode(256, 256, 32, SDL_DOUBLEBUF | SDL_HWSURFACE))) + { + printf("Failed to set video mode!\n"); + return 2; + } + + SDL_FillRect(screen, NULL, 0); + Uint32 *pixels = screen->pixels; + Uint32 c; + for (c = 0; c < 65536; c++) + *pixels++ = c; + SDL_Flip(screen); + + while (SDL_WaitEvent(&event) != 0) + if (event.type == SDL_KEYDOWN) + exit(0); +}