add placeholder for viewer tool

This commit is contained in:
Alex Yatskov 2018-12-17 18:16:52 -08:00
parent feeff0796e
commit 87b9cf9967

39
tools/viewer/main.go Normal file
View File

@ -0,0 +1,39 @@
package main
import "github.com/veandco/go-sdl2/sdl"
func main() {
if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil {
panic(err)
}
defer sdl.Quit()
window, err := sdl.CreateWindow("test", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED,
800, 600, sdl.WINDOW_SHOWN)
if err != nil {
panic(err)
}
defer window.Destroy()
surface, err := window.GetSurface()
if err != nil {
panic(err)
}
surface.FillRect(nil, 0)
rect := sdl.Rect{X: 0, Y: 0, W: 200, H: 200}
surface.FillRect(&rect, 0xffff0000)
window.UpdateSurface()
running := true
for running {
for event := sdl.PollEvent(); event != nil; event = sdl.PollEvent() {
switch event.(type) {
case *sdl.QuitEvent:
println("Quit")
running = false
break
}
}
}
}