added sdl-bare files
git-svn-id: svn://anubis/misc/sdl-bare@83 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
1ffea9fd12
commit
e4308eaa3f
5
Makefile
Normal file
5
Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
all:
|
||||||
|
gcc bare.c -o bare `sdl-config --cflags --libs`
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -f *~ *.o bare
|
37
bare.c
Normal file
37
bare.c
Normal file
@ -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);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user