Last active
September 9, 2018 17:38
-
-
Save eterps/07dab9b96bc657bbc89395d6cc229f27 to your computer and use it in GitHub Desktop.
Working SDL example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc rect.c -o rect `sdl-config --cflags` `sdl-config --libs` && ./rect | |
// cflags: -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE | |
// libs: -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa | |
#include "SDL.h" | |
#include <stdbool.h> | |
#include <unistd.h> | |
SDL_Surface *screen; | |
SDL_Event event; | |
int main(int argc, char *argv[]) { | |
SDL_Init(SDL_INIT_VIDEO); | |
screen = SDL_SetVideoMode(640, 480, 16, SDL_SWSURFACE); | |
SDL_WM_SetCaption("Simple Window", "Simple Window"); | |
bool done=false; | |
while(!done) { | |
while(SDL_PollEvent(&event)) { | |
if (event.type == SDL_QUIT) { | |
done=true; | |
} | |
} | |
// fill the screen with black color | |
SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0, 0, 0)); | |
// update the screen buffer | |
SDL_Flip(screen); | |
//usleep(1000 * 1000); | |
} | |
SDL_Quit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment