Skip to content

Commit

Permalink
Small bug fixes and api updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Dec 14, 2023
1 parent acbff1f commit 5fab95f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
9 changes: 1 addition & 8 deletions src/renderer.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
15 changes: 12 additions & 3 deletions src/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -87,3 +90,9 @@ func (w *Window) Destroy() {
w.Window.Destroy()
}

func clean() {
for _, i := range ImageArray {
gl.DeleteTextures(1, &i.texture)
}
}

7 changes: 4 additions & 3 deletions test/test1/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,7 +20,8 @@ func main() {

image.Draw()
image1.Draw()
}

ren.Destroy()
w.Refresh()
}
}

0 comments on commit 5fab95f

Please sign in to comment.