如何安装opengl以使其运行 [英] How to install opengl for this to run

查看:250
本文介绍了如何安装opengl以使其运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用简单的代码使用 Fyne 包创建GUI:

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

Fyne主页上所述,我需要安装OpenGL.从转到OpenGL绑定,似乎有三种安装方法:

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

我需要使用哪些命令?我正在使用Windows7并使用go version go1.12.9 windows/386

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

感谢您的帮助.

我尝试了以下命令:

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.

我也尝试过gles2,但是它没有安装而是给出了以下错误:

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.

推荐答案

OpenGL库通常来自您的图形卡驱动程序,看起来Fyne-io需要相当新的图形卡驱动程序. (它使用的是OpenGL 3.2,该版本于2009年左右发布它使用的是OpenGL 2.0).因此,您可以尝试:

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:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆