forked from tlively/sdl_seminar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello2_window.c
35 lines (30 loc) · 856 Bytes
/
hello2_window.c
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
32
33
34
35
/**
* hello2_window.c - Initializes SDL and creates a window
*/
#include <stdio.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_timer.h>
int main(void)
{
// attempt to initialize graphics and timer system
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER) != 0)
{
printf("error initializing SDL: %s\n", SDL_GetError());
return 1;
}
SDL_Window* win = SDL_CreateWindow("Hello, CS50!",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
640, 480, 0);
if (!win)
{
printf("error creating window: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
// wait a few seconds
SDL_Delay(5000);
// clean up resources before exiting
SDL_DestroyWindow(win);
SDL_Quit();
}