From 041cf94c5c32521b67010ab41ccbb1ace604a889 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Sun, 24 Feb 2019 11:07:07 +0100 Subject: [PATCH] updated glfw and sdl examples --- examples/glfw/glfw.go | 10 +++++----- examples/sdl/sdl.go | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/glfw/glfw.go b/examples/glfw/glfw.go index 4cf03e2..62dab3a 100644 --- a/examples/glfw/glfw.go +++ b/examples/glfw/glfw.go @@ -7,7 +7,7 @@ import ( "github.com/go-gl/gl/v3.2-core/gl" "github.com/go-gl/glfw/v3.2/glfw" "github.com/tfriedel6/canvas" - "github.com/tfriedel6/canvas/glimpl/gogl" + "github.com/tfriedel6/canvas/backend/gogl" ) func main() { @@ -41,8 +41,8 @@ func main() { glfw.SwapInterval(1) gl.Enable(gl.MULTISAMPLE) - // load canvas GL assets - err = canvas.LoadGL(glimplgogl.GLImpl{}) + // load GL backend + backend, err := goglbackend.New(0, 0, 0, 0) if err != nil { log.Fatalf("Error loading canvas GL assets: %v", err) } @@ -52,7 +52,7 @@ func main() { }) // initialize canvas with zero size, since size is set in main loop - cv := canvas.New(0, 0, 0, 0) + cv := canvas.New(backend) for !window.ShouldClose() { window.MakeContextCurrent() @@ -60,7 +60,7 @@ func main() { // set canvas size ww, wh := window.GetSize() - cv.SetBounds(0, 0, ww, wh) + backend.SetBounds(0, 0, ww, wh) // call the run function to do all the drawing run(cv, float64(ww), float64(wh)) diff --git a/examples/sdl/sdl.go b/examples/sdl/sdl.go index 759b343..fd37747 100644 --- a/examples/sdl/sdl.go +++ b/examples/sdl/sdl.go @@ -7,7 +7,7 @@ import ( "github.com/go-gl/gl/v3.2-core/gl" "github.com/tfriedel6/canvas" - "github.com/tfriedel6/canvas/glimpl/gogl" + "github.com/tfriedel6/canvas/backend/gogl" "github.com/veandco/go-sdl2/sdl" ) @@ -62,14 +62,14 @@ func main() { sdl.GLSetSwapInterval(1) gl.Enable(gl.MULTISAMPLE) - // load canvas GL assets - err = canvas.LoadGL(glimplgogl.GLImpl{}) + // load GL backend + backend, err := goglbackend.New(0, 0, 0, 0) if err != nil { log.Fatalf("Error loading canvas GL assets: %v", err) } // initialize canvas with zero size, since size is set in main loop - cv := canvas.New(0, 0, 0, 0) + cv := canvas.New(backend) for running := true; running; { err := window.GLMakeCurrent(glContext) @@ -92,6 +92,8 @@ func main() { } case *sdl.MouseMotionEvent: mx, my = float64(e.X), float64(e.Y) + case *sdl.QuitEvent: + running = false case *sdl.WindowEvent: if e.Type == sdl.WINDOWEVENT_CLOSE { running = false @@ -101,7 +103,7 @@ func main() { // set canvas size ww, wh := window.GetSize() - cv.SetBounds(0, 0, int(ww), int(wh)) + backend.SetBounds(0, 0, int(ww), int(wh)) // call the run function to do all the drawing run(cv, float64(ww), float64(wh))