diff --git a/src/renderer.go b/src/renderer.go index 3bfa1c8..4e08658 100644 --- a/src/renderer.go +++ b/src/renderer.go @@ -1,15 +1,8 @@ package src -import "github.com/go-gl/gl/v2.1/gl" - type Renderer2D struct {} -func (w Window) NewRenderer2D() Renderer2D { +func (a* Application) NewRenderer2D() Renderer2D { return Renderer2D{} } -func (w Renderer2D) Destroy() { - for _, i := range ImageArray { - gl.DeleteTextures(1, &i.texture) - } -} diff --git a/src/window.go b/src/window.go index e6678db..7c04515 100644 --- a/src/window.go +++ b/src/window.go @@ -70,15 +70,18 @@ func (w* Window) SetResizable(resizable bool) { func (w* Window) Close() bool { for !w.Window.ShouldClose() { - w.Window.SwapBuffers() glfw.PollEvents() - gl.Clear(gl.COLOR_BUFFER_BIT) - return false } + clean() return true } +func (w* Window) Refresh() { + w.Window.SwapBuffers() + gl.Clear(gl.COLOR_BUFFER_BIT) +} + func (w* Window) SetContextCurrent() { w.Window.MakeContextCurrent() } @@ -87,3 +90,9 @@ func (w *Window) Destroy() { w.Window.Destroy() } +func clean() { + for _, i := range ImageArray { + gl.DeleteTextures(1, &i.texture) + } +} + diff --git a/test/test1/test.go b/test/test1/test.go index 3251a7c..40a8b7c 100644 --- a/test/test1/test.go +++ b/test/test1/test.go @@ -8,7 +8,7 @@ func main() { a := vuelto.NewApp() w := a.NewWindow("hi", 800, 600, false) - ren := w.NewRenderer2D() + ren := a.NewRenderer2D() image := ren.LoadImage("test/image.png", 300, 300, 250, 250) image1 := ren.LoadImage("test/image.png", 100, 100, 150, 150) @@ -20,7 +20,8 @@ func main() { image.Draw() image1.Draw() - } - ren.Destroy() + w.Refresh() + } } +