package main import "github.com/veandco/go-sdl2/sdl" /* #cgo CFLAGS: -I/home/nick/Downloads/include #cgo LDFLAGS: -L/home/nick/.local/lib -lprojectM-4 #include "projectM-4/projectM.h" */ import "C" 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_OPENGL) if err != nil { panic(err) } defer window.Destroy() context, err := window.GLCreateContext() if err != nil { panic(err) } defer sdl.GLDeleteContext(context) handle := C.projectm_create() if (handle == nil) { panic("nil") } defer C.projectm_destroy(handle) C.projectm_set_window_size(handle, 800, 600) surface, err := window.GetSurface() if err != nil { panic(err) } surface.FillRect(nil, 0) rect := sdl.Rect{0, 0, 200, 200} colour := sdl.Color{R: 255, G: 0, B: 255, A: 255} // purple pixel := sdl.MapRGBA(surface.Format, colour.R, colour.G, colour.B, colour.A) surface.FillRect(&rect, pixel) 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 } } } }