| 1 |
#include "SDL.h" |
| 2 |
#include <stdio.h> |
| 3 |
|
| 4 |
int main(int argc, char *argv[]) { |
| 5 |
SDL_Window *window = NULL; |
| 6 |
SDL_Surface *screenSurface = NULL; |
| 7 |
if (SDL_Init(SDL_INIT_VIDEO) < 0) { |
| 8 |
fprintf(stderr, "could not initialize sdl2: %s\n", SDL_GetError()); |
| 9 |
return 1; |
| 10 |
} |
| 11 |
window = SDL_CreateWindow( |
| 12 |
"hello_sdl2", |
| 13 |
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
| 14 |
640, 480, |
| 15 |
SDL_WINDOW_SHOWN |
| 16 |
); |
| 17 |
if (window == NULL) { |
| 18 |
fprintf(stderr, "could not create window: %s\n", SDL_GetError()); |
| 19 |
return 1; |
| 20 |
} |
| 21 |
screenSurface = SDL_GetWindowSurface(window); |
| 22 |
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0xff, 0xff, 0xff)); |
| 23 |
SDL_UpdateWindowSurface(window); |
| 24 |
SDL_Delay(100); |
| 25 |
SDL_DestroyWindow(window); |
| 26 |
SDL_Quit(); |
| 27 |
return 0; |
| 28 |
} |