diff --git a/main.go b/main.go index b4620a0..3bb88d4 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,10 @@ import "github.com/veandco/go-sdl2/sdl" */ import "C" +import ( + "time" +) + func main() { if err := sdl.Init(sdl.INIT_EVERYTHING); err != nil { panic(err) @@ -29,25 +33,13 @@ func main() { defer sdl.GLDeleteContext(context) handle := C.projectm_create() - if (handle == nil) { + 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() { @@ -58,5 +50,9 @@ func main() { break } } + + C.projectm_opengl_render_frame(handle) + window.GLSwap() + time.Sleep(1 / 60 * time.Second) } }