aboutsummaryrefslogtreecommitdiff
path: root/manual tests/3 standalone binaries/myapp.c
blob: 83a4e4ce22d04ec65d0cd8da88336c66c302ac9f (plain)
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
29
30
31
#include<SDL.h>

int main(int argc, char **argv) {
  SDL_Window *window;
  SDL_Surface *screenSurface;
  SDL_Event e;
  int keepGoing = 1;
  if(SDL_Init( SDL_INIT_VIDEO ) < 0) {
    printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() );
  }

  window = SDL_CreateWindow( "My application", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN );

  screenSurface = SDL_GetWindowSurface( window );

  while(keepGoing) {
    while(SDL_PollEvent(&e) != 0) {
      if(e.type == SDL_QUIT) {
        keepGoing = 0;
        break;
      }
    }
    SDL_FillRect( screenSurface, NULL, SDL_MapRGB( screenSurface->format, 0xFF, 0x00, 0x00 ) ); 
    SDL_UpdateWindowSurface( window );
    SDL_Delay(100);
  }

  SDL_DestroyWindow(window);
  SDL_Quit();
  return 0;
}