1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/sdl/examples/basic_window/main.v

32 lines
647 B
V
Raw Normal View History

module main
import sdl
fn main() {
C.SDL_Init(C.SDL_INIT_VIDEO)
window := C.SDL_CreateWindow('Hello SDL2', 300, 300, 500, 300, 0)
renderer := C.SDL_CreateRenderer(window, -1, C.SDL_RENDERER_ACCELERATED | C.SDL_RENDERER_PRESENTVSYNC)
mut should_close := false
for {
2019-12-14 03:31:07 +03:00
evt := SDL_Event{}
for 0 < sdl.poll_event(&evt) {
match int(evt.@type) {
C.SDL_QUIT { should_close = true }
else {}
}
}
if should_close {
break
}
C.SDL_SetRenderDrawColor(renderer, 255, 55, 55, 255)
C.SDL_RenderClear(renderer)
C.SDL_RenderPresent(renderer)
}
C.SDL_DestroyRenderer(renderer)
C.SDL_DestroyWindow(window)
C.SDL_Quit()
2019-12-18 08:13:31 +03:00
}