gotk3 / gotk3-examples

164 stars 34 forks source link

error building glarea example #27

Closed davidcoble closed 3 years ago

davidcoble commented 4 years ago

I'm looking for a way to write cross platform executables in golang. This library seems like it might be a good fit. Do you know why I can't build this example?

output:

$ cd $GOPATH/src/github.com/gotk3/gotk3-examples/gtk-examples/glarea/ && go build
# github.com/gotk3/gotk3-examples/gtk-examples/glarea
./opengl.go:70:24: cannot use update (type func(*gtk.Widget, *gdk.FrameClock, uintptr) bool) as type gtk.TickCallback in argument to glarea.Widget.AddTickCallback

$ go version
go version go1.15.2 linux/amd64

$ cd $GOPATH/src/github.com/go-gl/gl && git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ cd $GOPATH/src/github.com/go-gl/mathgl && git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
qinjinze commented 4 years ago

I also get this error when compiling the program

H:\project\src\github.com\gotk3\gotk3-examples\gtk-examples\glarea>ls README.md app.go glarea.png go.mod go.sum opengl.go shaders.go triangle.go ui

H:\project\src\github.com\gotk3\gotk3-examples\gtk-examples\glarea>type go.mod module github.com/gotk3/gotk3-examples/gtk-examples/glarea

go 1.14

require ( github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 github.com/go-gl/mathgl v1.0.0 github.com/gotk3/gotk3 v0.5.0 )

H:\project\src\github.com\gotk3\gotk3-examples\gtk-examples\glarea>go build ./

github.com/gotk3/gotk3-examples/gtk-examples/glarea

.\opengl.go:70:24: cannot use update (type func(gtk.Widget, gdk.FrameClock, uintptr) bool) as type gtk.TickCallback in argument to glarea.Widget.AddTickCallback

H:\project\src\github.com\gotk3\gotk3-examples\gtk-examples\glarea>

drakbar commented 3 years ago

@davidcoble @qinjinze check out my PR that change will fix it.

The interface for gtk.TickCallback changed from (type func(*gtk.Widget, *gdk.FrameClock, uintptr) bool) to (type func(*gtk.Widget, *gdk.FrameClock, ...interface{}) bool). If you change the update function line(176) in opengl.go to func update(widget *gtk.Widget, frameClock *gdk.FrameClock, userData ...interface{}) bool { then it should build and you can then run it.