package main import ( "log" "os" "github.com/veandco/go-sdl2/sdl" "github.com/veandco/go-sdl2/ttf" "ouichat/core" "ouichat/plugins" "ouichat/ui" ) func run() int { var err error // Initialize libraries if err = sdl.Init(sdl.INIT_EVERYTHING); err != nil { panic(err) } defer sdl.Quit() if err = ttf.Init(); err != nil { panic(err) } defer ttf.Quit() // create window window, err := sdl.CreateWindow( "ouichat", sdl.WINDOWPOS_UNDEFINED, sdl.WINDOWPOS_UNDEFINED, 1024, 768, sdl.WINDOW_SHOWN, ) if err != nil { panic(err) } defer window.Destroy() // create buffer tree tree := core.NewBufferNode("ouichat") // start plugins man := plugins.NewPluginManager(tree) man.Spawn(plugins.NewIrcPlugin("acm")) // initialize ui ui, err := ui.NewUI(window, tree) if err != nil { log.Println(err) return 1 } defer ui.Close() // main loop for { exit := ui.RenderLoop() window.UpdateSurface() if exit { break } } return 0 } func main() { var exitcode int sdl.Main(func() { exitcode = run() }) os.Exit(exitcode) }