2

I am trying following simple code to create a GUI using Fyne package:

// from: https://github.com/fyne-io/fyne
package main
import (
    "fyne.io/fyne/widget"
    "fyne.io/fyne/app"
)
func main() {
    app := app.New()
    w := app.NewWindow("Hello")
    w.SetContent(widget.NewVBox(
        widget.NewLabel("Hello Fyne!"),
        widget.NewButton("Quit", func() {
            app.Quit()
        }),
    ))
    w.ShowAndRun()
}

It compiles and builds executable file without any error or even warning, but on trying to run it gives following error:

I:\>rnfynetest
2019/08/25 12:37:18 Fyne error:  failed to initialise OpenGL
2019/08/25 12:37:18   Cause: glBeginConditionalRender
2019/08/25 12:37:18   At: C:/Users/ABCD/go/src/fyne.io/fyne/internal/driver/gl/window.go:1007
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x2c pc=0x572afd]

goroutine 1 [running, locked to thread]:
fyne.io/fyne/internal/driver/gl.(*window).SetContent(0x0, 0x8fc5e0, 0x1386e0c0)
        C:/Users/ABCD/go/src/fyne.io/fyne/internal/driver/gl/window.go:361 +0x1d
main.main()
        I:/rnfynetest.go:10 +0x1ce

As given on Fyne homepage I need to install OpenGL. From go bindings for OpenGL it seems there are three ways to install it:

go get -u github.com/go-gl/gl/v{3.2,3.3,4.1,4.2,4.3,4.4,4.5,4.6}-{core,compatibility}/gl
go get -u github.com/go-gl/gl/v3.1/gles2
go get -u github.com/go-gl/gl/v2.1/gl

Which of these commands do I need to use? I am working on Windows7 and using go version go1.12.9 windows/386

Thanks for your help.

Edit:

I tried following commands:

go get -u github.com/go-gl/gl/v2.1/gl
go get -u github.com/go-gl/gl/v4.6-core/gl
go get -u github.com/go-gl/gl/v4.6-compatibility/gl

They all install all right but same error is persisting on trying to run built executable.

I also tried gles2 but it does not install rather gives following error:

I:\>go get -u github.com/go-gl/gl/v3.1/gles2
# github.com/go-gl/gl/v3.1/gles2
C:\Users\ABCD\go\src\github.com\go-gl\gl\v3.1\gles2\package.go:38:11: fatal error: KHR/khrplatform.h: No such file or directory
 // #include <KHR/khrplatform.h>
           ^~~~~~~~~~~~~~~~~~~
compilation terminated.
rnso
  • 23,686
  • 25
  • 112
  • 234
  • 1
    Hi, I am not a Go developer, but typically opengl libraries come from your graphics card drivers. If it is failing to run, Chances are your drivers/hardware is too old to load the requested OpenGL context. And looks like Fyne needs OpenGL 3.2-core. ( https://github.com/fyne-io/fyne/blob/master/internal/driver/gl/window.go#L17 ). Try updating your graphics card drivers, or try using the software renderer using mesa: https://fdossena.com/?p=mesa/index.frag . – Dinesh Aug 25 '19 at 07:55
  • So I should put Mesa3D dll in same folder and try to run the built executable again? – rnso Aug 25 '19 at 08:03
  • 1
    Ok. It did not work after installing `3.2-core` version but it worked after `opengl32.dll` ! You may enter this as an answer and I will accept it. – rnso Aug 25 '19 at 08:08
  • I would like to fix Fyne so that others do not run into this problem- what hardware / operating system version are you using? – andy.xyz Aug 25 '19 at 09:01
  • I am working on `Intel(R) Core(TM) i3-3220 CPU @3.30GHz 3.30GHz` with `Windows7 64bit` with `4Gb RAM` – rnso Aug 25 '19 at 10:57
  • @ajwillia.ms : Could you comment on this question for which I have received not even one comment let alone answer: https://stackoverflow.com/questions/57630341/gui-not-running-not-finding-entry-point-in-dll – rnso Aug 25 '19 at 11:00
  • Do you know what graphics card and driver are installed? – andy.xyz Aug 25 '19 at 13:37
  • I have NVIDIA GeForce 210 card installed. – rnso Aug 25 '19 at 15:22

1 Answers1

5

The OpenGL libraries typically come from your graphics card drivers, and looks like Fyne-io needs fairly new Graphics Card Drivers. (It uses OpenGL 3.2 which was released around 2009 It uses OpenGL 2.0). So you can try to:

Or

  • Update your Graphics Card drivers - If they are available for your hardware, to get GPU accelerated OpenGL. Definitely try this this if you are planning on making a graphics intensive application).

Edit: Updated the version of the OpenGL context Fyne uses

Dinesh
  • 449
  • 2
  • 5
  • 1
    It actually only requires 2.0 - the 3.2 is just the version of the Go bindings. This older version was released in 2004, so I’m really interested in what sort of computer didn’t have it available? – andy.xyz Aug 25 '19 at 08:58
  • Actually, it builds and runs all right but font on label and button is very small. What can be done to increase size of font. – rnso Aug 25 '19 at 11:49
  • @ajwillia.ms : I have posted above comment as a separate question: https://stackoverflow.com/questions/57645973/increasing-default-font-size-of-this-simple-go-gui-application – rnso Aug 25 '19 at 12:24
  • I just tested this because I had problems with Win 7 under Virtualbox: it works fine when I either use the injector or drop the DLL next to my exe. @andy.xyz is it possible to create a single exe that contains and uses the DLL ? Do you happen to know this ? – Marged Jan 16 '20 at 07:30
  • We don't want to include software-only rendering in Fyne, it is so much slower than the code path that normally executes that it could be problematic. The root of the issue is, I think, that virtualBox has no OpenGL driver and so you need to install one, such as this DLL. If you want to re-package the windows binary to ship a software renderer for your own uses that may be possible, but I don't know the details. – andy.xyz Jan 16 '20 at 13:11