-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.swift
38 lines (31 loc) · 888 Bytes
/
main.swift
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
36
37
38
import SDL
// Initialize SDL video systems
guard SDL_Init(SDL_INIT_VIDEO) == 0 else {
fatalError("SDL could not initialize! SDL_Error: \(String(cString: SDL_GetError()))")
}
// Create a window at the center of the screen with 800x600 pixel resolution
let window = SDL_CreateWindow(
"SDL2 Minimal Demo",
Int32(SDL_WINDOWPOS_CENTERED_MASK), Int32(SDL_WINDOWPOS_CENTERED_MASK),
800, 600,
UInt32(SDL_WINDOW_SHOWN.rawValue)
)
var quit = false
var event = SDL_Event()
// Run until app is quit
while !quit {
// Poll for (input) events
while SDL_PollEvent(&event) > 0 {
// if the quit event is triggered ...
if event.type == SDL_QUIT.rawValue {
// ... quit the run loop
quit = true
}
}
// wait 100 ms
SDL_Delay(100)
}
// Destroy the window
SDL_DestroyWindow(window)
// Quit all SDL systems
SDL_Quit()