Skip to content

Instantly share code, notes, and snippets.

@eterps
Last active September 10, 2018 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eterps/2e2fad9a67327877e26200f1f168b9e1 to your computer and use it in GitHub Desktop.
Save eterps/2e2fad9a67327877e26200f1f168b9e1 to your computer and use it in GitHub Desktop.
#include "SDL.h"
#include <stdbool.h>
#include <unistd.h>
SDL_Surface *screen;
SDL_Event event;
void Do(void) {
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();
}
void Do(void);
// gcc -framework Foundation -o rect2 rect2.c Gfx.c `sdl-config --cflags` `sdl-config --libs` && ./rect2
// Simply adding this include statement fixes input focus: #include "SDL.h"
#include "Gfx.h"
int main(int argc, char *argv[]) {
Do();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment