gpt4 book ai didi

opengl - 在 Go 中使用 OpenGL

转载 作者:IT老高 更新时间:2023-10-28 13:08:32 24 4
gpt4 key购买 nike

我正在尝试在 Go 程序中使用 OpenGL。我认为我已经准备好了所有的部分,但我仍然不能让它运行起来。

我的 C 编译器是 64-bit version of mingw.它在我的%PATH%变量,并且我已经验证了它与 cgo 中的随机数示例一起使用文档。

我通过将 bin、lib 和 include 文件夹复制到 \mingw\x86_64-w64-mingw32 来安装 64 位 GLEW 1.9.0我的 mingw-w64 安装中的等价物。

当我尝试运行 go get github.com/go-gl/gl 时,请回复以下内容:

In file included from attriblocation.go:7:0:
gl.h:5:25: error: enumerator value for '__cgo_enum__5' is not an integer constant
#define GLEW_GET_FUN(x) (*x)
^
d:\programs\mingw64\x86_64-w64-mingw32\include\gl\glew.h:1956:26: note: in expansion of macro 'GLEW_GET_FUN'
#define glVertexAttrib3f GLEW_GET_FUN(__glewVertexAttrib3f)
^
gl.h:5:25: error: enumerator value for '__cgo_enum__6' is not an integer constant
#define GLEW_GET_FUN(x) (*x)

对于不超过 __cgo_enum__15 的值,这些错误会以类似的方式继续存在。 .对于每个条目,我还收到来自 Go 方面的一些匹配错误。

关于我缺少什么以使其正常工作的任何想法?

编辑:以下是 Go 方面的“匹配”日志。

attriblocation.go:42:2: error: initializer element is not constant
func (indx AttribLocation) Attrib4fv(values *[4]float32) {
^
attriblocation.go:42:2: error: (near initialization for '__cgodebug_data[5]')
attriblocation.go:43:2: error: initializer element is not constant
C.glVertexAttrib4fv(C.GLuint(indx), (*C.GLfloat)(&values[0]))
^
attriblocation.go:43:2: error: (near initialization for '__cgodebug_data[6]')
attriblocation.go:44:2: error: initializer element is not constant
}

每个 __cgodebug_data[] 都有一个5-15。

编辑 2: 我被要求附上一些日志。 Here is what happens when I compile with GCC 4.8 , 和 Here is what I get with 4.7 and 4.6 .

最佳答案

看起来这是 Go 中的一个缺陷,以及 C/Go 编译器如何相互通信。解决方法是设置 CGO_CFLAGS=-ftrack-macro-expansion=0 go build。您也可以使用 go-1.2rc5 或更新版本来解决此问题。 This bug has been closed with the previous workarounds/fixes specified .

关于opengl - 在 Go 中使用 OpenGL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16412644/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com